mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-03 06:35:20 +00:00
LibWeb: Give DOM::Node a direct pointer to its Paintable
Instead of going via the layout tree.
This commit is contained in:
parent
25375bf1d5
commit
3d7c880a42
|
@ -41,6 +41,7 @@
|
|||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -103,6 +104,7 @@ void Node::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_child_nodes);
|
||||
|
||||
visitor.visit(m_layout_node);
|
||||
visitor.visit(m_paintable);
|
||||
|
||||
for (auto& registered_observer : m_registered_observer_list)
|
||||
visitor.visit(registered_observer);
|
||||
|
@ -1438,18 +1440,19 @@ size_t Node::length() const
|
|||
return child_count();
|
||||
}
|
||||
|
||||
void Node::set_paintable(JS::GCPtr<Painting::Paintable> paintable)
|
||||
{
|
||||
m_paintable = paintable;
|
||||
}
|
||||
|
||||
Painting::Paintable const* Node::paintable() const
|
||||
{
|
||||
if (!layout_node())
|
||||
return nullptr;
|
||||
return layout_node()->paintable();
|
||||
return m_paintable;
|
||||
}
|
||||
|
||||
Painting::Paintable* Node::paintable()
|
||||
{
|
||||
if (!layout_node())
|
||||
return nullptr;
|
||||
return layout_node()->paintable();
|
||||
return m_paintable;
|
||||
}
|
||||
|
||||
Painting::PaintableBox const* Node::paintable_box() const
|
||||
|
|
|
@ -187,6 +187,8 @@ public:
|
|||
Painting::Paintable const* paintable() const;
|
||||
Painting::Paintable* paintable();
|
||||
|
||||
void set_paintable(JS::GCPtr<Painting::Paintable>);
|
||||
|
||||
void set_layout_node(Badge<Layout::Node>, JS::NonnullGCPtr<Layout::Node>);
|
||||
void detach_layout_node(Badge<Layout::TreeBuilder>);
|
||||
|
||||
|
@ -671,6 +673,7 @@ protected:
|
|||
|
||||
JS::GCPtr<Document> m_document;
|
||||
JS::GCPtr<Layout::Node> m_layout_node;
|
||||
JS::GCPtr<Painting::Paintable> m_paintable;
|
||||
NodeType m_type { NodeType::INVALID };
|
||||
bool m_needs_style_update { false };
|
||||
bool m_child_needs_style_update { false };
|
||||
|
|
|
@ -209,6 +209,8 @@ static void build_paint_tree(Node& node, Painting::Paintable* parent_paintable =
|
|||
parent_paintable->append_child(paintable);
|
||||
}
|
||||
paintable.set_dom_node(node.dom_node());
|
||||
if (node.dom_node())
|
||||
node.dom_node()->set_paintable(&paintable);
|
||||
for (auto* child = node.first_child(); child; child = child->next_sibling()) {
|
||||
build_paint_tree(*child, &paintable);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue