Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a30df7ba2f8b4f0c90f96d2170b5dd1997f8ee73
https://github.com/WebKit/WebKit/commit/a30df7ba2f8b4f0c90f96d2170b5dd1997f8ee73
Author: Ahmad Saleem <[email protected]>
Date: 2026-07-15 (Wed, 15 Jul 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/multiple-aligned-targets/nested-supercedes-common-to-both-axes-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/multiple-aligned-targets/prefer-inner-target-expected.txt
M Source/WebCore/platform/ScrollSnapAnimatorState.cpp
M Source/WebCore/platform/ScrollSnapAnimatorState.h
Log Message:
-----------
[CSS Scroll Snap] Re-snap should select the innermost aligned snap area per
axis
https://bugs.webkit.org/show_bug.cgi?id=317992
rdar://180779865
Reviewed by Simon Fraser.
When several snap areas are aligned at the same offset, the re-snap algorithm
(https://drafts.csswg.org/css-scroll-snap-1/#multiple-aligned) selects, per
axis,
the focused box, then the targeted box, then the innermost box, then the first
in
tree order. WebCore had no notion of "innermost" and applied a single chosen box
to both axes, so it could not follow a nested snap area and a box tied only in
the
other axis could drag an axis off its snap position.
Select a snap target per axis among the boxes aligned at the active offset:
- selectSnapTargetForAxis() returns the focused/targeted representative, else
the
innermost box (one whose snap area does not enclose another aligned area),
else
the first in tree order; recorded per axis in updateCurrentlySnappedBoxes().
- resnapAfterLayout() follows each axis's target independently. Focused and
targeted boxes are re-evaluated fresh at re-snap (they can change after the
snap); otherwise the box recorded before the layout change is used.
- preserveCurrentTargetForAxis() matches the target against all areas
contributing
to an offset, so a box sharing its post-layout offset with another is still
found.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/multiple-aligned-targets/nested-supercedes-common-to-both-axes-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/multiple-aligned-targets/prefer-inner-target-expected.txt:
* Source/WebCore/platform/ScrollSnapAnimatorState.cpp:
(WebCore::ScrollSnapAnimatorState::preserveCurrentTargetForAxis):
(WebCore::ScrollSnapAnimatorState::selectSnapTargetForAxis const):
(WebCore::ScrollSnapAnimatorState::updateCurrentlySnappedBoxes):
(WebCore::focusedOrTargetedBox):
(WebCore::ScrollSnapAnimatorState::resnapAfterLayout):
(WebCore::preferredSnapTarget): Deleted.
(WebCore::chooseBoxToResnapTo): Deleted.
* Source/WebCore/platform/ScrollSnapAnimatorState.h:
Canonical link: https://commits.webkit.org/317225@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications