mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:57:34 +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
3 changed files with 14 additions and 6 deletions
|
@ -41,6 +41,7 @@
|
||||||
#include <LibWeb/Layout/Node.h>
|
#include <LibWeb/Layout/Node.h>
|
||||||
#include <LibWeb/Layout/TextNode.h>
|
#include <LibWeb/Layout/TextNode.h>
|
||||||
#include <LibWeb/Layout/Viewport.h>
|
#include <LibWeb/Layout/Viewport.h>
|
||||||
|
#include <LibWeb/Painting/Paintable.h>
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
|
||||||
|
@ -103,6 +104,7 @@ void Node::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(m_child_nodes);
|
visitor.visit(m_child_nodes);
|
||||||
|
|
||||||
visitor.visit(m_layout_node);
|
visitor.visit(m_layout_node);
|
||||||
|
visitor.visit(m_paintable);
|
||||||
|
|
||||||
for (auto& registered_observer : m_registered_observer_list)
|
for (auto& registered_observer : m_registered_observer_list)
|
||||||
visitor.visit(registered_observer);
|
visitor.visit(registered_observer);
|
||||||
|
@ -1438,18 +1440,19 @@ size_t Node::length() const
|
||||||
return child_count();
|
return child_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::set_paintable(JS::GCPtr<Painting::Paintable> paintable)
|
||||||
|
{
|
||||||
|
m_paintable = paintable;
|
||||||
|
}
|
||||||
|
|
||||||
Painting::Paintable const* Node::paintable() const
|
Painting::Paintable const* Node::paintable() const
|
||||||
{
|
{
|
||||||
if (!layout_node())
|
return m_paintable;
|
||||||
return nullptr;
|
|
||||||
return layout_node()->paintable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Painting::Paintable* Node::paintable()
|
Painting::Paintable* Node::paintable()
|
||||||
{
|
{
|
||||||
if (!layout_node())
|
return m_paintable;
|
||||||
return nullptr;
|
|
||||||
return layout_node()->paintable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Painting::PaintableBox const* Node::paintable_box() const
|
Painting::PaintableBox const* Node::paintable_box() const
|
||||||
|
|
|
@ -187,6 +187,8 @@ public:
|
||||||
Painting::Paintable const* paintable() const;
|
Painting::Paintable const* paintable() const;
|
||||||
Painting::Paintable* paintable();
|
Painting::Paintable* paintable();
|
||||||
|
|
||||||
|
void set_paintable(JS::GCPtr<Painting::Paintable>);
|
||||||
|
|
||||||
void set_layout_node(Badge<Layout::Node>, JS::NonnullGCPtr<Layout::Node>);
|
void set_layout_node(Badge<Layout::Node>, JS::NonnullGCPtr<Layout::Node>);
|
||||||
void detach_layout_node(Badge<Layout::TreeBuilder>);
|
void detach_layout_node(Badge<Layout::TreeBuilder>);
|
||||||
|
|
||||||
|
@ -671,6 +673,7 @@ protected:
|
||||||
|
|
||||||
JS::GCPtr<Document> m_document;
|
JS::GCPtr<Document> m_document;
|
||||||
JS::GCPtr<Layout::Node> m_layout_node;
|
JS::GCPtr<Layout::Node> m_layout_node;
|
||||||
|
JS::GCPtr<Painting::Paintable> m_paintable;
|
||||||
NodeType m_type { NodeType::INVALID };
|
NodeType m_type { NodeType::INVALID };
|
||||||
bool m_needs_style_update { false };
|
bool m_needs_style_update { false };
|
||||||
bool m_child_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);
|
parent_paintable->append_child(paintable);
|
||||||
}
|
}
|
||||||
paintable.set_dom_node(node.dom_node());
|
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()) {
|
for (auto* child = node.first_child(); child; child = child->next_sibling()) {
|
||||||
build_paint_tree(*child, &paintable);
|
build_paint_tree(*child, &paintable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue