mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:27:35 +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)
|
Node::Node(DOM::Document& document, DOM::Node* node)
|
||||||
: m_dom_node(node ? *node : document)
|
: m_dom_node(node ? *node : document)
|
||||||
|
, m_browsing_context(*document.browsing_context())
|
||||||
, m_anonymous(node == nullptr)
|
, m_anonymous(node == nullptr)
|
||||||
{
|
{
|
||||||
m_serial_id = document.next_layout_node_serial_id({});
|
m_serial_id = document.next_layout_node_serial_id({});
|
||||||
|
@ -34,6 +35,7 @@ void Node::visit_edges(Cell::Visitor& visitor)
|
||||||
{
|
{
|
||||||
Base::visit_edges(visitor);
|
Base::visit_edges(visitor);
|
||||||
visitor.visit(m_dom_node);
|
visitor.visit(m_dom_node);
|
||||||
|
visitor.visit(m_browsing_context);
|
||||||
TreeNode::visit_edges(visitor);
|
TreeNode::visit_edges(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,14 +107,12 @@ bool Node::establishes_stacking_context() const
|
||||||
|
|
||||||
HTML::BrowsingContext const& Node::browsing_context() const
|
HTML::BrowsingContext const& Node::browsing_context() const
|
||||||
{
|
{
|
||||||
VERIFY(document().browsing_context());
|
return *m_browsing_context;
|
||||||
return *document().browsing_context();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HTML::BrowsingContext& Node::browsing_context()
|
HTML::BrowsingContext& Node::browsing_context()
|
||||||
{
|
{
|
||||||
VERIFY(document().browsing_context());
|
return *m_browsing_context;
|
||||||
return *document().browsing_context();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InitialContainingBlock const& Node::root() const
|
InitialContainingBlock const& Node::root() const
|
||||||
|
|
|
@ -152,6 +152,8 @@ private:
|
||||||
JS::NonnullGCPtr<DOM::Node> m_dom_node;
|
JS::NonnullGCPtr<DOM::Node> m_dom_node;
|
||||||
RefPtr<Painting::Paintable> m_paintable;
|
RefPtr<Painting::Paintable> m_paintable;
|
||||||
|
|
||||||
|
JS::NonnullGCPtr<HTML::BrowsingContext> m_browsing_context;
|
||||||
|
|
||||||
size_t m_serial_id { 0 };
|
size_t m_serial_id { 0 };
|
||||||
|
|
||||||
bool m_anonymous { false };
|
bool m_anonymous { false };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue