summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-09 18:10:32 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-09 18:14:24 +0100
commit1e53cc3f5b48451e8208b52ef5d14dc3b7e245e9 (patch)
tree37257dd19bafa5005d855aae7668d6e10f76f75e /Userland/Libraries/LibWeb
parent6499cf4d280654d1b30cd7366a29d3acc53a46b3 (diff)
downloadserenity-1e53cc3f5b48451e8208b52ef5d14dc3b7e245e9.zip
LibWeb: Establish parent/child relationship between BrowsingContexts
When an iframe is inserted or removed from a document, we now take it in and out of the BrowsingContext tree.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp8
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
index 8f54c03c2a..e4d8b533d7 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp
@@ -31,11 +31,19 @@ void BrowsingContextContainer::inserted()
if (auto* browsing_context = document().browsing_context()) {
VERIFY(browsing_context->page());
m_nested_browsing_context = BrowsingContext::create_nested(*browsing_context->page(), *this);
+ browsing_context->append_child(*m_nested_browsing_context);
m_nested_browsing_context->set_frame_nesting_levels(browsing_context->frame_nesting_levels());
m_nested_browsing_context->register_frame_nesting(document().url());
}
}
+void BrowsingContextContainer::removed_from(Node* old_parent)
+{
+ HTMLElement::removed_from(old_parent);
+ if (m_nested_browsing_context && m_nested_browsing_context->parent())
+ m_nested_browsing_context->parent()->remove_child(*m_nested_browsing_context);
+}
+
// https://html.spec.whatwg.org/multipage/browsers.html#concept-bcc-content-document
const DOM::Document* BrowsingContextContainer::content_document() const
{
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h
index 968b2e6da2..9b49ba952e 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h
@@ -22,6 +22,7 @@ public:
DOM::Document const* content_document_without_origin_check() const;
virtual void inserted() override;
+ virtual void removed_from(Node*) override;
protected:
RefPtr<BrowsingContext> m_nested_browsing_context;