Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5c74a3cb95df09bad3c953b1d828bac5e48d6668
https://github.com/WebKit/WebKit/commit/5c74a3cb95df09bad3c953b1d828bac5e48d6668
Author: Simon Fraser <[email protected]>
Date: 2026-05-04 (Mon, 04 May 2026)
Changed paths:
A
LayoutTests/fast/scrolling/ios/scroll-into-view-smooth-after-snap-expected.txt
A LayoutTests/fast/scrolling/ios/scroll-into-view-smooth-after-snap.html
M Source/WebCore/page/LocalFrameView.cpp
M Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
M Source/WebCore/page/scrolling/ScrollingTree.cpp
M Source/WebCore/platform/ScrollAnimator.cpp
M
Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp
M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
M
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
M Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h
M
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.h
M
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm
M
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm
Log Message:
-----------
Smooth scroll in viewport with scroll-snap fails on iOS
https://bugs.webkit.org/show_bug.cgi?id=245722
rdar://100727098
Reviewed by Abrar Rahman Protyasha.
On iOS, after a programmatic scroll, a user scroll could snap the scroll offset
back
to an earlier, stale snap point. This made combinations of scroll snap and
programmatics scrolling very unreliable.
The active snap points are maintained in the UI process independently from the
web
process. It's unclear if this is the correct design, but changing that at
present
would be too risky. The comments in ScrollingStateScrollingNode, and logging
fixes
make this design choice more clear.
The bug was that the active snap point was only updated in `-[WKWebView
scrollViewWillEndDragging:...]` and not after other scrolls, so a snap point was
chosen after dragging, then the programmatic scroll moved the content offset
elsewhere, then the next `-_updateVisibleContentRects` would jump back to the
stale
snap point. The fix is to update the active snap index in
`-_didFinishScrolling:`.
Some other clean up was also done; RemoteScrollingCoordinatorProxyIOS now takes
all
arguments as scrollOffsets (already adjusted for insets), and takes zoomScale
as an
argument.
The functions to map between contentOffset and scrollOffset are factored into
two-argument verions for call sites that need to pass custom insets.
Test: fast/scrolling/ios/scroll-into-view-smooth-after-snap.html
*
LayoutTests/fast/scrolling/ios/scroll-into-view-smooth-after-snap-expected.txt:
Added.
* LayoutTests/fast/scrolling/ios/scroll-into-view-smooth-after-snap.html: Added.
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::setScrollOffsetWithOptions):
* Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp:
(WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
(WebCore::ScrollingStateScrollingNode::setCurrentVerticalSnapPointIndex):
* Source/WebCore/page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling):
* Source/WebCore/platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::scrollOffsetAdjustedForSnapping const):
*
Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
(WebKit::dump):
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _contentOffset:adjustedForObscuredInsets:]):
(-[WKWebView _scrollOffset:adjustedForObscuredInsets:]):
(-[WKWebView _contentOffsetAdjustedForObscuredInset:]):
(-[WKWebView _scrollOffsetAdjustedForObscuredInset:]):
(-[WKWebView _didFinishScrolling:]):
(-[WKWebView scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
(-[WKWebView _createVisibleContentRectUpdate]):
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::resetStateAfterProcessExited):
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
*
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.h:
*
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm:
(WebKit::shouldSnapForMainFrameScrolling):
(WebKit::RemoteScrollingCoordinatorProxyIOS::adjustTargetScrollOffsetForSnapping):
(WebKit::RemoteScrollingCoordinatorProxyIOS::shouldSetScrollViewDecelerationRateFast
const):
(WebKit::RemoteScrollingCoordinatorProxyIOS::closestSnapOffsetForMainFrameScrolling
const):
(WebKit::RemoteScrollingCoordinatorProxyIOS::hasActiveSnapPoint const):
(WebKit::RemoteScrollingCoordinatorProxyIOS::scrollOffsetSnappedToNearestSnapPoint
const):
(WebKit::RemoteScrollingCoordinatorProxyIOS::updateSnapIndicesForMainFrameOffset):
(WebKit::RemoteScrollingCoordinatorProxyIOS::adjustTargetContentOffsetForSnapping):
Deleted.
(WebKit::RemoteScrollingCoordinatorProxyIOS::shouldSnapForMainFrameScrolling
const): Deleted.
(WebKit::RemoteScrollingCoordinatorProxyIOS::nearestActiveContentInsetAdjustedSnapOffset
const): Deleted.
*
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
(-[WKScrollingNodeScrollViewDelegate
scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
Canonical link: https://commits.webkit.org/312558@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications