diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index b8bc63fe3f..a85a23d280 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -283,20 +283,11 @@ void Document::set_title(const String& title) void Document::attach_to_frame(Badge, 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) { - for_each_in_subtree([&](auto& node) { - node.document_will_detach_from_frame(frame); - return IterationDecision::Continue; - }); - tear_down_layout_tree(); m_frame = nullptr; } diff --git a/Libraries/LibWeb/DOM/Node.h b/Libraries/LibWeb/DOM/Node.h index b34a3a1182..7fc2b9bbaa 100644 --- a/Libraries/LibWeb/DOM/Node.h +++ b/Libraries/LibWeb/DOM/Node.h @@ -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&); virtual EventTarget* get_parent(const Event&) override; diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index b2488620c2..937ca36321 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -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 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) diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Libraries/LibWeb/HTML/HTMLIFrameElement.h index f3f96d40fb..6688cb0a6c 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -50,8 +50,7 @@ public: void content_frame_did_load(Badge); 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&);