LibWeb: Use FrameLoader to load iframes :^)

This commit is contained in:
Andreas Kling 2020-06-06 13:10:11 +02:00
parent 075bd75859
commit 5c0ee72b30
Notes: sideshowbarker 2024-07-19 05:48:32 +09:00
3 changed files with 9 additions and 16 deletions

View file

@ -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);
}
}

View file

@ -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)

View file

@ -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();
}
}