Commit Graph

2 Commits

Author SHA1 Message Date
Andreas Kling
229eba9a06 LibWeb: Clip against scroll containers in IntersectionObserver
Implement the containing block chain traversal in compute_intersection
(steps 2-3 of the spec algorithm). Walk from the target's paintable box
up through the containing block chain, clipping the intersection rect
against each ancestor that has a content clip (overflow != visible).

This fixes the case where a target is inside an overflow:hidden or
overflow:clip container and pushed below the visible area. Previously,
the intersection ratio was incorrectly non-zero because we only
intersected with the root bounds (viewport), not intermediate
scroll containers.

Also update the scroll container clipping tests to verify the
intersection ratio (which is what compute_intersection affects)
rather than isIntersecting (which per spec is based on targetRect
vs rootBounds, not the clipped intersection rect).
2026-03-22 14:09:22 -05:00
Andreas Kling
d1b485e6d6 Tests: Add IntersectionObserver tests for scroll container clipping
Add tests for the implicit root case where targets are inside scroll
containers with various overflow types:

- overflow:hidden container with target pushed below visible area:
  should NOT be intersecting (currently wrong, shows intersecting).
- overflow:clip container with target pushed below visible area:
  should NOT be intersecting (currently wrong, shows intersecting).
- overflow:hidden container with target at top (visible):
  should be intersecting (correct).

The two failing tests currently reflect wrong behavior because
compute_intersection does not clip against intermediate scroll
containers when walking the containing block chain.
2026-03-22 14:09:22 -05:00