LibWeb: Use unsafe layout/paintable accessors where appropriate

Add unsafe_layout_node(), unsafe_paintable(), and unsafe_paintable_box()
accessors that skip layout-staleness verification. These are for use in
contexts where accessing layout/paintable data is legitimate despite
layout not being up to date: tree construction, style recalculation,
painting, animation interpolation, DOM mutation, and invalidation
propagation.

Also add wrapper APIs on Node to centralize common patterns:
- set_needs_display() wraps if (unsafe_paintable()) ...set_needs_display
- set_needs_paint_only_properties_update() wraps similar
- set_needs_layout_update() wraps if (unsafe_layout_node()) ...

And add Document::layout_is_up_to_date() which checks whether layout
tree update flags are all clear.
This commit is contained in:
Andreas Kling
2026-02-26 11:57:29 +01:00
committed by Andreas Kling
parent b8b63ddc8f
commit a146225331
Notes: github-actions[bot] 2026-02-26 20:10:33 +00:00
48 changed files with 396 additions and 225 deletions

View File

@@ -42,14 +42,17 @@ WebIDL::ExceptionOr<GC::Ref<ResizeObserverEntry>> ResizeObserverEntry::create_an
double height = content_box_size->block_size();
// 7. If target is not an SVG element or target is an SVG element with an associated CSS layout box do these steps:
if (!target.is_svg_element() && target.paintable_box()) {
auto const& paintable_box = *target.paintable_box();
// NB: Layout was up to date when observations were gathered, but a previous
// observer's callback may have invalidated it before we get here.
// This matches the behavior of all major browsers.
if (!target.is_svg_element() && target.unsafe_paintable_box()) {
auto const& paintable_box = *target.unsafe_paintable_box();
auto absolute_padding_rect = paintable_box.absolute_padding_box_rect();
// Set this.contentRect.top to target.padding top.
y = absolute_padding_rect.y().to_double();
// Set this.contentRect.left to target.padding left.
x = absolute_padding_rect.x().to_double();
} else if (target.is_svg_element() && target.paintable_box()) {
} else if (target.is_svg_element() && target.unsafe_paintable_box()) {
// 8. If target is an SVG element without an associated CSS layout box do these steps:
// Set this.contentRect.top and this.contentRect.left to 0.
// NOTE: This is already done by the default constructor.