1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-07 05:27:35 +00:00

LibWeb: Delay sub-Frame construction until host Document is attached

While we're parsing a new document, we don't have a Frame to grab at.
We now use the Node::document_did_attach_to_frame() notification hook
to delay subframe construction.

With this, subframes now always have a valid reference to their
enclosing main frame.
This commit is contained in:
Andreas Kling 2020-06-06 15:08:36 +02:00
parent 285a4165f3
commit 38ada2d102
4 changed files with 31 additions and 15 deletions

View file

@ -44,7 +44,6 @@ namespace Web {
HTMLIFrameElement::HTMLIFrameElement(Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)
{
m_hosted_frame = Frame::create_subframe();
}
HTMLIFrameElement::~HTMLIFrameElement()
@ -57,14 +56,18 @@ RefPtr<LayoutNode> HTMLIFrameElement::create_layout_node(const StyleProperties*
return adopt(*new LayoutFrame(*this, move(style)));
}
void HTMLIFrameElement::parse_attribute(const FlyString& name, const String& value)
void HTMLIFrameElement::document_did_attach_to_frame(Frame& frame)
{
HTMLElement::parse_attribute(name, value);
if (name == HTML::AttributeNames::src) {
load_src(value);
ASSERT(!m_hosted_frame);
m_hosted_frame = Frame::create_subframe(*this, frame.main_frame());
auto src = attribute(HTML::AttributeNames::src);
if (src.is_null())
return;
}
load_src(src);
}
void HTMLIFrameElement::document_will_detach_from_frame(Frame&)
{
}
void HTMLIFrameElement::load_src(const String& value)