Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d8f6ca541f56a048e8d292e862d5cc3249957ccd
      
https://github.com/WebKit/WebKit/commit/d8f6ca541f56a048e8d292e862d5cc3249957ccd
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-06-19 (Fri, 19 Jun 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/input/paged-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-stop-002-expected.txt
    M LayoutTests/platform/mac/TestExpectations
    M Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp

  Log Message:
  -----------
  Scroll snapping selects a snap point that overshoots the destination instead 
of the closest one in the scroll direction
https://bugs.webkit.org/show_bug.cgi?id=317064
rdar://179549119

Reviewed by Simon Fraser.

When two snap offsets bracket a scroll destination, 
closestSnapOffsetWithInfoAndAxis()
picked the one in the scroll direction unconditionally instead of the closest 
one, so a
snap point between the origin and the destination could be skipped in favor of 
one that
overshoots it (e.g. offsets 0/95/120, scrolling from 0 to 100, snapped to 120 
instead of 95).

The fix is twofold. First, make the directional trap-escape filter decide which 
side to
discard from the actual scroll direction (velocity) rather than from the 
predicted
destination: the predicted destination can collapse onto the original offset 
(e.g. when
momentum scrolling prediction is disabled), in which case the strict 
origin-vs-destination
comparison failed to drop the candidate sitting at the origin. Only fall back 
to the
destination for non-directional scrolls where velocity is 0. With that filter 
now reliably
discarding any candidate at or behind the origin, both remaining candidates are 
valid
forward targets, so pick whichever is closest to the destination, using scroll 
direction
only to break an exact tie.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/input/paged-expected.txt:
 Progressions
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-snap-stop-002-expected.txt:
 Ditto
* LayoutTests/platform/mac/TestExpectations: Unskip now passing test
* Source/WebCore/page/scrolling/ScrollSnapOffsetsInfo.cpp:
(WebCore::closestSnapOffsetWithInfoAndAxis):

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



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

Reply via email to