1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:17:45 +00:00

LibWeb: Give paintables their own pointer to the BrowsingContext

This commit is contained in:
Andreas Kling 2023-08-18 13:21:38 +02:00
parent e67ac16862
commit 6b3af92262
2 changed files with 21 additions and 6 deletions

View file

@ -11,11 +11,18 @@
namespace Web::Painting {
Paintable::Paintable(Layout::Node const& layout_node)
: m_layout_node(layout_node)
, m_browsing_context(const_cast<HTML::BrowsingContext&>(layout_node.browsing_context()))
{
}
void Paintable::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_dom_node);
visitor.visit(m_layout_node);
visitor.visit(m_browsing_context);
if (m_containing_block.has_value())
visitor.visit(m_containing_block.value());
}
@ -35,6 +42,16 @@ JS::GCPtr<DOM::Node const> Paintable::dom_node() const
return m_dom_node;
}
HTML::BrowsingContext const& Paintable::browsing_context() const
{
return m_browsing_context;
}
HTML::BrowsingContext& Paintable::browsing_context()
{
return m_browsing_context;
}
Paintable::DispatchEventOfSameName Paintable::handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned, unsigned)
{
return DispatchEventOfSameName::Yes;

View file

@ -139,8 +139,8 @@ public:
bool visible_for_hit_testing() const { return computed_values().pointer_events() != CSS::PointerEvents::None; }
HTML::BrowsingContext const& browsing_context() const { return m_layout_node->browsing_context(); }
HTML::BrowsingContext& browsing_context() { return layout_node().browsing_context(); }
[[nodiscard]] HTML::BrowsingContext const& browsing_context() const;
[[nodiscard]] HTML::BrowsingContext& browsing_context();
void set_needs_display() const { const_cast<Layout::Node&>(*m_layout_node).set_needs_display(); }
@ -157,16 +157,14 @@ public:
StackingContext const* stacking_context_rooted_here() const;
protected:
explicit Paintable(Layout::Node const& layout_node)
: m_layout_node(layout_node)
{
}
explicit Paintable(Layout::Node const&);
virtual void visit_edges(Cell::Visitor&) override;
private:
JS::GCPtr<DOM::Node> m_dom_node;
JS::NonnullGCPtr<Layout::Node const> m_layout_node;
JS::NonnullGCPtr<HTML::BrowsingContext> m_browsing_context;
Optional<JS::GCPtr<Layout::Box const>> mutable m_containing_block;
};