Allow different types of ScrollingTrees to have different types of ScrollingTreeNode...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Jan 2014 20:05:48 +0000 (20:05 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Jan 2014 20:05:48 +0000 (20:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126445

Reviewed by Tim Horton.

Make it possible to have ScrollingTree subclasses with different subclasses of ScrollingTreeNodes,
by giving ScrollingTree a pure virtual createNode() function. ThreadedScrollingTree implements
this, and then delegates node creation to its AsyncScrollingCoordinator (since we have
a ScrollingCoordinatorMac but no real need for a ThreadedScrollingTreeMac).

Also made ThreadedScrollingTree's m_scrollingCoordinator an AsyncScrollingCoordinator,
since by definition a threaded scrolling tree uses an async coordinator.

* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::updateTreeFromStateNode):
* page/scrolling/ScrollingTree.h:
* page/scrolling/ScrollingTreeScrollingNode.h:
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::create):
(WebCore::ThreadedScrollingTree::ThreadedScrollingTree):
(WebCore::ThreadedScrollingTree::createNode):
* page/scrolling/ThreadedScrollingTree.h:
* page/scrolling/mac/ScrollingCoordinatorMac.h:
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::createScrollingTreeNode):
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.h:
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::ScrollingTreeScrollingNodeMac::create):

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

Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
Source/WebCore/page/scrolling/ThreadedScrollingTree.h
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.h
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm

index f6beed2..7322acb 100644 (file)
@@ -1,3 +1,35 @@
+2014-01-03  Simon Fraser  <simon.fraser@apple.com>
+
+        Allow different types of ScrollingTrees to have different types of ScrollingTreeNode subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=126445
+
+        Reviewed by Tim Horton.
+        
+        Make it possible to have ScrollingTree subclasses with different subclasses of ScrollingTreeNodes,
+        by giving ScrollingTree a pure virtual createNode() function. ThreadedScrollingTree implements
+        this, and then delegates node creation to its AsyncScrollingCoordinator (since we have
+        a ScrollingCoordinatorMac but no real need for a ThreadedScrollingTreeMac).
+        
+        Also made ThreadedScrollingTree's m_scrollingCoordinator an AsyncScrollingCoordinator,
+        since by definition a threaded scrolling tree uses an async coordinator.
+
+        * page/scrolling/AsyncScrollingCoordinator.h:
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::updateTreeFromStateNode):
+        * page/scrolling/ScrollingTree.h:
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+        * page/scrolling/ThreadedScrollingTree.cpp:
+        (WebCore::ThreadedScrollingTree::create):
+        (WebCore::ThreadedScrollingTree::ThreadedScrollingTree):
+        (WebCore::ThreadedScrollingTree::createNode):
+        * page/scrolling/ThreadedScrollingTree.h:
+        * page/scrolling/mac/ScrollingCoordinatorMac.h:
+        * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+        (WebCore::ScrollingCoordinatorMac::createScrollingTreeNode):
+        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.h:
+        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeScrollingNodeMac::create):
+
 2014-01-03  Gavin Barraclough  <barraclough@apple.com>
 
         Refactor NSActivity handling code from ChildProcess to UserActivity
index eb0d052..10c2980 100644 (file)
@@ -52,6 +52,8 @@ public:
 
     ScrollingTree* scrollingTree() const { return m_scrollingTree.get(); }
 
+    virtual PassOwnPtr<ScrollingTreeNode> createScrollingTreeNode(ScrollingNodeType, ScrollingNodeID) = 0;
+
 protected:
     AsyncScrollingCoordinator(Page*);
 
index 840c33c..9f197c7 100644 (file)
 
 #include "PlatformWheelEvent.h"
 #include "ScrollingStateTree.h"
-#include "ScrollingTreeFixedNode.h"
 #include "ScrollingTreeNode.h"
 #include "ScrollingTreeScrollingNode.h"
-#include "ScrollingTreeStickyNode.h"
 #include <wtf/TemporaryChange.h>
 
 namespace WebCore {
@@ -133,24 +131,12 @@ void ScrollingTree::updateTreeFromStateNode(const ScrollingStateNode* stateNode)
             // This is the root node. Nuke the node map.
             m_nodeMap.clear();
 
-            m_rootNode = ScrollingTreeScrollingNode::create(*this, nodeID);
+            m_rootNode = static_pointer_cast<ScrollingTreeScrollingNode>(createNode(ScrollingNode, nodeID));
             m_nodeMap.set(nodeID, m_rootNode.get());
             m_rootNode->updateBeforeChildren(*stateNode);
             node = m_rootNode.get();
         } else {
-            OwnPtr<ScrollingTreeNode> newNode;
-            switch (stateNode->nodeType()) {
-            case ScrollingNode:
-                newNode = ScrollingTreeScrollingNode::create(*this, nodeID);
-                break;
-            case FixedNode:
-                newNode = ScrollingTreeFixedNode::create(*this, nodeID);
-                break;
-            case StickyNode:
-                newNode = ScrollingTreeStickyNode::create(*this, nodeID);
-                break;
-            }
-
+            OwnPtr<ScrollingTreeNode> newNode = createNode(stateNode->nodeType(), nodeID);
             node = newNode.get();
             m_nodeMap.set(nodeID, node);
             ScrollingTreeNodeMap::const_iterator it = m_nodeMap.find(stateNode->parent()->scrollingNodeID());
index 0de3548..d3bbdf1 100644 (file)
@@ -103,6 +103,8 @@ private:
     void removeDestroyedNodes(const ScrollingStateTree&);
     void updateTreeFromStateNode(const ScrollingStateNode*);
 
+    virtual PassOwnPtr<ScrollingTreeNode> createNode(ScrollingNodeType, ScrollingNodeID) = 0;
+
     OwnPtr<ScrollingTreeScrollingNode> m_rootNode;
 
     typedef HashMap<ScrollingNodeID, ScrollingTreeNode*> ScrollingTreeNodeMap;
index 162923b..de0c8a0 100644 (file)
@@ -42,7 +42,6 @@ class ScrollingStateScrollingNode;
 
 class ScrollingTreeScrollingNode : public ScrollingTreeNode {
 public:
-    static PassOwnPtr<ScrollingTreeScrollingNode> create(ScrollingTree&, ScrollingNodeID);
     virtual ~ScrollingTreeScrollingNode();
 
     virtual void updateBeforeChildren(const ScrollingStateNode&) OVERRIDE;
index d857daf..5e0ebef 100644 (file)
@@ -28,8 +28,8 @@
 
 #if ENABLE(ASYNC_SCROLLING)
 
+#include "AsyncScrollingCoordinator.h"
 #include "PlatformWheelEvent.h"
-#include "ScrollingCoordinator.h"
 #include "ScrollingThread.h"
 #include "ScrollingTreeFixedNode.h"
 #include "ScrollingTreeNode.h"
 
 namespace WebCore {
 
-RefPtr<ThreadedScrollingTree> ThreadedScrollingTree::create(ScrollingCoordinator* scrollingCoordinator)
+RefPtr<ThreadedScrollingTree> ThreadedScrollingTree::create(AsyncScrollingCoordinator* scrollingCoordinator)
 {
     return adoptRef(new ThreadedScrollingTree(scrollingCoordinator));
 }
 
-ThreadedScrollingTree::ThreadedScrollingTree(ScrollingCoordinator* scrollingCoordinator)
+ThreadedScrollingTree::ThreadedScrollingTree(AsyncScrollingCoordinator* scrollingCoordinator)
     : m_scrollingCoordinator(scrollingCoordinator)
 {
 }
@@ -120,6 +120,11 @@ void ThreadedScrollingTree::handleWheelEventPhase(PlatformWheelEventPhase phase)
 }
 #endif
 
+PassOwnPtr<ScrollingTreeNode> ThreadedScrollingTree::createNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
+{
+    return m_scrollingCoordinator->createScrollingTreeNode(nodeType, nodeID);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)
index a903a84..f8813be 100644 (file)
 
 namespace WebCore {
 
+class AsyncScrollingCoordinator;
+
 // The ThreadedScrollingTree class lives almost exclusively on the scrolling thread and manages the
 // hierarchy of scrollable regions on the page. It's also responsible for dispatching events
 // to the correct scrolling tree nodes or dispatching events back to the ScrollingCoordinator
 // object on the main thread if they can't be handled on the scrolling thread for various reasons.
 class ThreadedScrollingTree : public ScrollingTree {
 public:
-    static RefPtr<ThreadedScrollingTree> create(ScrollingCoordinator*);
+    static RefPtr<ThreadedScrollingTree> create(AsyncScrollingCoordinator*);
 
     virtual ~ThreadedScrollingTree();
 
@@ -59,14 +61,16 @@ public:
     virtual void invalidate() OVERRIDE;
 
 private:
-    explicit ThreadedScrollingTree(ScrollingCoordinator*);
+    explicit ThreadedScrollingTree(AsyncScrollingCoordinator*);
+
+    virtual PassOwnPtr<ScrollingTreeNode> createNode(ScrollingNodeType, ScrollingNodeID) OVERRIDE;
 
     virtual void updateMainFrameScrollPosition(const IntPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) OVERRIDE;
 #if PLATFORM(MAC)
     virtual void handleWheelEventPhase(PlatformWheelEventPhase) OVERRIDE;
 #endif
 
-    RefPtr<ScrollingCoordinator> m_scrollingCoordinator;
+    RefPtr<AsyncScrollingCoordinator> m_scrollingCoordinator;
 };
 
 SCROLLING_TREE_TYPE_CASTS(ThreadedScrollingTree, isThreadedScrollingTree());
index 157eed9..e48a8fd 100644 (file)
@@ -51,6 +51,7 @@ public:
     virtual bool handleWheelEvent(FrameView*, const PlatformWheelEvent&) OVERRIDE;
 
 private:
+    virtual PassOwnPtr<ScrollingTreeNode> createScrollingTreeNode(ScrollingNodeType, ScrollingNodeID) OVERRIDE;
     virtual void scheduleTreeStateCommit() OVERRIDE;
 
     void scrollingStateTreeCommitterTimerFired(Timer<ScrollingCoordinatorMac>*);
index b43921e..7179e51 100644 (file)
@@ -36,6 +36,9 @@
 #include "Region.h"
 #include "ScrollingStateTree.h"
 #include "ScrollingThread.h"
+#include "ScrollingTreeFixedNode.h"
+#include "ScrollingTreeScrollingNodeMac.h"
+#include "ScrollingTreeStickyNode.h"
 #include "ThreadedScrollingTree.h"
 #include "TiledBacking.h"
 #include <wtf/Functional.h>
@@ -135,6 +138,22 @@ void ScrollingCoordinatorMac::updateTiledScrollingIndicator()
     tiledBacking->setScrollingModeIndication(indicatorMode);
 }
 
+PassOwnPtr<ScrollingTreeNode> ScrollingCoordinatorMac::createScrollingTreeNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
+{
+    ASSERT(scrollingTree());
+
+    switch (nodeType) {
+    case ScrollingNode:
+        return ScrollingTreeScrollingNodeMac::create(*scrollingTree(), nodeID);
+    case FixedNode:
+        return ScrollingTreeFixedNode::create(*scrollingTree(), nodeID);
+    case StickyNode:
+        return ScrollingTreeStickyNode::create(*scrollingTree(), nodeID);
+    }
+    return nullptr;
+}
+
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING)
index 026903c..baa9ea3 100644 (file)
@@ -39,10 +39,12 @@ namespace WebCore {
 
 class ScrollingTreeScrollingNodeMac : public ScrollingTreeScrollingNode, private ScrollElasticityControllerClient {
 public:
-    ScrollingTreeScrollingNodeMac(ScrollingTree&, ScrollingNodeID);
+    static PassOwnPtr<ScrollingTreeScrollingNode> create(ScrollingTree&, ScrollingNodeID);
     virtual ~ScrollingTreeScrollingNodeMac();
 
 private:
+    ScrollingTreeScrollingNodeMac(ScrollingTree&, ScrollingNodeID);
+
     // ScrollingTreeNode member functions.
     virtual void updateBeforeChildren(const ScrollingStateNode&) OVERRIDE;
     virtual void updateAfterChildren(const ScrollingStateNode&) OVERRIDE;
index 6983ff2..3b35e35 100644 (file)
@@ -50,7 +50,7 @@ static void logThreadedScrollingMode(unsigned synchronousScrollingReasons);
 static void logWheelEventHandlerCountChanged(unsigned);
 
 
-PassOwnPtr<ScrollingTreeScrollingNode> ScrollingTreeScrollingNode::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
+PassOwnPtr<ScrollingTreeScrollingNode> ScrollingTreeScrollingNodeMac::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
 {
     return adoptPtr(new ScrollingTreeScrollingNodeMac(scrollingTree, nodeID));
 }