Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ea4fe561d0dd64bdbd48e4f33f5401b1fb171aaa
https://github.com/WebKit/WebKit/commit/ea4fe561d0dd64bdbd48e4f33f5401b1fb171aaa
Author: Ahmad Saleem <[email protected]>
Date: 2026-06-18 (Thu, 18 Jun 2026)
Changed paths:
M LayoutTests/TestExpectations
A
LayoutTests/fast/scrolling/mac/scrollend-event-retarget-smooth-scroll-main-frame-expected.txt
A
LayoutTests/fast/scrolling/mac/scrollend-event-retarget-smooth-scroll-main-frame.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/resnap-on-oveflow-hidden-container-expected.txt
M Source/WebCore/platform/ScrollAnimator.cpp
M Source/WebCore/platform/ScrollAnimator.h
M Source/WebCore/platform/ScrollableArea.cpp
M Source/WebCore/rendering/RenderLayerScrollableArea.cpp
Log Message:
-----------
Interrupting a smooth scroll with a new scrollTo() to a different target
fires scrollend at the wrong position
https://bugs.webkit.org/show_bug.cgi?id=317065
rdar://179551854
Reviewed by Simon Fraser.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
When a programmatic smooth scroll was already running and a new animated
scrollTo() arrived for a different target, the in-flight animation was cancelled
before the new one started. Cancelling tears the animation down, which
prematurely fires a scrollend event at the current intermediate offset instead
of running on to the new destination.
This affected both scroller types:
- Overflow scrollers, via RenderLayerScrollableArea::scrollToOffset().
- The main frame, via ScrollableArea::scrollToPositionWithAnimation() (reached
through LocalFrameView::setScrollOffsetWithOptions()), which does not go
through the RenderLayerScrollableArea override.
Retarget the running animation to the new destination instead of cancelling it,
falling back to cancellation only for non-animated requests or when no active
main-thread animation exists. retargetRunningAnimation() now returns whether
retargeting succeeded so the caller can choose the fallback.
* LayoutTests/TestExpectations: Unskip Expectation
*
LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-snap/snap-after-relayout/resnap-on-oveflow-hidden-container-expected.txt:
Progression
*
LayoutTests/fast/scrolling/mac/scrollend-event-retarget-smooth-scroll-main-frame-expected.txt:
Added.
*
LayoutTests/fast/scrolling/mac/scrollend-event-retarget-smooth-scroll-main-frame.html:
Added.
* Source/WebCore/platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::retargetRunningAnimation):
* Source/WebCore/platform/ScrollAnimator.h:
* Source/WebCore/platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::scrollToPositionWithAnimation):
* Source/WebCore/rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::scrollToOffset):
Canonical link: https://commits.webkit.org/315471@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications