Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b6306634c70b5891fdec1b19f14f0b297453204d
      
https://github.com/WebKit/WebKit/commit/b6306634c70b5891fdec1b19f14f0b297453204d
  Author: Wenson Hsieh <wenson_hs...@apple.com>
  Date:   2023-03-23 (Thu, 23 Mar 2023)

  Changed paths:
    M Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.cpp
    M Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h
    M Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
    M Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h
    M 
Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm

  Log Message:
  -----------
  [UI-side compositing] Two 
imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior tests fail
https://bugs.webkit.org/show_bug.cgi?id=254335
rdar://106116027

Reviewed by Tim Horton and Simon Fraser.

When UI-side compositing is enabled, the following two WPT fail:

• 
imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-root.html
• 
imported/w3c/web-platform-tests/css/cssom-view/scroll-behavior-main-frame-window.html

Both of these tests wait for an animated scroll to a specific scroll position 
`(x, y)` to finish
before resetting the scroll position to `(0, 0)` and immediately starting 
another animated scroll to
the same `(x, y)` destination. When UI-side compositing is enabled and 
scrolling tree updates are
propagated to the UI process in batches via remote layer tree commits, this 
means that the animated
scroll to `(x, y)` replaces the `m_requestedScrollData` set by the instant 
programmatic scroll to
`(0, 0)`.

However, because the UI process already thinks that the scroll position of the 
scrolling node is at
`(x, y)` due to the previous animated scroll (right before the page tries to 
instantly scroll to
`(0, 0)`), the next layer tree commit that contains the requested animated 
scroll to `(x, y)`
results in a no-op.

To address this, we add a new member to `RequestedScrollData` that carries 
information about the
previously requested scrolling update, which is only populated in the case 
where an animated scroll
immediately follows a non-animated scroll. We then use this data to perform an 
immediate scroll in
the UI process right before starting the animated scroll, such that the 
animated scroll begins from
the correct position.

* Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.cpp:
(WebCore::RequestedScrollData::merge):

Add a helper method to coalesce data from an incoming requested scroll into 
existing requested
scroll data. See changes in `ScrollingStateScrollingNode` for more details.

* Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h:
(WebCore::RequestedScrollData::operator== const):
* Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp:
(WebCore::ScrollingStateScrollingNode::setRequestedScrollData):

In the case where the scrolling tree state already holds a requested scrolling 
update, use the
helper method above to merge the incoming requested scroll data into the 
existing one. Typically,
this simply results in the incoming request replacing the existing one; 
however, in the case where
we have an incoming animated scrolling request that immediately follows a 
non-animated scrolling
request, we'll additionally set `requestedDataBeforeAnimatedScroll`.

* Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h:
* 
Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteScrollingTreeMac.mm:
(WebKit::RemoteScrollingTreeMac::startPendingScrollAnimations):

If `requestedDataBeforeAnimatedScroll` exists, then use 
`ScrollingTreeScrollingNode::scrollTo` to
set the scroll position right before embarking on the animated scroll.

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


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to