mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Use FrameLoader to load iframes :^)
This commit is contained in:
parent
075bd75859
commit
5c0ee72b30
Notes:
sideshowbarker
2024-07-19 05:48:32 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5c0ee72b300
3 changed files with 9 additions and 16 deletions
|
@ -76,21 +76,12 @@ void HTMLIFrameElement::load_src(const String& value)
|
|||
return;
|
||||
}
|
||||
|
||||
ResourceLoader::the().load_sync(
|
||||
url,
|
||||
[&](auto& data, auto& headers) {
|
||||
(void)headers;
|
||||
auto html_source = String::copy(data);
|
||||
HTMLDocumentParser parser(html_source, "utf-8");
|
||||
parser.run(url);
|
||||
m_hosted_frame->set_document(&parser.document());
|
||||
m_hosted_frame->on_set_needs_display = [this](auto&) {
|
||||
if (layout_node())
|
||||
layout_node()->set_needs_display();
|
||||
};
|
||||
|
||||
dbg() << "The hosted frame now has this DOM:";
|
||||
dump_tree(*m_hosted_frame->document());
|
||||
},
|
||||
[&](auto& error) {
|
||||
dbg() << "<iframe> failed to load: " << error;
|
||||
});
|
||||
m_hosted_frame->loader().load(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ void Frame::set_size(const Gfx::Size& size)
|
|||
if (m_size == size)
|
||||
return;
|
||||
m_size = size;
|
||||
if (m_document)
|
||||
m_document->layout();
|
||||
}
|
||||
|
||||
void Frame::set_viewport_rect(const Gfx::Rect& rect)
|
||||
|
|
|
@ -48,6 +48,8 @@ LayoutFrame::~LayoutFrame()
|
|||
|
||||
void LayoutFrame::layout(LayoutMode layout_mode)
|
||||
{
|
||||
ASSERT(node().hosted_frame());
|
||||
|
||||
set_has_intrinsic_width(true);
|
||||
set_has_intrinsic_height(true);
|
||||
// FIXME: Do proper error checking, etc.
|
||||
|
@ -81,8 +83,6 @@ void LayoutFrame::did_set_rect()
|
|||
|
||||
ASSERT(node().hosted_frame());
|
||||
node().hosted_frame()->set_size(Gfx::Size(rect().width(), rect().height()));
|
||||
|
||||
node().hosted_frame()->document()->layout();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue