1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

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 #4408.
This commit is contained in:
Andreas Kling 2020-12-14 13:41:18 +01:00
parent b861de0a13
commit 34d0141da3
4 changed files with 7 additions and 25 deletions

View file

@ -283,20 +283,11 @@ void Document::set_title(const String& title)
void Document::attach_to_frame(Badge<Frame>, Frame& frame)
{
m_frame = frame;
for_each_in_subtree([&](auto& node) {
node.document_did_attach_to_frame(frame);
return IterationDecision::Continue;
});
update_layout();
}
void Document::detach_from_frame(Badge<Frame>, Frame& frame)
{
for_each_in_subtree([&](auto& node) {
node.document_will_detach_from_frame(frame);
return IterationDecision::Continue;
});
tear_down_layout_tree();
m_frame = nullptr;
}

View file

@ -147,9 +147,6 @@ public:
bool is_link() const;
virtual void document_did_attach_to_frame(Frame&) { }
virtual void document_will_detach_from_frame(Frame&) { }
void set_document(Badge<Document>, Document&);
virtual EventTarget* get_parent(const Event&) override;

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)

View file

@ -50,8 +50,7 @@ public:
void content_frame_did_load(Badge<FrameLoader>);
private:
virtual void document_did_attach_to_frame(Frame&) override;
virtual void document_will_detach_from_frame(Frame&) override;
virtual void parse_attribute(const FlyString& name, const String& value) override;
void load_src(const String&);