Title: [242687] trunk/Source
Revision
242687
Author
[email protected]
Date
2019-03-10 11:03:42 -0700 (Sun, 10 Mar 2019)

Log Message

ScrollingTree should have the final say on where layers go
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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (242686 => 242687)


--- trunk/Source/WebCore/ChangeLog	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/ChangeLog	2019-03-10 18:03:42 UTC (rev 242687)
@@ -1,3 +1,56 @@
+2019-03-10  Simon Fraser  <[email protected]>
+
+        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  <[email protected]>
 
         [Apple Pay] CanMakePaymentsWithActiveCard and OpenPaymentSetup should be async messages

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp	2019-03-10 18:03:42 UTC (rev 242687)
@@ -228,6 +228,11 @@
     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);

Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -97,6 +97,8 @@
 
     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;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -100,6 +100,9 @@
     // 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);

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2019-03-10 18:03:42 UTC (rev 242687)
@@ -106,6 +106,7 @@
             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::commitTreeState(std::unique_ptr<ScrollingStateTree> scrollingStateTree)
 {
+    LockHolder locker(m_treeMutex);
+
     bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode();
     
     LOG(Scrolling, "\nScrollingTree %p commitTreeState", this);
@@ -245,6 +248,32 @@
     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)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -68,6 +68,8 @@
 
     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 @@
 
     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*>;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.cpp (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.cpp	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.cpp	2019-03-10 18:03:42 UTC (rev 242687)
@@ -57,6 +57,10 @@
         m_parentRelativeScrollableRect = frameHostingStateNode.parentRelativeScrollableRect();
 }
 
+void ScrollingTreeFrameHostingNode::applyLayerPositions(const FloatRect&, FloatSize&)
+{
+}
+
 LayoutPoint ScrollingTreeFrameHostingNode::parentToLocalPoint(LayoutPoint point) const
 {
     return point - toLayoutSize(parentRelativeScrollableRect().location());

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameHostingNode.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -42,6 +42,7 @@
     ScrollingTreeFrameHostingNode(ScrollingTree&, ScrollingNodeID);
 
     void commitStateBeforeChildren(const ScrollingStateNode&) final;
+    void applyLayerPositions(const FloatRect&, FloatSize&) final;
 
     const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; }
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp	2019-03-10 18:03:42 UTC (rev 242687)
@@ -77,8 +77,9 @@
     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

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -85,6 +85,8 @@
 
     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;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2019-03-10 18:03:42 UTC (rev 242687)
@@ -179,6 +179,12 @@
     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

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -98,6 +98,8 @@
     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; }

Modified: trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -47,7 +47,7 @@
     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;
 

Modified: trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm	2019-03-10 18:03:42 UTC (rev 242687)
@@ -63,7 +63,7 @@
         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);
 

Modified: trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -47,7 +47,7 @@
     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;
 

Modified: trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm	2019-03-10 18:03:42 UTC (rev 242687)
@@ -65,7 +65,7 @@
         m_constraints = stickyStateNode.viewportConstraints();
 }
 
-void ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect& layoutViewport, FloatSize& cumulativeDelta)
+void ScrollingTreeStickyNode::applyLayerPositions(const FloatRect& layoutViewport, FloatSize& cumulativeDelta)
 {
     FloatRect constrainingRect;
 

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp	2019-03-10 18:03:42 UTC (rev 242687)
@@ -54,7 +54,7 @@
 {
 }
 
-void ScrollingTreeFixedNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect&, FloatSize&)
+void ScrollingTreeFixedNode::applyLayerPositions(const FloatRect&, FloatSize&)
 {
 }
 

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -42,7 +42,7 @@
     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

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp	2019-03-10 18:03:42 UTC (rev 242687)
@@ -54,7 +54,7 @@
 {
 }
 
-void ScrollingTreeStickyNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode&, const FloatRect&, FloatSize&)
+void ScrollingTreeStickyNode::applyLayerPositions(const FloatRect&, FloatSize&)
 {
 }
 

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h (242686 => 242687)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -42,7 +42,8 @@
     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

Modified: trunk/Source/WebKit/ChangeLog (242686 => 242687)


--- trunk/Source/WebKit/ChangeLog	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebKit/ChangeLog	2019-03-10 18:03:42 UTC (rev 242687)
@@ -1,3 +1,18 @@
+2019-03-10  Simon Fraser  <[email protected]>
+
+        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  <[email protected]>
 
         [Cocoa] Code signing fails because services are copied into XPCServices after the framework is signed

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm (242686 => 242687)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm	2019-03-10 18:03:42 UTC (rev 242687)
@@ -217,13 +217,15 @@
     m_webPageProxy.didCommitLayerTree(layerTreeTransaction);
 
 #if ENABLE(ASYNC_SCROLLING)
+    if (m_webPageProxy.scrollingCoordinatorProxy()->hasFixedOrSticky()) {
 #if PLATFORM(IOS_FAMILY)
-    if (m_webPageProxy.scrollingCoordinatorProxy()->hasFixedOrSticky()) {
         // 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
     }
-#endif
 
     // Handle requested scroll position updates from the scrolling tree transaction after didCommitLayerTree()
     // has updated the view size based on the content size.

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp (242686 => 242687)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp	2019-03-10 18:03:42 UTC (rev 242687)
@@ -184,6 +184,11 @@
     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));

Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h (242686 => 242687)


--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h	2019-03-10 18:03:42 UTC (rev 242687)
@@ -60,6 +60,8 @@
     // 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?

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (242686 => 242687)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2019-03-10 17:13:52 UTC (rev 242686)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2019-03-10 18:03:42 UTC (rev 242687)
@@ -496,8 +496,10 @@
         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
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to