mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:57:35 +00:00
LibWeb: Give Paintable its own pointer to the corresponding DOM node
Instead of going through the layout node's DOM pointer.
This commit is contained in:
parent
216bd513fa
commit
e67ac16862
3 changed files with 21 additions and 2 deletions
|
@ -208,6 +208,7 @@ static void build_paint_tree(Node& node, Painting::Paintable* parent_paintable =
|
|||
}
|
||||
parent_paintable->append_child(paintable);
|
||||
}
|
||||
paintable.set_dom_node(node.dom_node());
|
||||
for (auto* child = node.first_child(); child; child = child->next_sibling()) {
|
||||
build_paint_tree(*child, &paintable);
|
||||
}
|
||||
|
|
|
@ -14,11 +14,27 @@ namespace Web::Painting {
|
|||
void Paintable::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_dom_node);
|
||||
visitor.visit(m_layout_node);
|
||||
if (m_containing_block.has_value())
|
||||
visitor.visit(m_containing_block.value());
|
||||
}
|
||||
|
||||
void Paintable::set_dom_node(JS::GCPtr<DOM::Node> dom_node)
|
||||
{
|
||||
m_dom_node = dom_node;
|
||||
}
|
||||
|
||||
JS::GCPtr<DOM::Node> Paintable::dom_node()
|
||||
{
|
||||
return m_dom_node;
|
||||
}
|
||||
|
||||
JS::GCPtr<DOM::Node const> Paintable::dom_node() const
|
||||
{
|
||||
return m_dom_node;
|
||||
}
|
||||
|
||||
Paintable::DispatchEventOfSameName Paintable::handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned)
|
||||
{
|
||||
return DispatchEventOfSameName::Yes;
|
||||
|
|
|
@ -131,8 +131,9 @@ public:
|
|||
Layout::Node const& layout_node() const { return m_layout_node; }
|
||||
Layout::Node& layout_node() { return const_cast<Layout::Node&>(*m_layout_node); }
|
||||
|
||||
DOM::Node* dom_node() { return layout_node().dom_node(); }
|
||||
DOM::Node const* dom_node() const { return layout_node().dom_node(); }
|
||||
[[nodiscard]] JS::GCPtr<DOM::Node> dom_node();
|
||||
[[nodiscard]] JS::GCPtr<DOM::Node const> dom_node() const;
|
||||
void set_dom_node(JS::GCPtr<DOM::Node>);
|
||||
|
||||
auto const& computed_values() const { return m_layout_node->computed_values(); }
|
||||
|
||||
|
@ -164,6 +165,7 @@ protected:
|
|||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
private:
|
||||
JS::GCPtr<DOM::Node> m_dom_node;
|
||||
JS::NonnullGCPtr<Layout::Node const> m_layout_node;
|
||||
Optional<JS::GCPtr<Layout::Box const>> mutable m_containing_block;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue