Prepare scrolling tree to handle > 1 scrolling node
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jan 2014 00:04:18 +0000 (00:04 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jan 2014 00:04:18 +0000 (00:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127590

Source/WebCore:

Reviewed by Tim Horton.

Clean up the code path called after the ScrollingTree has scrolled a node,
to prepare for multiple scrolling nodes.

Change "updateMainFrameScrollPosition" terminology to "updateScrollPositionAfterAsyncScroll",
and pass along the ScrollingNodeID that scrolled.

Move updateMainFrameScrollPosition-related code from ScrollingCoordinator to
AsyncScrollingCoordinator, since this sync-up is only necessary when doing
async scrolling.

* WebCore.exp.in:
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::AsyncScrollingCoordinator):
(WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
(WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll):
(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired):
(WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
* page/scrolling/AsyncScrollingCoordinator.h:
(WebCore::AsyncScrollingCoordinator::ScheduledScrollUpdate::ScheduledScrollUpdate):
(WebCore::AsyncScrollingCoordinator::ScheduledScrollUpdate::matchesUpdateType):
Package up the data related to a scheduled scroll into a ScheduledScrollUpdate struct,
for easier comparison and cleaner code.
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::ScrollingCoordinator):
* page/scrolling/ScrollingCoordinator.h:
* page/scrolling/ScrollingTree.h:
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
* page/scrolling/ThreadedScrollingTree.h:
* page/scrolling/ios/ScrollingTreeIOS.cpp:
(WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll):
* page/scrolling/ios/ScrollingTreeIOS.h:
* page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm:
(WebCore::ScrollingTreeScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstraints):
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::ScrollingTreeScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):

Source/WebKit2:

Reviewed by Tim Horton.

Clean up the code path called after the ScrollingTree has scrolled a node,
to prepare for multiple scrolling nodes.

Change "updateMainFrameScrollPosition" terminology to "updateScrollPositionAfterAsyncScroll",
and pass along the ScrollingNodeID that scrolled.

* UIProcess/Scrolling/RemoteScrollingTree.cpp:
(WebKit::RemoteScrollingTree::scrollingTreeNodeDidScroll):
* UIProcess/Scrolling/RemoteScrollingTree.h:
* WebProcess/Scrolling/RemoteScrollingCoordinator.mm:
(WebKit::RemoteScrollingCoordinator::scrollPositionChangedForNode):

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

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
Source/WebCore/page/scrolling/ThreadedScrollingTree.h
Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.cpp
Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.h
Source/WebCore/page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.cpp
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.h
Source/WebKit2/WebProcess/Scrolling/RemoteScrollingCoordinator.mm

index e8bb946..5b7c8e7 100644 (file)
@@ -1,3 +1,47 @@
+2014-01-24  Simon Fraser  <simon.fraser@apple.com>
+
+        Prepare scrolling tree to handle > 1 scrolling node
+        https://bugs.webkit.org/show_bug.cgi?id=127590
+
+        Reviewed by Tim Horton.
+
+        Clean up the code path called after the ScrollingTree has scrolled a node,
+        to prepare for multiple scrolling nodes.
+        
+        Change "updateMainFrameScrollPosition" terminology to "updateScrollPositionAfterAsyncScroll",
+        and pass along the ScrollingNodeID that scrolled.
+        
+        Move updateMainFrameScrollPosition-related code from ScrollingCoordinator to
+        AsyncScrollingCoordinator, since this sync-up is only necessary when doing
+        async scrolling.
+
+        * WebCore.exp.in:
+        * page/scrolling/AsyncScrollingCoordinator.cpp:
+        (WebCore::AsyncScrollingCoordinator::AsyncScrollingCoordinator):
+        (WebCore::AsyncScrollingCoordinator::requestScrollPositionUpdate):
+        (WebCore::AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll):
+        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired):
+        (WebCore::AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll):
+        * page/scrolling/AsyncScrollingCoordinator.h:
+        (WebCore::AsyncScrollingCoordinator::ScheduledScrollUpdate::ScheduledScrollUpdate):
+        (WebCore::AsyncScrollingCoordinator::ScheduledScrollUpdate::matchesUpdateType):
+        Package up the data related to a scheduled scroll into a ScheduledScrollUpdate struct,
+        for easier comparison and cleaner code.
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::ScrollingCoordinator):
+        * page/scrolling/ScrollingCoordinator.h:
+        * page/scrolling/ScrollingTree.h:
+        * page/scrolling/ThreadedScrollingTree.cpp:
+        (WebCore::ThreadedScrollingTree::scrollingTreeNodeDidScroll):
+        * page/scrolling/ThreadedScrollingTree.h:
+        * page/scrolling/ios/ScrollingTreeIOS.cpp:
+        (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll):
+        * page/scrolling/ios/ScrollingTreeIOS.h:
+        * page/scrolling/ios/ScrollingTreeScrollingNodeIOS.mm:
+        (WebCore::ScrollingTreeScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstraints):
+        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):
+
 2014-01-24  Mark Lam  <mark.lam@apple.com>
 
         ASSERT(!m_markedSpace.m_currentDelayedReleaseScope) reloading page in inspector.
index 8b4a92a..834cabe 100644 (file)
@@ -2992,7 +2992,6 @@ __ZN7WebCore22ScrollingTreeFixedNode6createERNS_13ScrollingTreeEy
 __ZN7WebCore23ScrollingStateFixedNode17updateConstraintsERKNS_32FixedPositionViewportConstraintsE
 __ZN7WebCore23ScrollingTreeStickyNode6createERNS_13ScrollingTreeEy
 __ZN7WebCore24ScrollingStateStickyNode17updateConstraintsERKNS_33StickyPositionViewportConstraintsE
-__ZN7WebCore20ScrollingCoordinator35scheduleUpdateScrollPositionForNodeEyRKNS_8IntPointEbNS_31SetOrSyncScrollingLayerPositionE
 __ZN7WebCore25AsyncScrollingCoordinator14clearStateTreeEv
 __ZN7WebCore25AsyncScrollingCoordinator17attachToStateTreeENS_17ScrollingNodeTypeEyy
 __ZN7WebCore25AsyncScrollingCoordinator18syncChildPositionsERKNS_10LayoutRectE
@@ -3006,6 +3005,7 @@ __ZN7WebCore25AsyncScrollingCoordinator29updateViewportConstrainedNodeEyRKNS_19V
 __ZN7WebCore25AsyncScrollingCoordinator30setSynchronousScrollingReasonsEj
 __ZN7WebCore25AsyncScrollingCoordinator37scrollableAreaScrollbarLayerDidChangeEPNS_14ScrollableAreaENS_20ScrollbarOrientationE
 __ZN7WebCore25AsyncScrollingCoordinator43recomputeWheelEventHandlerCountForFrameViewEPNS_9FrameViewE
+__ZN7WebCore25AsyncScrollingCoordinator44scheduleUpdateScrollPositionAfterAsyncScrollEyRKNS_8IntPointEbNS_31SetOrSyncScrollingLayerPositionE
 __ZN7WebCore25AsyncScrollingCoordinatorC2EPNS_4PageE
 __ZN7WebCore25AsyncScrollingCoordinatorD2Ev
 __ZN7WebCore27ScrollingStateScrollingNode14setFooterLayerERKNS_19LayerRepresentationE
index 150b6de..77c50b8 100644 (file)
@@ -43,6 +43,7 @@ namespace WebCore {
 
 AsyncScrollingCoordinator::AsyncScrollingCoordinator(Page* page)
     : ScrollingCoordinator(page)
+    , m_updateNodeScrollPositionTimer(this, &AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired)
     , m_scrollingStateTree(ScrollingStateTree::create(this))
 {
 }
@@ -135,7 +136,7 @@ bool AsyncScrollingCoordinator::requestScrollPositionUpdate(FrameView* frameView
         return false;
 
     if (frameView->inProgrammaticScroll() || frameView->frame().document()->inPageCache())
-        updateMainFrameScrollPosition(scrollPosition, frameView->inProgrammaticScroll(), SetScrollingLayerPosition);
+        updateScrollPositionAfterAsyncScroll(frameView->scrollLayerID(), scrollPosition, frameView->inProgrammaticScroll(), SetScrollingLayerPosition);
 
     // If this frame view's document is being put into the page cache, we don't want to update our
     // main frame scroll position. Just let the FrameView think that we did.
@@ -150,6 +151,88 @@ bool AsyncScrollingCoordinator::requestScrollPositionUpdate(FrameView* frameView
     return true;
 }
 
+void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const IntPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
+{
+    ScheduledScrollUpdate scrollUpdate(nodeID, scrollPosition, programmaticScroll, scrollingLayerPositionAction);
+    
+    if (m_updateNodeScrollPositionTimer.isActive()) {
+        if (m_scheduledScrollUpdate.matchesUpdateType(scrollUpdate)) {
+            m_scheduledScrollUpdate.scrollPosition = scrollPosition;
+            return;
+        }
+    
+        // If the parameters don't match what was previosly scheduled, dispatch immediately.
+        m_updateNodeScrollPositionTimer.stop();
+        updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction);
+        updateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, programmaticScroll, scrollingLayerPositionAction);
+        return;
+    }
+
+    m_scheduledScrollUpdate = scrollUpdate;
+    m_updateNodeScrollPositionTimer.startOneShot(0);
+}
+
+void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired(Timer<AsyncScrollingCoordinator>*)
+{
+    updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction);
+}
+
+void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const IntPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
+{
+    ASSERT(isMainThread());
+
+    if (!m_page)
+        return;
+
+    FrameView* frameView = m_page->mainFrame().view();
+    if (!frameView)
+        return;
+
+    bool oldProgrammaticScroll = frameView->inProgrammaticScroll();
+    frameView->setInProgrammaticScroll(programmaticScroll);
+
+    frameView->setConstrainsScrollingToContentEdge(false);
+    frameView->notifyScrollPositionChanged(scrollPosition);
+    frameView->setConstrainsScrollingToContentEdge(true);
+
+    frameView->setInProgrammaticScroll(oldProgrammaticScroll);
+
+#if USE(ACCELERATED_COMPOSITING)
+    if (scrollingNodeID == frameView->scrollLayerID()) {
+        if (GraphicsLayer* scrollLayer = scrollLayerForFrameView(frameView)) {
+            GraphicsLayer* counterScrollingLayer = counterScrollingLayerForFrameView(frameView);
+            GraphicsLayer* headerLayer = headerLayerForFrameView(frameView);
+            GraphicsLayer* footerLayer = footerLayerForFrameView(frameView);
+            IntSize scrollOffsetForFixed = frameView->scrollOffsetForFixedPosition();
+
+            if (programmaticScroll || scrollingLayerPositionAction == SetScrollingLayerPosition) {
+                scrollLayer->setPosition(-frameView->scrollPosition());
+                if (counterScrollingLayer)
+                    counterScrollingLayer->setPosition(IntPoint(scrollOffsetForFixed));
+                if (headerLayer)
+                    headerLayer->setPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
+                if (footerLayer)
+                    footerLayer->setPosition(FloatPoint(scrollOffsetForFixed.width(), frameView->totalContentsSize().height() - frameView->footerHeight()));
+            } else {
+                scrollLayer->syncPosition(-frameView->scrollPosition());
+                if (counterScrollingLayer)
+                    counterScrollingLayer->syncPosition(IntPoint(scrollOffsetForFixed));
+                if (headerLayer)
+                    headerLayer->syncPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
+                if (footerLayer)
+                    footerLayer->syncPosition(FloatPoint(scrollOffsetForFixed.width(), frameView->totalContentsSize().height() - frameView->footerHeight()));
+
+                LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect();
+                syncChildPositions(viewportRect);
+            }
+        }
+    }
+    // FIXME: handle non-main scrolling nodes.
+#else
+    UNUSED_PARAM(scrollingLayerPositionAction);
+#endif
+}
+
 void AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(ScrollableArea* scrollableArea, ScrollbarOrientation orientation)
 {
     ASSERT(isMainThread());
index 16c19b4..4b723d4 100644 (file)
@@ -31,6 +31,7 @@
 #include "ScrollingCoordinator.h"
 
 #include "ScrollingTree.h"
+#include "Timer.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
@@ -56,6 +57,8 @@ public:
 
     void scrollingStateTreePropertiesChanged();
 
+    void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const IntPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
+
 protected:
     AsyncScrollingCoordinator(Page*);
 
@@ -65,6 +68,8 @@ protected:
 
     PassRefPtr<ScrollingTree> releaseScrollingTree() { return m_scrollingTree.release(); }
 
+    void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const IntPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
+
 private:
     virtual bool isAsyncScrollingCoordinator() const override { return true; }
 
@@ -107,6 +112,39 @@ private:
     // FIXME: move somewhere else?
     void setScrollbarPaintersFromScrollbarsForNode(Scrollbar* verticalScrollbar, Scrollbar* horizontalScrollbar, ScrollingStateScrollingNode*);
 
+    void updateScrollPositionAfterAsyncScrollTimerFired(Timer<AsyncScrollingCoordinator>*);
+
+    Timer<AsyncScrollingCoordinator> m_updateNodeScrollPositionTimer;
+
+    struct ScheduledScrollUpdate {
+        ScheduledScrollUpdate()
+            : nodeID(0)
+            , isProgrammaticScroll(false)
+            , updateLayerPositionAction(SyncScrollingLayerPosition)
+        { }
+
+        ScheduledScrollUpdate(ScrollingNodeID scrollingNodeID, IntPoint point, bool isProgrammatic, SetOrSyncScrollingLayerPosition udpateAction)
+            : nodeID(scrollingNodeID)
+            , scrollPosition(point)
+            , isProgrammaticScroll(isProgrammatic)
+            , updateLayerPositionAction(udpateAction)
+        { }
+
+        ScrollingNodeID nodeID;
+        IntPoint scrollPosition;
+        bool isProgrammaticScroll;
+        SetOrSyncScrollingLayerPosition updateLayerPositionAction;
+        
+        bool matchesUpdateType(const ScheduledScrollUpdate& other) const
+        {
+            return nodeID == other.nodeID
+                && isProgrammaticScroll == other.isProgrammaticScroll
+                && updateLayerPositionAction == other.updateLayerPositionAction;
+        }
+    };
+
+    ScheduledScrollUpdate m_scheduledScrollUpdate;
+
     OwnPtr<ScrollingStateTree> m_scrollingStateTree;
     RefPtr<ScrollingTree> m_scrollingTree;
 };
index 1bbb7f3..93dfb0c 100644 (file)
@@ -64,9 +64,6 @@ PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
 
 ScrollingCoordinator::ScrollingCoordinator(Page* page)
     : m_page(page)
-    , m_updateMainFrameScrollPositionTimer(this, &ScrollingCoordinator::updateMainFrameScrollPositionTimerFired)
-    , m_scheduledUpdateIsProgrammaticScroll(false)
-    , m_scheduledScrollingLayerPositionAction(SyncScrollingLayerPosition)
     , m_forceSynchronousScrollLayerPositionUpdates(false)
 {
 }
@@ -260,92 +257,6 @@ void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
     updateSynchronousScrollingReasons();
 }
 
-void ScrollingCoordinator::scheduleUpdateScrollPositionForNode(ScrollingNodeID, const IntPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
-{
-    // FIXME: need to handle non-main nodes.
-    scheduleUpdateMainFrameScrollPosition(scrollPosition, programmaticScroll, scrollingLayerPositionAction);
-}
-
-void ScrollingCoordinator::scheduleUpdateMainFrameScrollPosition(const IntPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
-{
-    if (m_updateMainFrameScrollPositionTimer.isActive()) {
-        if (m_scheduledUpdateIsProgrammaticScroll == programmaticScroll
-            && m_scheduledScrollingLayerPositionAction == scrollingLayerPositionAction) {
-            m_scheduledUpdateScrollPosition = scrollPosition;
-            return;
-        }
-    
-        // If the parameters don't match what was previosly scheduled, dispatch immediately.
-        m_updateMainFrameScrollPositionTimer.stop();
-        updateMainFrameScrollPosition(m_scheduledUpdateScrollPosition, m_scheduledUpdateIsProgrammaticScroll, m_scheduledScrollingLayerPositionAction);
-        updateMainFrameScrollPosition(scrollPosition, programmaticScroll, scrollingLayerPositionAction);
-        return;
-    }
-
-    m_scheduledUpdateScrollPosition = scrollPosition;
-    m_scheduledUpdateIsProgrammaticScroll = programmaticScroll;
-    m_scheduledScrollingLayerPositionAction = scrollingLayerPositionAction;
-    m_updateMainFrameScrollPositionTimer.startOneShot(0);
-}
-
-void ScrollingCoordinator::updateMainFrameScrollPositionTimerFired(Timer<ScrollingCoordinator>*)
-{
-    updateMainFrameScrollPosition(m_scheduledUpdateScrollPosition, m_scheduledUpdateIsProgrammaticScroll, m_scheduledScrollingLayerPositionAction);
-}
-
-void ScrollingCoordinator::updateMainFrameScrollPosition(const IntPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
-{
-    ASSERT(isMainThread());
-
-    if (!m_page)
-        return;
-
-    FrameView* frameView = m_page->mainFrame().view();
-    if (!frameView)
-        return;
-
-    bool oldProgrammaticScroll = frameView->inProgrammaticScroll();
-    frameView->setInProgrammaticScroll(programmaticScroll);
-
-    frameView->setConstrainsScrollingToContentEdge(false);
-    frameView->notifyScrollPositionChanged(scrollPosition);
-    frameView->setConstrainsScrollingToContentEdge(true);
-
-    frameView->setInProgrammaticScroll(oldProgrammaticScroll);
-
-#if USE(ACCELERATED_COMPOSITING)
-    if (GraphicsLayer* scrollLayer = scrollLayerForFrameView(frameView)) {
-        GraphicsLayer* counterScrollingLayer = counterScrollingLayerForFrameView(frameView);
-        GraphicsLayer* headerLayer = headerLayerForFrameView(frameView);
-        GraphicsLayer* footerLayer = footerLayerForFrameView(frameView);
-        IntSize scrollOffsetForFixed = frameView->scrollOffsetForFixedPosition();
-
-        if (programmaticScroll || scrollingLayerPositionAction == SetScrollingLayerPosition) {
-            scrollLayer->setPosition(-frameView->scrollPosition());
-            if (counterScrollingLayer)
-                counterScrollingLayer->setPosition(IntPoint(scrollOffsetForFixed));
-            if (headerLayer)
-                headerLayer->setPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
-            if (footerLayer)
-                footerLayer->setPosition(FloatPoint(scrollOffsetForFixed.width(), frameView->totalContentsSize().height() - frameView->footerHeight()));
-        } else {
-            scrollLayer->syncPosition(-frameView->scrollPosition());
-            if (counterScrollingLayer)
-                counterScrollingLayer->syncPosition(IntPoint(scrollOffsetForFixed));
-            if (headerLayer)
-                headerLayer->syncPosition(FloatPoint(scrollOffsetForFixed.width(), 0));
-            if (footerLayer)
-                footerLayer->syncPosition(FloatPoint(scrollOffsetForFixed.width(), frameView->totalContentsSize().height() - frameView->footerHeight()));
-
-            LayoutRect viewportRect = frameView->viewportConstrainedVisibleContentRect();
-            syncChildPositions(viewportRect);
-        }
-    }
-#else
-    UNUSED_PARAM(scrollingLayerPositionAction);
-#endif
-}
-
 #if PLATFORM(MAC)
 void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase)
 {
index fc1e0ba..0e05d69 100644 (file)
@@ -31,7 +31,6 @@
 #include "PlatformWheelEvent.h"
 #include "RenderObject.h"
 #include "ScrollTypes.h"
-#include "Timer.h"
 #include <wtf/Forward.h>
 
 #if ENABLE(ASYNC_SCROLLING)
@@ -159,12 +158,6 @@ public:
     // Generated a unique id for scroll layers.
     ScrollingNodeID uniqueScrollLayerID();
 
-    void scheduleUpdateScrollPositionForNode(ScrollingNodeID, const IntPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
-
-    // Dispatched by the scrolling tree whenever the main frame scroll position changes.
-    void scheduleUpdateMainFrameScrollPosition(const IntPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
-    void updateMainFrameScrollPosition(const IntPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
-
     enum MainThreadScrollingReasonFlags {
         ForcedOnMainThread = 1 << 0,
         HasSlowRepaintObjects = 1 << 1,
@@ -210,13 +203,6 @@ private:
     virtual bool hasVisibleSlowRepaintViewportConstrainedObjects(FrameView*) const;
     void updateSynchronousScrollingReasons();
     
-    void updateMainFrameScrollPositionTimerFired(Timer<ScrollingCoordinator>*);
-
-    Timer<ScrollingCoordinator> m_updateMainFrameScrollPositionTimer;
-    IntPoint m_scheduledUpdateScrollPosition;
-    bool m_scheduledUpdateIsProgrammaticScroll;
-    SetOrSyncScrollingLayerPosition m_scheduledScrollingLayerPositionAction;
-
     bool m_forceSynchronousScrollLayerPositionUpdates;
 };
 
index a64e5ea..b64b6a2 100644 (file)
@@ -71,7 +71,7 @@ public:
 
     void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom);
 
-    virtual void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) = 0;
+    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) = 0;
     IntPoint mainFrameScrollPosition();
 
 #if PLATFORM(MAC) && !PLATFORM(IOS)
index 624d3a2..8314de3 100644 (file)
@@ -100,14 +100,15 @@ void ThreadedScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> sc
     ScrollingTree::commitNewTreeState(scrollingStateTree);
 }
 
-void ThreadedScrollingTree::updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
+void ThreadedScrollingTree::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
 {
     if (!m_scrollingCoordinator)
         return;
 
-    setMainFrameScrollPosition(scrollPosition);
+    if (nodeID == rootNode()->scrollingNodeID())
+        setMainFrameScrollPosition(scrollPosition);
 
-    callOnMainThread(bind(&ScrollingCoordinator::scheduleUpdateMainFrameScrollPosition, m_scrollingCoordinator.get(), scrollPosition, isHandlingProgrammaticScroll(), scrollingLayerPositionAction));
+    callOnMainThread(bind(&AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll, m_scrollingCoordinator.get(), nodeID, scrollPosition, isHandlingProgrammaticScroll(), scrollingLayerPositionAction));
 }
 
 #if PLATFORM(MAC) && !PLATFORM(IOS)
index b9fb218..d0c8b17 100644 (file)
@@ -64,7 +64,7 @@ private:
 
     virtual PassOwnPtr<ScrollingTreeNode> createNode(ScrollingNodeType, ScrollingNodeID) override;
 
-    virtual void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
+    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
 #if PLATFORM(MAC) && !PLATFORM(IOS)
     virtual void handleWheelEventPhase(PlatformWheelEventPhase) override;
 #endif
index 850a94d..147916a 100644 (file)
@@ -81,14 +81,15 @@ void ScrollingTreeIOS::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrolli
     ScrollingTree::commitNewTreeState(scrollingStateTree);
 }
 
-void ScrollingTreeIOS::updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
+void ScrollingTreeIOS::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
 {
     if (!m_scrollingCoordinator)
         return;
 
-    setMainFrameScrollPosition(scrollPosition);
+    if (nodeID == rootNode()->scrollingNodeID())
+        setMainFrameScrollPosition(scrollPosition);
 
-    callOnMainThread(bind(&ScrollingCoordinator::scheduleUpdateMainFrameScrollPosition, m_scrollingCoordinator.get(), scrollPosition, isHandlingProgrammaticScroll(), scrollingLayerPositionAction));
+    callOnMainThread(bind(&AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll, m_scrollingCoordinator.get(), nodeID, scrollPosition, isHandlingProgrammaticScroll(), scrollingLayerPositionAction));
 }
 
 PassOwnPtr<ScrollingTreeNode> ScrollingTreeIOS::createNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
index 7cba2f1..57601b8 100644 (file)
@@ -56,7 +56,7 @@ private:
 
     virtual PassOwnPtr<ScrollingTreeNode> createNode(ScrollingNodeType, ScrollingNodeID) override;
 
-    virtual void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
+    virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
 
     RefPtr<AsyncScrollingCoordinator> m_scrollingCoordinator;
 };
index 6b32963..826ecd6 100644 (file)
@@ -118,12 +118,12 @@ void ScrollingTreeScrollingNodeIOS::setScrollPositionWithoutContentEdgeConstrain
 {
     if (shouldUpdateScrollLayerPositionSynchronously()) {
         m_probableMainThreadScrollPosition = scrollPosition;
-        scrollingTree().updateMainFrameScrollPosition(scrollPosition, SetScrollingLayerPosition);
+        scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition, SetScrollingLayerPosition);
         return;
     }
 
     setScrollLayerPosition(scrollPosition);
-    scrollingTree().updateMainFrameScrollPosition(scrollPosition);
+    scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition);
 }
 
 void ScrollingTreeScrollingNodeIOS::setScrollLayerPosition(const IntPoint& position)
index eb7d201..857de8b 100644 (file)
@@ -315,12 +315,12 @@ void ScrollingTreeScrollingNodeMac::setScrollPositionWithoutContentEdgeConstrain
 
     if (shouldUpdateScrollLayerPositionSynchronously()) {
         m_probableMainThreadScrollPosition = scrollPosition;
-        scrollingTree().updateMainFrameScrollPosition(scrollPosition, SetScrollingLayerPosition);
+        scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition, SetScrollingLayerPosition);
         return;
     }
 
     setScrollLayerPosition(scrollPosition);
-    scrollingTree().updateMainFrameScrollPosition(scrollPosition);
+    scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition);
 }
 
 void ScrollingTreeScrollingNodeMac::setScrollLayerPosition(const IntPoint& position)
index 36769a0..09ef833 100644 (file)
@@ -1,5 +1,24 @@
 2014-01-24  Simon Fraser  <simon.fraser@apple.com>
 
+        Prepare scrolling tree to handle > 1 scrolling node
+        https://bugs.webkit.org/show_bug.cgi?id=127590
+
+        Reviewed by Tim Horton.
+        
+        Clean up the code path called after the ScrollingTree has scrolled a node,
+        to prepare for multiple scrolling nodes.
+        
+        Change "updateMainFrameScrollPosition" terminology to "updateScrollPositionAfterAsyncScroll",
+        and pass along the ScrollingNodeID that scrolled.
+
+        * UIProcess/Scrolling/RemoteScrollingTree.cpp:
+        (WebKit::RemoteScrollingTree::scrollingTreeNodeDidScroll):
+        * UIProcess/Scrolling/RemoteScrollingTree.h:
+        * WebProcess/Scrolling/RemoteScrollingCoordinator.mm:
+        (WebKit::RemoteScrollingCoordinator::scrollPositionChangedForNode):
+
+2014-01-24  Simon Fraser  <simon.fraser@apple.com>
+
         #ifdef out handleWheelEventPhase for iOS
         https://bugs.webkit.org/show_bug.cgi?id=127583
 
index fb4624f..2317d15 100644 (file)
@@ -76,10 +76,9 @@ void RemoteScrollingTree::handleWheelEventPhase(PlatformWheelEventPhase phase)
 }
 #endif
 
-void RemoteScrollingTree::updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition)
+void RemoteScrollingTree::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition)
 {
-    // FIXME: fix for all scrolling nodes.
-    m_scrollingCoordinatorProxy.scrollPositionChanged(rootNode()->scrollingNodeID(), scrollPosition);
+    m_scrollingCoordinatorProxy.scrollPositionChanged(nodeID, scrollPosition);
 }
 
 PassOwnPtr<ScrollingTreeNode> RemoteScrollingTree::createNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
index b04fcc6..268e5a2 100644 (file)
@@ -52,7 +52,7 @@ private:
 #if PLATFORM(MAC) && !PLATFORM(IOS)
     virtual void handleWheelEventPhase(WebCore::PlatformWheelEventPhase) override;
 #endif
-    virtual void updateMainFrameScrollPosition(const WebCore::IntPoint& scrollPosition, WebCore::SetOrSyncScrollingLayerPosition = WebCore::SyncScrollingLayerPosition) override;
+    virtual void scrollingTreeNodeDidScroll(WebCore::ScrollingNodeID, const WebCore::IntPoint& scrollPosition, WebCore::SetOrSyncScrollingLayerPosition = WebCore::SyncScrollingLayerPosition) override;
 
     virtual PassOwnPtr<WebCore::ScrollingTreeNode> createNode(WebCore::ScrollingNodeType, WebCore::ScrollingNodeID);
     
index c8966b8..9bd5c48 100644 (file)
@@ -93,7 +93,7 @@ void RemoteScrollingCoordinator::buildTransaction(RemoteScrollingCoordinatorTran
 // Notification from the UI process that we scrolled.
 void RemoteScrollingCoordinator::scrollPositionChangedForNode(ScrollingNodeID nodeID, const FloatPoint& scrollPosition)
 {
-    scheduleUpdateScrollPositionForNode(nodeID, roundedIntPoint(scrollPosition), false /* FIXME */, SyncScrollingLayerPosition);
+    scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, roundedIntPoint(scrollPosition), false /* FIXME */, SyncScrollingLayerPosition);
 }
 
 } // namespace WebKit