LibWeb: Simplify <iframe> content frame construction

Now that documents are attached to their frame *before* parsing, we can
create the content frame of <iframe> elements right away, instead of
waiting for the host frame attachment.

Fixes .
This commit is contained in:
Andreas Kling 2020-12-14 13:41:18 +01:00
parent b861de0a13
commit 34d0141da3
Notes: sideshowbarker 2024-07-19 00:52:59 +09:00
4 changed files with 7 additions and 25 deletions
Libraries/LibWeb/HTML

View file

@ -46,6 +46,8 @@ namespace Web::HTML {
HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, const QualifiedName& qualified_name)
: HTMLElement(document, qualified_name)
{
ASSERT(document.frame());
m_content_frame = Frame::create_subframe(*this, document.frame()->main_frame());
}
HTMLIFrameElement::~HTMLIFrameElement()
@ -58,18 +60,11 @@ RefPtr<Layout::Node> HTMLIFrameElement::create_layout_node(const CSS::StylePrope
return adopt(*new Layout::FrameBox(document(), *this, move(style)));
}
void HTMLIFrameElement::document_did_attach_to_frame(Frame& frame)
{
ASSERT(!m_content_frame);
m_content_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::parse_attribute(const FlyString& name, const String& value)
{
HTMLElement::parse_attribute(name, value);
if (name == HTML::AttributeNames::src)
load_src(value);
}
void HTMLIFrameElement::load_src(const String& value)