mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 06:25:06 +00:00
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.
This commit is contained in:
parent
6499cf4d28
commit
1e53cc3f5b
2 changed files with 9 additions and 0 deletions
|
@ -31,11 +31,19 @@ void BrowsingContextContainer::inserted()
|
||||||
if (auto* browsing_context = document().browsing_context()) {
|
if (auto* browsing_context = document().browsing_context()) {
|
||||||
VERIFY(browsing_context->page());
|
VERIFY(browsing_context->page());
|
||||||
m_nested_browsing_context = BrowsingContext::create_nested(*browsing_context->page(), *this);
|
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->set_frame_nesting_levels(browsing_context->frame_nesting_levels());
|
||||||
m_nested_browsing_context->register_frame_nesting(document().url());
|
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
|
// https://html.spec.whatwg.org/multipage/browsers.html#concept-bcc-content-document
|
||||||
const DOM::Document* BrowsingContextContainer::content_document() const
|
const DOM::Document* BrowsingContextContainer::content_document() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
DOM::Document const* content_document_without_origin_check() const;
|
DOM::Document const* content_document_without_origin_check() const;
|
||||||
|
|
||||||
virtual void inserted() override;
|
virtual void inserted() override;
|
||||||
|
virtual void removed_from(Node*) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RefPtr<BrowsingContext> m_nested_browsing_context;
|
RefPtr<BrowsingContext> m_nested_browsing_context;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue