LibWeb: Apply scroll margin in IntersectionObserver compute_intersection

Per the spec, the observer's [[scrollMargin]] should be applied to
each scroll container's scrollport when walking the containing block
chain. This expands the effective clip rect, allowing targets to be
detected as intersecting before they actually enter the visible area
of the scroll container.

Add a scroll_margin_values() accessor to IntersectionObserver so the
raw LengthPercentage values can be used during intersection computation.
The scroll margin is applied by inflating the scroll container's
padding box rect before clipping the intersection rect against it.
This commit is contained in:
Andreas Kling
2026-03-22 08:58:44 -05:00
committed by Andreas Kling
parent c871c56178
commit 9abb7e4517
Notes: github-actions[bot] 2026-03-22 19:10:54 +00:00
3 changed files with 17 additions and 2 deletions

View File

@@ -45,6 +45,7 @@ public:
Variant<GC::Root<DOM::Element>, GC::Root<DOM::Document>, Empty> root() const;
String root_margin() const;
String scroll_margin() const;
Vector<CSS::LengthPercentage> const& scroll_margin_values() const { return m_scroll_margin; }
Vector<double> const& thresholds() const { return m_thresholds; }
long delay() const { return m_delay; }
bool track_visibility() const { return m_track_visibility; }