ScrollingTree should have the final say on where layers go
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Mar 2019 18:03:42 +0000 (18:03 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 10 Mar 2019 18:03:42 +0000 (18:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195507

Reviewed by Antti Koivisto.

Source/WebCore:

Main thread layer flushing can race with scrolling tree layer changes on macOS, causing
flashing as layers jump around sometimes. We go to some lengths to avoid this by trying
not to touch properties on layers that are being interacted with (scrollableArea->setIsUserScroll in
updateScrollPositionAfterAsyncScroll()), but that's fragile.

This patch adds ScrollingTree::applyScrollingTreeLayerPositions(), which enters
ScrollingTree::applyLayerPositions() on the main thread/UI process. This traverses
the tree allowing each node to run their layer positioning logic.

For macOS WK2, this is called from TiledCoreAnimationDrawingArea::flushLayers() after flushCompositingStateIncludingSubframes().
For macOS WK2 with UI-side compositing, RemoteLayerTreeDrawingAreaProxy::commitLayerTree()
calls m_webPageProxy.scrollingCoordinatorProxy()->applyScrollingTreeLayerPositions().
iOS WK2 is unchanged, using viewportChangedViaDelegatedScrolling() which does the same thing, allowing
for the dynamic viewport changes that happen when zooming on iOS.

Testing this requires infrastructure that we don't have yet.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::applyScrollingTreeLayerPositions):
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::applyScrollingTreeLayerPositions):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::handleWheelEvent):
(WebCore::ScrollingTree::commitTreeState):
(WebCore::ScrollingTree::applyLayerPositions):
(WebCore::ScrollingTree::applyLayerPositionsRecursive):
* page/scrolling/ScrollingTree.h:
* page/scrolling/ScrollingTreeFrameHostingNode.cpp:
(WebCore::ScrollingTreeFrameHostingNode::applyLayerPositions):
* page/scrolling/ScrollingTreeFrameHostingNode.h:
* page/scrolling/ScrollingTreeNode.h:
* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::applyLayerPositions):
* page/scrolling/ScrollingTreeScrollingNode.h:
* page/scrolling/cocoa/ScrollingTreeFixedNode.h:
* page/scrolling/cocoa/ScrollingTreeFixedNode.mm:
(WebCore::ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange):
* page/scrolling/cocoa/ScrollingTreeStickyNode.h:
* page/scrolling/cocoa/ScrollingTreeStickyNode.mm:
(WebCore::ScrollingTreeStickyNode::applyLayerPositions):
(WebCore::ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange):
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::applyLayerPositions):

Source/WebKit:

* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::applyScrollingTreeLayerPositions):
* UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::flushLayers):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242687 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.cpp
Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.h
Source/WebCore/page/scrolling/ScrollingTreeNode.cpp
Source/WebCore/page/scrolling/ScrollingTreeNode.h
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h
Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm
Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h
Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm
Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp
Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h
Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp
Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp
Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h
Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm

index 4e402fb..7dce179 100644 (file)
@@ -1,3 +1,56 @@
+2019-03-10  Simon Fraser  <simon.fraser@apple.com>
+
+        ScrollingTree should have the final say on where layers go
+        https://bugs.webkit.org/show_bug.cgi?id=195507
+
+        Reviewed by Antti Koivisto.
+
+        Main thread layer flushing can race with scrolling tree layer changes on macOS, causing
+        flashing as layers jump around sometimes. We go to some lengths to avoid this by trying
+        not to touch properties on layers that are being interacted with (scrollableArea->setIsUserScroll in
+        updateScrollPositionAfterAsyncScroll()), but that's fragile.
+
+        This patch adds ScrollingTree::applyScrollingTreeLayerPositions(), which enters
+        ScrollingTree::applyLayerPositions() on the main thread/UI process. This traverses
+        the tree allowing each node to run their layer positioning logic.
+
+        For macOS WK2, this is called from TiledCoreAnimationDrawingArea::flushLayers() after flushCompositingStateIncludingSubframes().
+        For macOS WK2 with UI-side compositing, RemoteLayerTreeDrawingAreaProxy::commitLayerTree()
+        calls m_webPageProxy.scrollingCoordinatorProxy()->applyScrollingTreeLayerPositions().
+        iOS WK2 is unchanged, using viewportChangedViaDelegatedScrolling() which does the same thing, allowing
+        for the dynamic viewport changes that happen when zooming on iOS.
+
+        Testing this requires infrastructure that we don't have yet.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::applyScrollingTreeLayerPositions):
+        * page/scrolling/AsyncScrollingCoordinator.h:
+        * page/scrolling/ScrollingCoordinator.h:
+        (WebCore::ScrollingCoordinator::applyScrollingTreeLayerPositions):
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::handleWheelEvent):
+        (WebCore::ScrollingTree::commitTreeState):
+        (WebCore::ScrollingTree::applyLayerPositions):
+        (WebCore::ScrollingTree::applyLayerPositionsRecursive):
+        * page/scrolling/ScrollingTree.h:
+        * page/scrolling/ScrollingTreeFrameHostingNode.cpp:
+        (WebCore::ScrollingTreeFrameHostingNode::applyLayerPositions):
+        * page/scrolling/ScrollingTreeFrameHostingNode.h:
+        * page/scrolling/ScrollingTreeNode.h:
+        * page/scrolling/ScrollingTreeScrollingNode.cpp:
+        (WebCore::ScrollingTreeScrollingNode::applyLayerPositions):
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+        * page/scrolling/cocoa/ScrollingTreeFixedNode.h:
+        * page/scrolling/cocoa/ScrollingTreeFixedNode.mm:
+        (WebCore::ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange):
+        * page/scrolling/cocoa/ScrollingTreeStickyNode.h:
+        * page/scrolling/cocoa/ScrollingTreeStickyNode.mm:
+        (WebCore::ScrollingTreeStickyNode::applyLayerPositions):
+        (WebCore::ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange):
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::applyLayerPositions):
+
 2019-03-09  Andy Estes  <aestes@apple.com>
 
         [Apple Pay] CanMakePaymentsWithActiveCard and OpenPaymentSetup should be async messages
index a253db7..a32d385 100644 (file)
@@ -228,6 +228,11 @@ bool AsyncScrollingCoordinator::requestScrollPositionUpdate(FrameView& frameView
     return true;
 }
 
+void AsyncScrollingCoordinator::applyScrollingTreeLayerPositions()
+{
+    m_scrollingTree->applyLayerPositions();
+}
+
 void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction scrollingLayerPositionAction)
 {
     ScheduledScrollUpdate scrollUpdate(nodeID, scrollPosition, layoutViewportOrigin, programmaticScroll, scrollingLayerPositionAction);
index 2b93e70..5984865 100644 (file)
@@ -97,6 +97,8 @@ private:
 
     WEBCORE_EXPORT bool requestScrollPositionUpdate(FrameView&, const IntPoint&) override;
 
+    WEBCORE_EXPORT void applyScrollingTreeLayerPositions() override;
+
     WEBCORE_EXPORT ScrollingNodeID createNode(ScrollingNodeType, ScrollingNodeID newNodeID) override;
     WEBCORE_EXPORT ScrollingNodeID insertNode(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex) override;
     WEBCORE_EXPORT void unparentNode(ScrollingNodeID) override;
index 6bd5e81..f8d59d6 100644 (file)
@@ -100,6 +100,9 @@ public:
     // Should be called whenever the root layer for the given frame view changes.
     virtual void frameViewRootLayerDidChange(FrameView&);
 
+    // Traverses the scrolling tree, setting layer positions to represent the current scrolled state.
+    virtual void applyScrollingTreeLayerPositions() { }
+
 #if PLATFORM(COCOA)
     // Dispatched by the scrolling tree during handleWheelEvent. This is required as long as scrollbars are painted on the main thread.
     void handleWheelEventPhase(PlatformWheelEventPhase);
index f0d71e2..ebfde87 100644 (file)
@@ -106,6 +106,7 @@ ScrollingEventResult ScrollingTree::handleWheelEvent(const PlatformWheelEvent& w
             return downcast<ScrollingTreeScrollingNode>(*node).handleWheelEvent(wheelEvent);
     }
 
+    LockHolder locker(m_treeMutex);
     if (m_rootNode) {
         auto& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*m_rootNode);
 
@@ -140,6 +141,8 @@ void ScrollingTree::mainFrameViewportChangedViaDelegatedScrolling(const FloatPoi
 
 void ScrollingTree::commitTreeState(std::unique_ptr<ScrollingStateTree> scrollingStateTree)
 {
+    LockHolder locker(m_treeMutex);
+
     bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode();
     
     LOG(Scrolling, "\nScrollingTree %p commitTreeState", this);
@@ -245,6 +248,32 @@ void ScrollingTree::updateTreeFromStateNode(const ScrollingStateNode* stateNode,
     node->commitStateAfterChildren(*stateNode);
 }
 
+// Called from the main thread.
+void ScrollingTree::applyLayerPositions()
+{
+    LockHolder locker(m_treeMutex);
+
+    if (!m_rootNode)
+        return;
+
+    applyLayerPositionsRecursive(*m_rootNode, { }, { });
+}
+
+void ScrollingTree::applyLayerPositionsRecursive(ScrollingTreeNode& currNode, FloatRect layoutViewport, FloatSize cumulativeDelta)
+{
+    if (is<ScrollingTreeFrameScrollingNode>(currNode)) {
+        layoutViewport = downcast<ScrollingTreeFrameScrollingNode>(currNode).layoutViewport();
+        cumulativeDelta = { };
+    }
+
+    currNode.applyLayerPositions(layoutViewport, cumulativeDelta);
+
+    if (auto children = currNode.children()) {
+        for (auto& child : *children)
+            applyLayerPositionsRecursive(*child, layoutViewport, cumulativeDelta);
+    }
+}
+
 ScrollingTreeNode* ScrollingTree::nodeForID(ScrollingNodeID nodeID) const
 {
     if (!nodeID)
index 5cef4ef..d3fd9f9 100644 (file)
@@ -68,6 +68,8 @@ public:
 
     virtual void invalidate() { }
     WEBCORE_EXPORT virtual void commitTreeState(std::unique_ptr<ScrollingStateTree>);
+    
+    WEBCORE_EXPORT void applyLayerPositions();
 
     virtual Ref<ScrollingTreeNode> createScrollingTreeNode(ScrollingNodeType, ScrollingNodeID) = 0;
 
@@ -154,8 +156,12 @@ private:
 
     ScrollingTreeNode* nodeForID(ScrollingNodeID) const;
 
+    void applyLayerPositionsRecursive(ScrollingTreeNode&, FloatRect layoutViewport, FloatSize cumulativeDelta);
+
     void notifyRelatedNodesRecursive(ScrollingTreeScrollingNode& changedNode, ScrollingTreeNode& currNode, const FloatRect& layoutViewport, FloatSize cumulativeDelta);
 
+    Lock m_treeMutex; // Protects the scrolling tree.
+
     RefPtr<ScrollingTreeNode> m_rootNode;
 
     using ScrollingTreeNodeMap = HashMap<ScrollingNodeID, ScrollingTreeNode*>;
index 1a0aacc..3fa3783 100644 (file)
@@ -57,6 +57,10 @@ void ScrollingTreeFrameHostingNode::commitStateBeforeChildren(const ScrollingSta
         m_parentRelativeScrollableRect = frameHostingStateNode.parentRelativeScrollableRect();
 }
 
+void ScrollingTreeFrameHostingNode::applyLayerPositions(const FloatRect&, FloatSize&)
+{
+}
+
 LayoutPoint ScrollingTreeFrameHostingNode::parentToLocalPoint(LayoutPoint point) const
 {
     return point - toLayoutSize(parentRelativeScrollableRect().location());
index eaf0a11..9c277b6 100644 (file)
@@ -42,6 +42,7 @@ private:
     ScrollingTreeFrameHostingNode(ScrollingTree&, ScrollingNodeID);
 
     void commitStateBeforeChildren(const ScrollingStateNode&) final;
+    void applyLayerPositions(const FloatRect&, FloatSize&) final;
 
     const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; }
 
index f612b15..9b1c16f 100644 (file)
@@ -77,8 +77,9 @@ bool ScrollingTreeNode::isRootNode() const
     return m_scrollingTree.rootNode() == this;
 }
 
-void ScrollingTreeNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect&, FloatSize&)
+void ScrollingTreeNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& layoutViewport, FloatSize& cumulativeDelta)
 {
+    applyLayerPositions(layoutViewport, cumulativeDelta);
 }
 
 void ScrollingTreeNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const
index 8899c4a..426dc34 100644 (file)
@@ -85,6 +85,8 @@ protected:
 
     WEBCORE_EXPORT virtual void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta);
 
+    virtual void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) = 0;
+
     WEBCORE_EXPORT virtual void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const;
 
     std::unique_ptr<Vector<RefPtr<ScrollingTreeNode>>> m_children;
index 5bd7e25..d2d97c4 100644 (file)
@@ -179,6 +179,12 @@ bool ScrollingTreeScrollingNode::scrollPositionAndLayoutViewportMatch(const Floa
     return position == m_currentScrollPosition;
 }
 
+void ScrollingTreeScrollingNode::applyLayerPositions(const FloatRect&, FloatSize&)
+{
+    repositionScrollingLayers();
+    repositionRelatedLayers();
+}
+
 void ScrollingTreeScrollingNode::wasScrolledByDelegatedScrolling(const FloatPoint& position, Optional<FloatRect> overrideLayoutViewport)
 {
     // Even if position and overrideLayoutViewport haven't changed for this node, other nodes may have received new constraint data
index 2a19836..40c0a88 100644 (file)
@@ -98,6 +98,8 @@ protected:
     WEBCORE_EXPORT virtual void repositionScrollingLayers() { }
     WEBCORE_EXPORT virtual void repositionRelatedLayers() { }
 
+    void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;
+
     const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; }
     const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; }
     const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
index cd70d82..eb5564c 100644 (file)
@@ -47,7 +47,7 @@ private:
     ScrollingTreeFixedNode(ScrollingTree&, ScrollingNodeID);
 
     void commitStateBeforeChildren(const ScrollingStateNode&) override;
-    void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;
+    void applyLayerPositions(const FloatRect&, FloatSize&) override;
 
     void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override;
 
index f147cb2..a187989 100644 (file)
@@ -63,7 +63,7 @@ void ScrollingTreeFixedNode::commitStateBeforeChildren(const ScrollingStateNode&
         m_constraints = fixedStateNode.viewportConstraints();
 }
 
-void ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& layoutViewport, FloatSize& cumulativeDelta)
+void ScrollingTreeFixedNode::applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta)
 {
     FloatPoint layerPosition = m_constraints.layerPositionForViewportRect(layoutViewport);
 
index cab6105..f52b9f7 100644 (file)
@@ -47,7 +47,7 @@ private:
     ScrollingTreeStickyNode(ScrollingTree&, ScrollingNodeID);
 
     void commitStateBeforeChildren(const ScrollingStateNode&) override;
-    void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;
+    void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;
 
     void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override;
 
index fa74bc3..2727fb1 100644 (file)
@@ -65,7 +65,7 @@ void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode
         m_constraints = stickyStateNode.viewportConstraints();
 }
 
-void ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& layoutViewport, FloatSize& cumulativeDelta)
+void ScrollingTreeStickyNode::applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta)
 {
     FloatRect constrainingRect;
 
index e83f810..f04259b 100644 (file)
@@ -54,7 +54,7 @@ void ScrollingTreeFixedNode::commitStateBeforeChildren(const ScrollingStateNode&
 {
 }
 
-void ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect&, FloatSize&)
+void ScrollingTreeFixedNode::applyLayerPositions(const FloatRect&, FloatSize&)
 {
 }
 
index 69ab325..599b283 100644 (file)
@@ -42,7 +42,7 @@ private:
     ScrollingTreeFixedNode(ScrollingTree&, ScrollingNodeID);
 
     void commitStateBeforeChildren(const ScrollingStateNode&) override;
-    void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;
+    void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;
 };
 
 } // namespace WebCore
index a2eecb9..0b6f827 100644 (file)
@@ -54,7 +54,7 @@ void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode
 {
 }
 
-void ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect&, FloatSize&)
+void ScrollingTreeStickyNode::applyLayerPositions(const FloatRect&, FloatSize&)
 {
 }
 
index fffcdba..b2223d9 100644 (file)
@@ -42,7 +42,8 @@ private:
     ScrollingTreeStickyNode(ScrollingTree&, ScrollingNodeID);
 
     void commitStateBeforeChildren(const ScrollingStateNode&) override;
-    void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode, const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;
+    void applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta) override;
+
 };
 
 } // namespace WebCore
index 97b7339..63fb319 100644 (file)
@@ -1,3 +1,18 @@
+2019-03-10  Simon Fraser  <simon.fraser@apple.com>
+
+        ScrollingTree should have the final say on where layers go
+        https://bugs.webkit.org/show_bug.cgi?id=195507
+
+        Reviewed by Antti Koivisto.
+
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTree):
+        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
+        (WebKit::RemoteScrollingCoordinatorProxy::applyScrollingTreeLayerPositions):
+        * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
+
 2019-03-09  Darin Adler  <darin@apple.com>
 
         [Cocoa] Code signing fails because services are copied into XPCServices after the framework is signed
index bba0250..37f20a7 100644 (file)
@@ -217,13 +217,15 @@ void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTrans
     m_webPageProxy.didCommitLayerTree(layerTreeTransaction);
 
 #if ENABLE(ASYNC_SCROLLING)
-#if PLATFORM(IOS_FAMILY)
     if (m_webPageProxy.scrollingCoordinatorProxy()->hasFixedOrSticky()) {
+#if PLATFORM(IOS_FAMILY)
         // If we got a new layer for a fixed or sticky node, its position from the WebProcess is probably stale. We need to re-run the "viewport" changed logic to udpate it with our UI-side state.
         FloatRect layoutViewport = m_webPageProxy.computeCustomFixedPositionRect(m_webPageProxy.unobscuredContentRect(), m_webPageProxy.unobscuredContentRectRespectingInputViewBounds(), m_webPageProxy.customFixedPositionRect(), m_webPageProxy.displayedContentScale(), FrameView::LayoutViewportConstraint::Unconstrained);
         m_webPageProxy.scrollingCoordinatorProxy()->viewportChangedViaDelegatedScrolling(m_webPageProxy.unobscuredContentRect().location(), layoutViewport, m_webPageProxy.displayedContentScale());
-    }
+#else
+        m_webPageProxy.scrollingCoordinatorProxy()->applyScrollingTreeLayerPositions();
 #endif
+    }
 
     // Handle requested scroll position updates from the scrolling tree transaction after didCommitLayerTree()
     // has updated the view size based on the content size.
index 11f7850..d9895b5 100644 (file)
@@ -184,6 +184,11 @@ void RemoteScrollingCoordinatorProxy::viewportChangedViaDelegatedScrolling(const
     m_scrollingTree->mainFrameViewportChangedViaDelegatedScrolling(scrollPosition, layoutViewport, scale);
 }
 
+void RemoteScrollingCoordinatorProxy::applyScrollingTreeLayerPositions()
+{
+    m_scrollingTree->applyLayerPositions();
+}
+
 void RemoteScrollingCoordinatorProxy::currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical)
 {
     m_webPageProxy.send(Messages::RemoteScrollingCoordinator::CurrentSnapPointIndicesChangedForNode(nodeID, horizontal, vertical));
index 74ada61..62c0238 100644 (file)
@@ -60,6 +60,8 @@ public:
     // Called externally when native views move around.
     void viewportChangedViaDelegatedScrolling(const WebCore::FloatPoint& scrollPosition, const WebCore::FloatRect& layoutViewport, double scale);
 
+    void applyScrollingTreeLayerPositions();
+
     void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical);
 
     // FIXME: expose the tree and pass this to that?
index d270d73..2fc8d5e 100644 (file)
@@ -496,8 +496,10 @@ void TiledCoreAnimationDrawingArea::flushLayers()
         bool didFlushAllFrames = m_webPage.mainFrameView()->flushCompositingStateIncludingSubframes();
 
 #if ENABLE(ASYNC_SCROLLING)
-        if (ScrollingCoordinator* scrollingCoordinator = m_webPage.corePage()->scrollingCoordinator())
+        if (auto* scrollingCoordinator = m_webPage.corePage()->scrollingCoordinator()) {
             scrollingCoordinator->commitTreeStateIfNeeded();
+            scrollingCoordinator->applyScrollingTreeLayerPositions();
+        }
 #endif
 
         // If we have an active transient zoom, we want the zoom to win over any changes