Title: [283793] trunk/Source
Revision
283793
Author
[email protected]
Date
2021-10-07 23:45:35 -0700 (Thu, 07 Oct 2021)

Log Message

Plumb "animated scroll did end" back from the scrolling tree
https://bugs.webkit.org/show_bug.cgi?id=231412

Reviewed by Tim Horton.

Before we can enable async animated scrolls, we have to get the "did end" notification back
from the scrolling thread/UI process in order to clear the ScrollAnimationStatus on
ScrollableArea.

The scroll animations are run by the ScrollingEffectsController owned by
ScrollingTreeScrollingNodeDelegateMac/ScrollingTreeScrollingNodeDelegateNicosia. Their
didStopAnimatedScroll() implementations call through the ScrollingTreeScrollingNde to the
ScrollingTree, which enqueues ScrollUpdate just as we do for scroll position changes.

ScrollUpdate is enhanced to contain an 'updateType' with a AnimatedScrollDidEnd value. When
this is received by AsyncScrollingCoordinator it clears the ScrollAnimationStatus on the
relevant FrameView/RenderLayerScrollableArea.

With UI-side compositing, AnimatedScrollDidEndForNode is an IPC message back to
RemoteScrollingCoordinator.

Not yet tested because async animated scrolls are not enabled.

Source/WebCore:

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
(WebCore::AsyncScrollingCoordinator::applyScrollPositionUpdate):
(WebCore::AsyncScrollingCoordinator::animatedScrollDidEndForNode):
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ScrollingCoordinatorTypes.h:
(WebCore::ScrollUpdate::canMerge const):
* page/scrolling/ScrollingTree.h:
(WebCore::ScrollingTree::scrollingTreeNodeDidStopAnimatedScroll):
* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::didStopAnimatedScroll):
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
(WebCore::ThreadedScrollingTree::scrollingTreeNodeDidStopAnimatedScroll):
* page/scrolling/ThreadedScrollingTree.h:
* page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h:
* page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
(WebCore::ScrollingTreeScrollingNodeDelegateMac::didStopAnimatedScroll):
* page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp:
(WebCore::ScrollingTreeScrollingNodeDelegateNicosia::didStopAnimatedScroll):
* page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h:

Source/WebKit:

* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidStopAnimatedScroll):
* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
* UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
(WebKit::RemoteScrollingTree::scrollingTreeNodeDidStopAnimatedScroll):
* UIProcess/RemoteLayerTree/RemoteScrollingTree.h:
* WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h:
* WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in:
* WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm:
(WebKit::RemoteScrollingCoordinator::scrollPositionChangedForNode):
(WebKit::RemoteScrollingCoordinator::animatedScrollDidEndForNode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283792 => 283793)


--- trunk/Source/WebCore/ChangeLog	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/ChangeLog	2021-10-08 06:45:35 UTC (rev 283793)
@@ -1,5 +1,52 @@
 2021-10-07  Simon Fraser  <[email protected]>
 
+        Plumb "animated scroll did end" back from the scrolling tree
+        https://bugs.webkit.org/show_bug.cgi?id=231412
+
+        Reviewed by Tim Horton.
+
+        Before we can enable async animated scrolls, we have to get the "did end" notification back
+        from the scrolling thread/UI process in order to clear the ScrollAnimationStatus on
+        ScrollableArea.
+
+        The scroll animations are run by the ScrollingEffectsController owned by
+        ScrollingTreeScrollingNodeDelegateMac/ScrollingTreeScrollingNodeDelegateNicosia. Their
+        didStopAnimatedScroll() implementations call through the ScrollingTreeScrollingNde to the
+        ScrollingTree, which enqueues ScrollUpdate just as we do for scroll position changes.
+
+        ScrollUpdate is enhanced to contain an 'updateType' with a AnimatedScrollDidEnd value. When
+        this is received by AsyncScrollingCoordinator it clears the ScrollAnimationStatus on the
+        relevant FrameView/RenderLayerScrollableArea.
+
+        With UI-side compositing, AnimatedScrollDidEndForNode is an IPC message back to
+        RemoteScrollingCoordinator.
+
+        Not yet tested because async animated scrolls are not enabled.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
+        (WebCore::AsyncScrollingCoordinator::applyScrollPositionUpdate):
+        (WebCore::AsyncScrollingCoordinator::animatedScrollDidEndForNode):
+        * page/scrolling/AsyncScrollingCoordinator.h:
+        * page/scrolling/ScrollingCoordinatorTypes.h:
+        (WebCore::ScrollUpdate::canMerge const):
+        * page/scrolling/ScrollingTree.h:
+        (WebCore::ScrollingTree::scrollingTreeNodeDidStopAnimatedScroll):
+        * page/scrolling/ScrollingTreeScrollingNode.cpp:
+        (WebCore::ScrollingTreeScrollingNode::didStopAnimatedScroll):
+        * page/scrolling/ThreadedScrollingTree.cpp:
+        (WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
+        (WebCore::ThreadedScrollingTree::scrollingTreeNodeDidStopAnimatedScroll):
+        * page/scrolling/ThreadedScrollingTree.h:
+        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h:
+        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
+        (WebCore::ScrollingTreeScrollingNodeDelegateMac::didStopAnimatedScroll):
+        * page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp:
+        (WebCore::ScrollingTreeScrollingNodeDelegateNicosia::didStopAnimatedScroll):
+        * page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h:
+
+2021-10-07  Simon Fraser  <[email protected]>
+
         Add some plumbing for running smooth scroll animations in the scrolling thread/UI process
         https://bugs.webkit.org/show_bug.cgi?id=231402
 

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2021-10-08 06:45:35 UTC (rev 283793)
@@ -260,7 +260,7 @@
     bool isSnapshotting = m_page->isTakingSnapshotsForApplicationSuspension();
     bool inProgrammaticScroll = scrollableArea.currentScrollType() == ScrollType::Programmatic;
     if (inProgrammaticScroll || inBackForwardCache) {
-        auto scrollUpdate = ScrollUpdate { scrollingNodeID, scrollPosition, { }, ScrollingLayerPositionAction::Set };
+        auto scrollUpdate = ScrollUpdate { scrollingNodeID, scrollPosition, { }, ScrollUpdateType::PositionUpdate, ScrollingLayerPositionAction::Set };
         applyScrollUpdate(WTFMove(scrollUpdate), ScrollType::Programmatic);
     }
 
@@ -367,9 +367,36 @@
 
 void AsyncScrollingCoordinator::applyScrollPositionUpdate(ScrollUpdate&& update, ScrollType scrollType)
 {
+    if (update.updateType == ScrollUpdateType::AnimatedScrollDidEnd) {
+        animatedScrollDidEndForNode(update.nodeID);
+        return;
+    }
+
     updateScrollPositionAfterAsyncScroll(update.nodeID, update.scrollPosition, update.layoutViewportOrigin, update.updateLayerPositionAction, scrollType);
 }
 
+void AsyncScrollingCoordinator::animatedScrollDidEndForNode(ScrollingNodeID scrollingNodeID)
+{
+    ASSERT(isMainThread());
+
+    if (!m_page)
+        return;
+
+    auto* frameView = frameViewForScrollingNode(scrollingNodeID);
+    if (!frameView)
+        return;
+
+    LOG_WITH_STREAM(Scrolling, stream << "AsyncScrollingCoordinator::animatedScrollDidEndForNode node " << scrollingNodeID);
+
+    if (scrollingNodeID == frameView->scrollingNodeID()) {
+        frameView->setScrollAnimationStatus(ScrollAnimationStatus::NotAnimating);
+        return;
+    }
+
+    if (auto* scrollableArea = frameView->scrollableAreaForScrollingNodeID(scrollingNodeID))
+        scrollableArea->setScrollAnimationStatus(ScrollAnimationStatus::NotAnimating);
+}
+
 void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const FloatPoint& scrollPosition, std::optional<FloatPoint> layoutViewportOrigin, ScrollingLayerPositionAction scrollingLayerPositionAction, ScrollType scrollType)
 {
     ASSERT(isMainThread());

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h	2021-10-08 06:45:35 UTC (rev 283793)
@@ -54,7 +54,7 @@
 
     void applyPendingScrollUpdates();
 
-    WEBCORE_EXPORT void applyScrollUpdate(ScrollUpdate&&, ScrollType);
+    WEBCORE_EXPORT void applyScrollUpdate(ScrollUpdate&&, ScrollType = ScrollType::User);
 
 #if PLATFORM(COCOA)
     WEBCORE_EXPORT void handleWheelEventPhase(ScrollingNodeID, PlatformWheelEventPhase) final;
@@ -155,7 +155,8 @@
     
     void applyScrollPositionUpdate(ScrollUpdate&&, ScrollType);
     void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, std::optional<FloatPoint> layoutViewportOrigin, ScrollingLayerPositionAction, ScrollType);
-    
+    void animatedScrollDidEndForNode(ScrollingNodeID);
+
     FrameView* frameViewForScrollingNode(ScrollingNodeID) const;
 
     std::unique_ptr<ScrollingStateTree> m_scrollingStateTree;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h	2021-10-08 06:45:35 UTC (rev 283793)
@@ -116,15 +116,21 @@
     }
 };
 
+enum ScrollUpdateType : uint8_t {
+    PositionUpdate,
+    AnimatedScrollDidEnd
+};
+
 struct ScrollUpdate {
     ScrollingNodeID nodeID { 0 };
     FloatPoint scrollPosition;
     std::optional<FloatPoint> layoutViewportOrigin;
+    ScrollUpdateType updateType { ScrollUpdateType::PositionUpdate };
     ScrollingLayerPositionAction updateLayerPositionAction { ScrollingLayerPositionAction::Sync };
     
     bool canMerge(const ScrollUpdate& other) const
     {
-        return nodeID == other.nodeID && updateLayerPositionAction == other.updateLayerPositionAction;
+        return nodeID == other.nodeID && updateLayerPositionAction == other.updateLayerPositionAction && updateType == other.updateType;
     }
     
     void merge(ScrollUpdate&& other)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2021-10-08 06:45:35 UTC (rev 283793)
@@ -129,6 +129,7 @@
     // Called after a scrolling tree node has handled a scroll and updated its layers.
     // Updates FrameView/RenderLayer scrolling state and GraphicsLayers.
     virtual void scrollingTreeNodeDidScroll(ScrollingTreeScrollingNode&, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync) = 0;
+    virtual void scrollingTreeNodeDidStopAnimatedScroll(ScrollingTreeScrollingNode&) { }
 
     // Called for requested scroll position updates.
     virtual void scrollingTreeNodeRequestsScroll(ScrollingNodeID, const FloatPoint& /*scrollPosition*/, ScrollType, ScrollClamping) { }

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2021-10-08 06:45:35 UTC (rev 283793)
@@ -230,7 +230,7 @@
 void ScrollingTreeScrollingNode::didStopAnimatedScroll()
 {
     LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeScrollingNode " << scrollingNodeID() << " didStopAnimatedScroll");
-    // FIXME: Propagate state back to the main thread.
+    scrollingTree().scrollingTreeNodeDidStopAnimatedScroll(*this);
 }
 
 void ScrollingTreeScrollingNode::handleScrollPositionRequest(const RequestedScrollData& requestedScrollData)

Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp	2021-10-08 06:45:35 UTC (rev 283793)
@@ -207,10 +207,10 @@
     if (is<ScrollingTreeFrameScrollingNode>(node))
         layoutViewportOrigin = downcast<ScrollingTreeFrameScrollingNode>(node).layoutViewport().location();
 
-    auto scrollUpdate = ScrollUpdate { node.scrollingNodeID(), scrollPosition, layoutViewportOrigin, scrollingLayerPositionAction };
+    auto scrollUpdate = ScrollUpdate { node.scrollingNodeID(), scrollPosition, layoutViewportOrigin, ScrollUpdateType::PositionUpdate, scrollingLayerPositionAction };
 
     if (RunLoop::isMain()) {
-        m_scrollingCoordinator->applyScrollUpdate(WTFMove(scrollUpdate), ScrollType::User);
+        m_scrollingCoordinator->applyScrollUpdate(WTFMove(scrollUpdate));
         return;
     }
 
@@ -225,6 +225,28 @@
     });
 }
 
+void ThreadedScrollingTree::scrollingTreeNodeDidStopAnimatedScroll(ScrollingTreeScrollingNode& node)
+{
+    if (!m_scrollingCoordinator)
+        return;
+
+    LOG_WITH_STREAM(Scrolling, stream << "ThreadedScrollingTree::scrollingTreeNodeDidStopAnimatedScroll " << node.scrollingNodeID());
+
+    auto scrollUpdate = ScrollUpdate { node.scrollingNodeID(), { }, { }, ScrollUpdateType::AnimatedScrollDidEnd };
+
+    if (RunLoop::isMain()) {
+        m_scrollingCoordinator->applyScrollUpdate(WTFMove(scrollUpdate));
+        return;
+    }
+
+    addPendingScrollUpdate(WTFMove(scrollUpdate));
+
+    RunLoop::main().dispatch([strongThis = Ref { *this }] {
+        if (auto* scrollingCoordinator = strongThis->m_scrollingCoordinator.get())
+            scrollingCoordinator->scrollingThreadAddedPendingUpdate();
+    });
+}
+
 void ThreadedScrollingTree::reportSynchronousScrollingReasonsChanged(MonotonicTime timestamp, OptionSet<SynchronousScrollingReason> reasons)
 {
     RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, timestamp, reasons] {

Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h	2021-10-08 06:45:35 UTC (rev 283793)
@@ -68,6 +68,8 @@
     explicit ThreadedScrollingTree(AsyncScrollingCoordinator&);
 
     void scrollingTreeNodeDidScroll(ScrollingTreeScrollingNode&, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync) override;
+    void scrollingTreeNodeDidStopAnimatedScroll(ScrollingTreeScrollingNode&) override;
+
 #if PLATFORM(MAC)
     void handleWheelEventPhase(ScrollingNodeID, PlatformWheelEventPhase) override;
     void setActiveScrollSnapIndices(ScrollingNodeID, std::optional<unsigned> horizontalIndex, std::optional<unsigned> verticalIndex) override;

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h	2021-10-08 06:45:35 UTC (rev 283793)
@@ -96,8 +96,12 @@
 
     FloatPoint scrollOffset() const final;
     float pageScaleFactor() const final;
+
+    void didStopAnimatedScroll() final;
+
     void willStartScrollSnapAnimation() final;
     void didStopScrollSnapAnimation() final;
+
     ScrollExtents scrollExtents() const final;
 
     void releaseReferencesToScrollerImpsOnTheMainThread();

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm	2021-10-08 06:45:35 UTC (rev 283793)
@@ -371,6 +371,11 @@
     return 1;
 }
 
+void ScrollingTreeScrollingNodeDelegateMac::didStopAnimatedScroll()
+{
+    scrollingNode().didStopAnimatedScroll();
+}
+
 void ScrollingTreeScrollingNodeDelegateMac::willStartScrollSnapAnimation()
 {
     scrollingNode().setScrollSnapInProgress(true);

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp	2021-10-08 06:45:35 UTC (rev 283793)
@@ -161,6 +161,11 @@
     scrollingNode().setScrollSnapInProgress(false);
 }
 
+void ScrollingTreeScrollingNodeDelegateNicosia::didStopAnimatedScroll()
+{
+    scrollingNode().didStopAnimatedScroll();
+}
+
 float ScrollingTreeScrollingNodeDelegateNicosia::pageScaleFactor() const
 {
     // FIXME: What should this return for non-root frames, and overflow?

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h (283792 => 283793)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h	2021-10-08 06:45:35 UTC (rev 283793)
@@ -69,8 +69,12 @@
     void adjustScrollPositionToBoundsIfNecessary() final;
 
     FloatPoint scrollOffset() const final;
+
     void willStartScrollSnapAnimation() final;
     void didStopScrollSnapAnimation() final;
+
+    void didStopAnimatedScroll() final;
+
     float pageScaleFactor() const final;
     ScrollExtents scrollExtents() const final;
 

Modified: trunk/Source/WebKit/ChangeLog (283792 => 283793)


--- trunk/Source/WebKit/ChangeLog	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebKit/ChangeLog	2021-10-08 06:45:35 UTC (rev 283793)
@@ -1,5 +1,42 @@
 2021-10-07  Simon Fraser  <[email protected]>
 
+        Plumb "animated scroll did end" back from the scrolling tree
+        https://bugs.webkit.org/show_bug.cgi?id=231412
+
+        Reviewed by Tim Horton.
+
+        Before we can enable async animated scrolls, we have to get the "did end" notification back
+        from the scrolling thread/UI process in order to clear the ScrollAnimationStatus on
+        ScrollableArea.
+
+        The scroll animations are run by the ScrollingEffectsController owned by
+        ScrollingTreeScrollingNodeDelegateMac/ScrollingTreeScrollingNodeDelegateNicosia. Their
+        didStopAnimatedScroll() implementations call through the ScrollingTreeScrollingNde to the
+        ScrollingTree, which enqueues ScrollUpdate just as we do for scroll position changes.
+
+        ScrollUpdate is enhanced to contain an 'updateType' with a AnimatedScrollDidEnd value. When
+        this is received by AsyncScrollingCoordinator it clears the ScrollAnimationStatus on the
+        relevant FrameView/RenderLayerScrollableArea.
+
+        With UI-side compositing, AnimatedScrollDidEndForNode is an IPC message back to
+        RemoteScrollingCoordinator.
+
+        Not yet tested because async animated scrolls are not enabled.
+
+        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
+        (WebKit::RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidStopAnimatedScroll):
+        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
+        * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
+        (WebKit::RemoteScrollingTree::scrollingTreeNodeDidStopAnimatedScroll):
+        * UIProcess/RemoteLayerTree/RemoteScrollingTree.h:
+        * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h:
+        * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in:
+        * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm:
+        (WebKit::RemoteScrollingCoordinator::scrollPositionChangedForNode):
+        (WebKit::RemoteScrollingCoordinator::animatedScrollDidEndForNode):
+
+2021-10-07  Simon Fraser  <[email protected]>
+
         Add some plumbing for running smooth scroll animations in the scrolling thread/UI process
         https://bugs.webkit.org/show_bug.cgi?id=231402
 

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp (283792 => 283793)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp	2021-10-08 06:45:35 UTC (rev 283793)
@@ -236,6 +236,11 @@
     m_webPageProxy.send(Messages::RemoteScrollingCoordinator::ScrollPositionChangedForNode(scrolledNodeID, newScrollPosition, scrollingLayerPositionAction == ScrollingLayerPositionAction::Sync));
 }
 
+void RemoteScrollingCoordinatorProxy::scrollingTreeNodeDidStopAnimatedScroll(ScrollingNodeID scrolledNodeID)
+{
+    m_webPageProxy.send(Messages::RemoteScrollingCoordinator::AnimatedScrollDidEndForNode(scrolledNodeID));
+}
+
 void RemoteScrollingCoordinatorProxy::scrollingTreeNodeRequestsScroll(ScrollingNodeID scrolledNodeID, const FloatPoint& scrollPosition, ScrollType scrollType, ScrollClamping)
 {
     if (scrolledNodeID == rootScrollingNodeID() && m_requestedScrollInfo) {

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h (283792 => 283793)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h	2021-10-08 06:45:35 UTC (rev 283793)
@@ -60,6 +60,7 @@
     // Inform the web process that the scroll position changed (called from the scrolling tree)
     void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& newScrollPosition, const std::optional<WebCore::FloatPoint>& layoutViewportOrigin, WebCore::ScrollingLayerPositionAction);
     void scrollingTreeNodeRequestsScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, WebCore::ScrollType, WebCore::ScrollClamping);
+    void scrollingTreeNodeDidStopAnimatedScroll(WebCore::ScrollingNodeID);
 
     WebCore::TrackingType eventTrackingTypeForPoint(const AtomString& eventName, WebCore::IntPoint) const;
 

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp (283792 => 283793)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp	2021-10-08 06:45:35 UTC (rev 283793)
@@ -94,6 +94,11 @@
     m_scrollingCoordinatorProxy.scrollingTreeNodeDidScroll(node.scrollingNodeID(), node.currentScrollPosition(), layoutViewportOrigin, scrollingLayerPositionAction);
 }
 
+void RemoteScrollingTree::scrollingTreeNodeDidStopAnimatedScroll(ScrollingTreeScrollingNode& node)
+{
+    m_scrollingCoordinatorProxy.scrollingTreeNodeDidStopAnimatedScroll(node.scrollingNodeID());
+}
+
 void RemoteScrollingTree::scrollingTreeNodeRequestsScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, ScrollType scrollType, ScrollClamping clamping)
 {
     m_scrollingCoordinatorProxy.scrollingTreeNodeRequestsScroll(nodeID, scrollPosition, scrollType, clamping);

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h (283792 => 283793)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.h	2021-10-08 06:45:35 UTC (rev 283793)
@@ -44,31 +44,32 @@
     static Ref<RemoteScrollingTree> create(RemoteScrollingCoordinatorProxy&);
     virtual ~RemoteScrollingTree();
 
-    bool isRemoteScrollingTree() const override { return true; }
+    bool isRemoteScrollingTree() const final { return true; }
 
     void handleMouseEvent(const WebCore::PlatformMouseEvent&);
 
     const RemoteScrollingCoordinatorProxy& scrollingCoordinatorProxy() const { return m_scrollingCoordinatorProxy; }
 
-    void scrollingTreeNodeDidScroll(WebCore::ScrollingTreeScrollingNode&, WebCore::ScrollingLayerPositionAction = WebCore::ScrollingLayerPositionAction::Sync) override;
-    void scrollingTreeNodeRequestsScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, WebCore::ScrollType, WebCore::ScrollClamping) override;
+    void scrollingTreeNodeDidScroll(WebCore::ScrollingTreeScrollingNode&, WebCore::ScrollingLayerPositionAction = WebCore::ScrollingLayerPositionAction::Sync) final;
+    void scrollingTreeNodeDidStopAnimatedScroll(WebCore::ScrollingTreeScrollingNode&) final;
+    void scrollingTreeNodeRequestsScroll(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, WebCore::ScrollType, WebCore::ScrollClamping) final;
 
-    void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, std::optional<unsigned> horizontal, std::optional<unsigned> vertical) override;
+    void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, std::optional<unsigned> horizontal, std::optional<unsigned> vertical) final;
 
 private:
     explicit RemoteScrollingTree(RemoteScrollingCoordinatorProxy&);
 
 #if PLATFORM(MAC)
-    void handleWheelEventPhase(WebCore::ScrollingNodeID, WebCore::PlatformWheelEventPhase) override;
+    void handleWheelEventPhase(WebCore::ScrollingNodeID, WebCore::PlatformWheelEventPhase) final;
 #endif
 
 #if PLATFORM(IOS_FAMILY)
-    void scrollingTreeNodeWillStartPanGesture(WebCore::ScrollingNodeID) override;
-    void scrollingTreeNodeWillStartScroll(WebCore::ScrollingNodeID) override;
-    void scrollingTreeNodeDidEndScroll(WebCore::ScrollingNodeID) override;
+    void scrollingTreeNodeWillStartPanGesture(WebCore::ScrollingNodeID) final;
+    void scrollingTreeNodeWillStartScroll(WebCore::ScrollingNodeID) final;
+    void scrollingTreeNodeDidEndScroll(WebCore::ScrollingNodeID) final;
 #endif
 
-    Ref<WebCore::ScrollingTreeNode> createScrollingTreeNode(WebCore::ScrollingNodeType, WebCore::ScrollingNodeID) override;
+    Ref<WebCore::ScrollingTreeNode> createScrollingTreeNode(WebCore::ScrollingNodeType, WebCore::ScrollingNodeID) final;
     
     RemoteScrollingCoordinatorProxy& m_scrollingCoordinatorProxy;
 };

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h (283792 => 283793)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h	2021-10-08 06:45:35 UTC (rev 283793)
@@ -79,6 +79,7 @@
     
     // Respond to UI process changes.
     void scrollPositionChangedForNode(WebCore::ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool syncLayerPosition);
+    void animatedScrollDidEndForNode(WebCore::ScrollingNodeID);
     void currentSnapPointIndicesChangedForNode(WebCore::ScrollingNodeID, std::optional<unsigned> horizontal, std::optional<unsigned> vertical);
 
     WebPage* m_webPage;

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in (283792 => 283793)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in	2021-10-08 06:45:35 UTC (rev 283793)
@@ -24,6 +24,7 @@
 
 messages -> RemoteScrollingCoordinator {
     ScrollPositionChangedForNode(uint64_t nodeID, WebCore::FloatPoint scrollPosition, bool syncLayerPosition);
+    AnimatedScrollDidEndForNode(uint64_t nodeID);
     CurrentSnapPointIndicesChangedForNode(uint64_t nodeID, std::optional<unsigned> horizontal, std::optional<unsigned> vertical);
     ScrollingStateInUIProcessChanged(WebKit::RemoteScrollingUIState uiState);
 }

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm (283792 => 283793)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm	2021-10-08 04:30:33 UTC (rev 283792)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm	2021-10-08 06:45:35 UTC (rev 283793)
@@ -107,10 +107,16 @@
 // Notification from the UI process that we scrolled.
 void RemoteScrollingCoordinator::scrollPositionChangedForNode(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, bool syncLayerPosition)
 {
-    auto scrollUpdate = ScrollUpdate { nodeID, scrollPosition, { }, syncLayerPosition ? ScrollingLayerPositionAction::Sync : ScrollingLayerPositionAction::Set };
-    applyScrollUpdate(WTFMove(scrollUpdate), ScrollType::User);
+    auto scrollUpdate = ScrollUpdate { nodeID, scrollPosition, { }, ScrollUpdateType::PositionUpdate, syncLayerPosition ? ScrollingLayerPositionAction::Sync : ScrollingLayerPositionAction::Set };
+    applyScrollUpdate(WTFMove(scrollUpdate));
 }
 
+void RemoteScrollingCoordinator::animatedScrollDidEndForNode(ScrollingNodeID nodeID)
+{
+    auto scrollUpdate = ScrollUpdate { nodeID, { }, { }, ScrollUpdateType::AnimatedScrollDidEnd };
+    applyScrollUpdate(WTFMove(scrollUpdate));
+}
+
 void RemoteScrollingCoordinator::currentSnapPointIndicesChangedForNode(ScrollingNodeID nodeID, std::optional<unsigned> horizontal, std::optional<unsigned> vertical)
 {
     setActiveScrollSnapIndices(nodeID, horizontal, vertical);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to