Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0445b6c42fa52f5d4ca8e9a2f655a2faa7a81089
      
https://github.com/WebKit/WebKit/commit/0445b6c42fa52f5d4ca8e9a2f655a2faa7a81089
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-07-16 (Thu, 16 Jul 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/multiple-aligned-targets/common-to-both-axes-supercedes-first-in-tree-order-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/multiple-aligned-targets/prefer-common-to-both-axes-expected.txt
    M LayoutTests/platform/mac/TestExpectations
    M Source/WebCore/platform/ScrollSnapAnimatorState.cpp
    M Source/WebCore/platform/ScrollSnapAnimatorState.h

  Log Message:
  -----------
  [CSS Scroll Snap] Re-snap should select the snap area aligned in both axes 
among multiple aligned targets
https://bugs.webkit.org/show_bug.cgi?id=319478
rdar://182285397

Reviewed by Simon Fraser.

Per CSS Scroll Snap "Selecting between multiple aligned snap areas" [1], after
focused and targeted areas and ancestor removal (innermost wins), if the block
and inline sets of aligned areas overlap they are replaced with their
intersection before falling back to first in tree order. We stopped at first in
tree order and evaluated each axis independently, so we picked each axis's
first-in-tree box instead of the box common to both axes. Blink and Gecko both
select the common box; WebKit was the only engine that did not. We also
re-derived the target on every layout change, letting a box that became common
(or first in tree) after a layout shift steal selection from the tracked box.

Selection now intersects the two axes' innermost-level candidate lists and
prefers the common box over tree order; since snap area indices are in tree
order, both axes converge on the same box. Re-snap keeps the box it actually
followed as the recorded target so a later layout shift does not abandon it.

[1] https://drafts.csswg.org/css-scroll-snap/#multiple-aligned-snap-areas

* Source/WebCore/platform/ScrollSnapAnimatorState.cpp:
(WebCore::ScrollSnapAnimatorState::selectSnapTargetForAxis): Prefer a candidate
also aligned in the other axis before first in tree order.
(WebCore::ScrollSnapAnimatorState::innermostAlignedAreaIndicesForAxis): Added;
aligned areas at the axis's active offset with ancestors removed, in tree order.
(WebCore::ScrollSnapAnimatorState::resnapAfterLayout): Keep the followed target
as the recorded target across layout changes.
* Source/WebCore/platform/ScrollSnapAnimatorState.h:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/multiple-aligned-targets/prefer-common-to-both-axes-expected.txt:
 Progression
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/multiple-aligned-targets/common-to-both-axes-supercedes-first-in-tree-order-expected.txt:
 Ditto
* LayoutTests/platform/mac/TestExpectations: Unskip Passing test now

Canonical link: https://commits.webkit.org/317294@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to