LibWeb: Add VERIFY checks to layout_node(), paintable(), paintable_box()

Add VERIFY(document().layout_is_up_to_date()) assertions to the safe
layout_node() and paintable() accessors on DOM::Node. These catch cases
where code accesses layout or paint data without first ensuring layout
is up to date.

Code that legitimately needs to access layout/paintable data when layout
is stale (e.g. during tree construction, style recalculation, painting,
or invalidation propagation) should use the unsafe_layout_node(),
unsafe_paintable(), or unsafe_paintable_box() accessors instead.
This commit is contained in:
Andreas Kling 2026-02-26 12:00:16 +01:00 committed by Andreas Kling
parent a146225331
commit 5fe1a70c8e

View file

@ -2653,11 +2653,15 @@ size_t Node::length() const
Layout::Node const* Node::layout_node() const
{
if (m_layout_node)
VERIFY(document().layout_is_up_to_date());
return m_layout_node;
}
Layout::Node* Node::layout_node()
{
if (m_layout_node)
VERIFY(document().layout_is_up_to_date());
return m_layout_node;
}
@ -2691,11 +2695,15 @@ void Node::set_needs_layout_update(SetNeedsLayoutReason reason)
Painting::Paintable const* Node::paintable() const
{
if (m_paintable)
VERIFY(document().layout_is_up_to_date());
return m_paintable;
}
Painting::Paintable* Node::paintable()
{
if (m_paintable)
VERIFY(document().layout_is_up_to_date());
return m_paintable;
}