Make reconcileViewportConstrainedLayerPositions start from a specified scrolling...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 21:22:02 +0000 (21:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2018 21:22:02 +0000 (21:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180002

Patch by Frederic Wang <fwang@igalia.com> on 2018-11-29
Reviewed by Simon Fraser.

For non-programmatic scrolling of frames, AsyncScrollingCoordinator::reconcileScrollingState
currently always call reconcileViewportConstrainedLayerPositions for the main frame
since async subframe scrolling is not supported yet (bug 171667 and bug 149264). This
function in turn calls reconcileLayerPositionForViewportRect on the whole scrolling tree to
readjust position of fixed/sticky descendants. This patch refactors a bit the code so that
the operation is actually only applied to the descendants of the frame's scrolling node,
which would mean a small optimization when subframe are asynchronously scrollable. The code
is already covered by reconcile-layer-position-recursive.html.

No new tests, behavior unchanged and already covered by existing tests.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::reconcileScrollingState): Pass the frame's scrolling
node id.
(WebCore::AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions): Start
reconciliation from the specified scrolling node and log its ID.
* page/scrolling/AsyncScrollingCoordinator.h: Add ScrollingNodeID parameter.
* page/scrolling/ScrollingCoordinator.h:
(WebCore::ScrollingCoordinator::reconcileViewportConstrainedLayerPositions): Ditto.

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

Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingCoordinator.h

index 9bc7dbf..48e3a0f 100644 (file)
@@ -1,3 +1,30 @@
+2018-11-29  Frederic Wang  <fwang@igalia.com>
+
+        Make reconcileViewportConstrainedLayerPositions start from a specified scrolling node
+        https://bugs.webkit.org/show_bug.cgi?id=180002
+
+        Reviewed by Simon Fraser.
+
+        For non-programmatic scrolling of frames, AsyncScrollingCoordinator::reconcileScrollingState
+        currently always call reconcileViewportConstrainedLayerPositions for the main frame
+        since async subframe scrolling is not supported yet (bug 171667 and bug 149264). This
+        function in turn calls reconcileLayerPositionForViewportRect on the whole scrolling tree to
+        readjust position of fixed/sticky descendants. This patch refactors a bit the code so that
+        the operation is actually only applied to the descendants of the frame's scrolling node,
+        which would mean a small optimization when subframe are asynchronously scrollable. The code
+        is already covered by reconcile-layer-position-recursive.html.
+
+        No new tests, behavior unchanged and already covered by existing tests.
+
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::reconcileScrollingState): Pass the frame's scrolling
+        node id.
+        (WebCore::AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions): Start
+        reconciliation from the specified scrolling node and log its ID.
+        * page/scrolling/AsyncScrollingCoordinator.h: Add ScrollingNodeID parameter.
+        * page/scrolling/ScrollingCoordinator.h:
+        (WebCore::ScrollingCoordinator::reconcileViewportConstrainedLayerPositions): Ditto.
+
 2018-11-29  Zalan Bujtas  <zalan@apple.com>
 
         Rename *ObservedContentModifier(s) to *ObservedDOMTimer(s)
index 6800884..dc30a7e 100644 (file)
@@ -398,10 +398,11 @@ void AsyncScrollingCoordinator::reconcileScrollingState(FrameView& frameView, co
     frameView.setInProgrammaticScroll(oldProgrammaticScroll);
 
     if (!programmaticScroll && scrollingLayerPositionAction != ScrollingLayerPositionAction::Set) {
+        auto scrollingNodeID = frameView.scrollLayerID();
         if (viewportRectStability == ViewportRectStability::Stable)
-            reconcileViewportConstrainedLayerPositions(frameView.rectForFixedPositionLayout(), scrollingLayerPositionAction);
+            reconcileViewportConstrainedLayerPositions(scrollingNodeID, frameView.rectForFixedPositionLayout(), scrollingLayerPositionAction);
         else if (layoutViewportRect)
-            reconcileViewportConstrainedLayerPositions(LayoutRect(layoutViewportRect.value()), scrollingLayerPositionAction);
+            reconcileViewportConstrainedLayerPositions(scrollingNodeID, LayoutRect(layoutViewportRect.value()), scrollingLayerPositionAction);
     }
 
     auto* scrollLayer = scrollLayerForFrameView(frameView);
@@ -488,14 +489,15 @@ void AsyncScrollingCoordinator::clearStateTree()
     m_scrollingStateTree->clear();
 }
 
-void AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions(const LayoutRect& viewportRect, ScrollingLayerPositionAction action)
+void AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions(ScrollingNodeID scrollingNodeID, const LayoutRect& viewportRect, ScrollingLayerPositionAction action)
 {
-    if (!m_scrollingStateTree->rootStateNode())
+    auto* scrollingNode = m_scrollingStateTree->stateNodeForID(scrollingNodeID);
+    if (!scrollingNode)
         return;
 
-    LOG_WITH_STREAM(Scrolling, stream << getCurrentProcessID() << " AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions for viewport rect " << viewportRect);
+    LOG_WITH_STREAM(Scrolling, stream << getCurrentProcessID() << " AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions for viewport rect " << viewportRect << " and node " << scrollingNodeID);
 
-    m_scrollingStateTree->rootStateNode()->reconcileLayerPositionForViewportRect(viewportRect, action);
+    scrollingNode->reconcileLayerPositionForViewportRect(viewportRect, action);
 }
 
 void AsyncScrollingCoordinator::ensureRootStateNodeForFrameView(FrameView& frameView)
index 5fd1d55..3d64327 100644 (file)
@@ -116,7 +116,7 @@ private:
     bool isScrollSnapInProgress() const override;
 #endif
 
-    WEBCORE_EXPORT void reconcileViewportConstrainedLayerPositions(const LayoutRect& viewportRect, ScrollingLayerPositionAction) override;
+    WEBCORE_EXPORT void reconcileViewportConstrainedLayerPositions(ScrollingNodeID, const LayoutRect& viewportRect, ScrollingLayerPositionAction) override;
     WEBCORE_EXPORT void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation) override;
 
     WEBCORE_EXPORT void setSynchronousScrollingReasons(FrameView&, SynchronousScrollingReasons) final;
index 2646729..a5033b7 100644 (file)
@@ -191,7 +191,7 @@ public:
 
     virtual void updateFrameScrollingNode(ScrollingNodeID, GraphicsLayer* /*scrollLayer*/, GraphicsLayer* /*scrolledContentsLayer*/, GraphicsLayer* /*counterScrollingLayer*/, GraphicsLayer* /*insetClipLayer*/, const ScrollingGeometry* = nullptr) { }
     virtual void updateOverflowScrollingNode(ScrollingNodeID, GraphicsLayer* /*scrollLayer*/, GraphicsLayer* /*scrolledContentsLayer*/, const ScrollingGeometry* = nullptr) { }
-    virtual void reconcileViewportConstrainedLayerPositions(const LayoutRect&, ScrollingLayerPositionAction) { }
+    virtual void reconcileViewportConstrainedLayerPositions(ScrollingNodeID, const LayoutRect&, ScrollingLayerPositionAction) { }
     virtual String scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const;
     virtual bool isRubberBandInProgress() const { return false; }
     virtual bool isScrollSnapInProgress() const { return false; }