Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 05c68b558872e9b3736f0c3dbf8d33af4d558288
      
https://github.com/WebKit/WebKit/commit/05c68b558872e9b3736f0c3dbf8d33af4d558288
  Author: Simon Fraser <[email protected]>
  Date:   2026-02-23 (Mon, 23 Feb 2026)

  Changed paths:
    R 
LayoutTests/platform/ios/imported/w3c/web-platform-tests/scroll-animations/scroll-timelines/scroll-timeline-snapshotting-expected.txt
    M Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
    M Source/WebCore/page/scrolling/ScrollAnchoringController.cpp
    M Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.cpp
    M Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h
    M Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp
    M Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h
    M Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.cpp
    M Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.h
    M Source/WebCore/page/scrolling/ScrollingStatePluginScrollingNode.cpp
    M Source/WebCore/page/scrolling/ScrollingStatePluginScrollingNode.h
    M Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
    M Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h
    M Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
    M Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
    M Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
    M Source/WebCore/platform/ScrollTypes.cpp
    M Source/WebCore/platform/ScrollTypes.h
    M 
Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.serialization.in
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
    M 
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
    M Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h
    M Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm
    M Source/WebKit/UIProcess/WebPageProxy.h

  Log Message:
  -----------
  [Async scrolling] Clean up RequestedScrollData
https://bugs.webkit.org/show_bug.cgi?id=308436
rdar://170930785

Reviewed by BJ Burg and Tim Horton.

`RequestedScrollData` encodes data required to handle programmatic scrolls 
(e.g. `scrollTo()`,
scrollBy()`, scroll anchoring adjustments etc). When multiple of these occur in 
sequence,
we have to determine how they reduce to the minimal set of instructions to the 
UI process
for async scrolling. For example:
    window.scrollTo(0, 100);
    window.scrollBy(0, 20);

reduces to
    window.scrollTo(0, 120);

and
    window.scrollTo({ top: 100, behavior: 'smooth'});
    window.scrollTo(0, 20);

becomes
    window.scrollTo(0, 20);

because instantaneous scrolls abort any smooth scroll. However, some 
combinations do result in
a two-step operation:
    window.scrollTo(0, 100);
    window.scrollBy({ top: 20, behavior: 'smooth'});

`RequestedScrollData` used `requestedDataBeforeAnimatedScroll` to represent 
step 1 here, but that
was unwieldy, and didn't preserve the `ScrollRequestIdentifier` on the first 
step. So instead use a
`Vector<RequestedScrollData, 2>` to represent the minimal set of operations for 
all the coalesced
requests in a given update. And it does always reduce to a maximum of two 
operations.

Most of the changes here are a mechanical switch from `RequestedScrollData` to 
`ScrollRequestData`.

The merging code is tricky, and used to live in `RequestedScrollData::merge()`. 
I moved it to
`ScrollingStateScrollingNode::mergeOrAppendScrollRequest()`, and made it a bit 
more long-winded, but
hopefully easier to follow. A couple of issues need care here; accumulating 
positions and deltas,
and ensuring that we keep track of the most recent `ScrollRequestIdentifier`.

To simplify this merging logic, it was easier to represent animated scrolls via 
new `ScrollRequestType`
values rather than using `ScrollIsAnimated` in `RequestedScrollData`. A new 
type, `ImplicitDeltaUpdate`,
was added to represent scrolls that don't interrupted running animated scrolls, 
for use by scroll
anchoring. Per spec[1], all the other types interrupt animations.

There are two places in the UI process that now have to handle the set of 1 or 
2 requests:
`ScrollingTreeScrollingNode::handleScrollPositionRequests()` and
`RemoteScrollingCoordinatorProxy::adjustMainFrameDelegatedScrollPosition()` 
(the latter handles only
main frame scrolls on iOS). These can now just process the requests in turn (I 
believe this makes an
iOS test pass now).

[1] https://drafts.csswg.org/cssom-view/#scrolling

* 
LayoutTests/platform/ios/imported/w3c/web-platform-tests/scroll-animations/scroll-timelines/scroll-timeline-snapshotting-expected.txt:
 This test
now passes on iOS.
* Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::requestScrollToPosition):
* Source/WebCore/page/scrolling/ScrollAnchoringController.cpp:
(WebCore::ScrollAnchoringController::adjustScrollPositionForAnchoring):
* Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.cpp:
(WebCore::RequestedScrollData::computeDestinationPosition):
(WebCore::operator<<):
(WebCore::RequestedScrollData::merge): Deleted.
* Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h:
(WebCore::isAnimatedUpdate):
(WebCore::RequestedScrollData::comparePositionOrDelta const):
(WebCore::RequestedScrollData::operator== const):
* Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp:
(WebCore::ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode):
* Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h:
* Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.cpp:
(WebCore::ScrollingStateOverflowScrollingNode::ScrollingStateOverflowScrollingNode):
* Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.h:
* Source/WebCore/page/scrolling/ScrollingStatePluginScrollingNode.cpp:
(WebCore::ScrollingStatePluginScrollingNode::ScrollingStatePluginScrollingNode):
* Source/WebCore/page/scrolling/ScrollingStatePluginScrollingNode.h:
* Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp:
(WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
(WebCore::ScrollingStateScrollingNode::mergeOrAppendScrollRequest):
(WebCore::ScrollingStateScrollingNode::setRequestedScrollData):
(WebCore::ScrollingStateScrollingNode::hasScrollPositionRequest const):
(WebCore::ScrollingStateScrollingNode::dumpProperties const):
* Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h:
(WebCore::ScrollingStateScrollingNode::requestedScrollData const):
* Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::commitStateAfterChildren):
(WebCore::ScrollingTreeScrollingNode::handleScrollPositionRequests):
(WebCore::ScrollingTreeScrollingNode::handleScrollPositionRequest):
* Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h:
* Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::scrollingTreeNodeRequestsScroll):
* Source/WebCore/platform/ScrollTypes.cpp:
(WebCore::operator<<):
* Source/WebCore/platform/ScrollTypes.h:
* 
Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.serialization.in:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTreeTransaction):
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::commitScrollingTreeState):
(WebKit::RemoteScrollingCoordinatorProxy::adjustMainFrameDelegatedScrollPosition):
(WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeRequestsScroll):
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm:
(WebKit::RemoteScrollingTreeMac::startPendingScrollAnimations):
(WebKit::RemoteScrollingTreeMac::scrollingTreeNodeRequestsScroll):
* Source/WebKit/UIProcess/WebPageProxy.h: viewScrollPosition() is not what it 
says on the tin.

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



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

Reply via email to