mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 17:18:11 +00:00
LibWeb: Tie layout tree to a specific browsing context
Now that both the layout tree and browsing context are GC-allocated, we can formalize their relationship a bit better by having layout nodes keep a NonnullGCPtr to the browsing context. This makes the previously-indirect link direct, removing an unpleasant "how do we know the browsing context is alive" question when accessing it from the layout tree.
This commit is contained in:
parent
b9dc0b7d1b
commit
6d830e6335
2 changed files with 6 additions and 4 deletions
|
@ -20,6 +20,7 @@ namespace Web::Layout {
|
|||
|
||||
Node::Node(DOM::Document& document, DOM::Node* node)
|
||||
: m_dom_node(node ? *node : document)
|
||||
, m_browsing_context(*document.browsing_context())
|
||||
, m_anonymous(node == nullptr)
|
||||
{
|
||||
m_serial_id = document.next_layout_node_serial_id({});
|
||||
|
@ -34,6 +35,7 @@ void Node::visit_edges(Cell::Visitor& visitor)
|
|||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_dom_node);
|
||||
visitor.visit(m_browsing_context);
|
||||
TreeNode::visit_edges(visitor);
|
||||
}
|
||||
|
||||
|
@ -105,14 +107,12 @@ bool Node::establishes_stacking_context() const
|
|||
|
||||
HTML::BrowsingContext const& Node::browsing_context() const
|
||||
{
|
||||
VERIFY(document().browsing_context());
|
||||
return *document().browsing_context();
|
||||
return *m_browsing_context;
|
||||
}
|
||||
|
||||
HTML::BrowsingContext& Node::browsing_context()
|
||||
{
|
||||
VERIFY(document().browsing_context());
|
||||
return *document().browsing_context();
|
||||
return *m_browsing_context;
|
||||
}
|
||||
|
||||
InitialContainingBlock const& Node::root() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue