Fixed and sticky nodes have no nodeID set
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Feb 2013 21:03:16 +0000 (21:03 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Feb 2013 21:03:16 +0000 (21:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108734

Reviewed by Sam Weinig.

Push ScrollingNodeIDs onto scrolling nodes at construction time, and thereafter
treat them as readonly. Previously, only the root scrolling node would have a node ID.

Node IDs aren't actually used by the scrolling tree yet, but are useful for debugging.

Not testable since we only dump the scrolling state tree, not the scrolling
node tree in tests.

* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::ScrollingTree): No longer create the root node here;
we can only create it when we know what its ID will be.
(WebCore::ScrollingTree::updateTreeFromStateNode): Create the root node if
necessary. Pass node IDs into create methods.
* page/scrolling/ScrollingTreeNode.cpp:
(WebCore::ScrollingTreeNode::ScrollingTreeNode):
* page/scrolling/ScrollingTreeNode.h:
* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::ScrollingTreeScrollingNode):
* page/scrolling/ScrollingTreeScrollingNode.h:
* page/scrolling/mac/ScrollingTreeFixedNode.h:
* page/scrolling/mac/ScrollingTreeFixedNode.mm:
(WebCore::ScrollingTreeFixedNode::create):
(WebCore::ScrollingTreeFixedNode::ScrollingTreeFixedNode):
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.h:
* page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
(WebCore::ScrollingTreeScrollingNode::create):
(WebCore::ScrollingTreeScrollingNodeMac::ScrollingTreeScrollingNodeMac):
* page/scrolling/mac/ScrollingTreeStickyNode.h:
* page/scrolling/mac/ScrollingTreeStickyNode.mm:
(WebCore::ScrollingTreeStickyNode::create):
(WebCore::ScrollingTreeStickyNode::ScrollingTreeStickyNode):

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/ScrollingTree.cpp
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/mac/ScrollingTreeFixedNode.h
Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.h
Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm
Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.h
Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.mm

index dd33262..31091f4 100644 (file)
@@ -1,3 +1,42 @@
+2013-02-02  Simon Fraser  <simon.fraser@apple.com>
+
+        Fixed and sticky nodes have no nodeID set
+        https://bugs.webkit.org/show_bug.cgi?id=108734
+
+        Reviewed by Sam Weinig.
+        
+        Push ScrollingNodeIDs onto scrolling nodes at construction time, and thereafter
+        treat them as readonly. Previously, only the root scrolling node would have a node ID.
+        
+        Node IDs aren't actually used by the scrolling tree yet, but are useful for debugging.
+
+        Not testable since we only dump the scrolling state tree, not the scrolling
+        node tree in tests.
+
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::ScrollingTree): No longer create the root node here;
+        we can only create it when we know what its ID will be.
+        (WebCore::ScrollingTree::updateTreeFromStateNode): Create the root node if
+        necessary. Pass node IDs into create methods.
+        * page/scrolling/ScrollingTreeNode.cpp:
+        (WebCore::ScrollingTreeNode::ScrollingTreeNode):
+        * page/scrolling/ScrollingTreeNode.h:
+        * page/scrolling/ScrollingTreeScrollingNode.cpp:
+        (WebCore::ScrollingTreeScrollingNode::ScrollingTreeScrollingNode):
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+        * page/scrolling/mac/ScrollingTreeFixedNode.h:
+        * page/scrolling/mac/ScrollingTreeFixedNode.mm:
+        (WebCore::ScrollingTreeFixedNode::create):
+        (WebCore::ScrollingTreeFixedNode::ScrollingTreeFixedNode):
+        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.h:
+        * page/scrolling/mac/ScrollingTreeScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeScrollingNode::create):
+        (WebCore::ScrollingTreeScrollingNodeMac::ScrollingTreeScrollingNodeMac):
+        * page/scrolling/mac/ScrollingTreeStickyNode.h:
+        * page/scrolling/mac/ScrollingTreeStickyNode.mm:
+        (WebCore::ScrollingTreeStickyNode::create):
+        (WebCore::ScrollingTreeStickyNode::ScrollingTreeStickyNode):
+
 2013-02-02  Takashi Sakamoto  <tasak@google.com>
 
         Making -webkit-image-set() the first value of background property causes crash.
index 5267cf3..261d884 100644 (file)
@@ -48,7 +48,6 @@ PassRefPtr<ScrollingTree> ScrollingTree::create(ScrollingCoordinator* scrollingC
 
 ScrollingTree::ScrollingTree(ScrollingCoordinator* scrollingCoordinator)
     : m_scrollingCoordinator(scrollingCoordinator)
-    , m_rootNode(ScrollingTreeScrollingNode::create(this))
     , m_hasWheelEventHandlers(false)
     , m_canGoBack(false)
     , m_canGoForward(false)
@@ -157,24 +156,27 @@ void ScrollingTree::updateTreeFromStateNode(ScrollingStateNode* stateNode)
     } else {
         // If the node isn't found, it's either new and needs to be added to the tree, or there is a new ID for our
         // root node.
+        ScrollingNodeID nodeID = stateNode->scrollingNodeID();
         if (!stateNode->parent()) {
             // This is the root node.
-            m_rootNode->setScrollingNodeID(stateNode->scrollingNodeID());
-            m_nodeMap.set(stateNode->scrollingNodeID(), m_rootNode.get());
+            if (!m_rootNode)
+                m_rootNode = ScrollingTreeScrollingNode::create(this, nodeID);
+
+            m_nodeMap.set(nodeID, m_rootNode.get());
             m_rootNode->update(stateNode);
         } else {
             OwnPtr<ScrollingTreeNode> newNode;
             if (stateNode->isScrollingNode())
-                newNode = ScrollingTreeScrollingNode::create(this);
+                newNode = ScrollingTreeScrollingNode::create(this, nodeID);
             else if (stateNode->isFixedNode())
-                newNode = ScrollingTreeFixedNode::create(this);
+                newNode = ScrollingTreeFixedNode::create(this, nodeID);
             else if (stateNode->isStickyNode())
-                newNode = ScrollingTreeStickyNode::create(this);
+                newNode = ScrollingTreeStickyNode::create(this, nodeID);
             else
                 ASSERT_NOT_REACHED();
 
             ScrollingTreeNode* newNodeRawPtr = newNode.get();
-            m_nodeMap.set(stateNode->scrollingNodeID(), newNodeRawPtr);
+            m_nodeMap.set(nodeID, newNodeRawPtr);
             ScrollingTreeNodeMap::const_iterator it = m_nodeMap.find(stateNode->parent()->scrollingNodeID());
             ASSERT(it != m_nodeMap.end());
             if (it != m_nodeMap.end()) {
index d033925..d810b40 100644 (file)
@@ -32,9 +32,9 @@
 
 namespace WebCore {
 
-ScrollingTreeNode::ScrollingTreeNode(ScrollingTree* scrollingTree)
+ScrollingTreeNode::ScrollingTreeNode(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
     : m_scrollingTree(scrollingTree)
-    , m_nodeID(0)
+    , m_nodeID(nodeID)
     , m_parent(0)
 {
 }
index d2b1190..014244b 100644 (file)
@@ -41,7 +41,7 @@ class ScrollingStateScrollingNode;
 
 class ScrollingTreeNode {
 public:
-    explicit ScrollingTreeNode(ScrollingTree*);
+    explicit ScrollingTreeNode(ScrollingTree*, ScrollingNodeID);
     virtual ~ScrollingTreeNode();
 
     virtual void update(ScrollingStateNode*) = 0;
@@ -49,7 +49,6 @@ public:
     virtual void parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta) = 0;
 
     ScrollingNodeID scrollingNodeID() const { return m_nodeID; }
-    void setScrollingNodeID(ScrollingNodeID nodeID) { m_nodeID = nodeID; }
 
     ScrollingTreeNode* parent() const { return m_parent; }
     void setParent(ScrollingTreeNode* parent) { m_parent = parent; }
index 7e60803..125ca71 100644 (file)
@@ -32,8 +32,8 @@
 
 namespace WebCore {
 
-ScrollingTreeScrollingNode::ScrollingTreeScrollingNode(ScrollingTree* scrollingTree)
-    : ScrollingTreeNode(scrollingTree)
+ScrollingTreeScrollingNode::ScrollingTreeScrollingNode(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+    : ScrollingTreeNode(scrollingTree, nodeID)
     , m_frameScaleFactor(1)
     , m_shouldUpdateScrollLayerPositionOnMainThread(0)
     , m_horizontalScrollElasticity(ScrollElasticityNone)
index a17824a..a6901f9 100644 (file)
@@ -42,7 +42,7 @@ class ScrollingStateScrollingNode;
 
 class ScrollingTreeScrollingNode : public ScrollingTreeNode {
 public:
-    static PassOwnPtr<ScrollingTreeScrollingNode> create(ScrollingTree*);
+    static PassOwnPtr<ScrollingTreeScrollingNode> create(ScrollingTree*, ScrollingNodeID);
     virtual ~ScrollingTreeScrollingNode();
 
     virtual void update(ScrollingStateNode*) OVERRIDE;
@@ -56,7 +56,7 @@ public:
     MainThreadScrollingReasons shouldUpdateScrollLayerPositionOnMainThread() const { return m_shouldUpdateScrollLayerPositionOnMainThread; }
 
 protected:
-    explicit ScrollingTreeScrollingNode(ScrollingTree*);
+    explicit ScrollingTreeScrollingNode(ScrollingTree*, ScrollingNodeID);
 
     const IntRect& viewportRect() const { return m_viewportRect; }
     const IntSize& contentsSize() const { return m_contentsSize; }
index f8256de..7971c5f 100644 (file)
@@ -40,12 +40,12 @@ class FixedPositionViewportConstraints;
 
 class ScrollingTreeFixedNode : public ScrollingTreeNode {
 public:
-    static PassOwnPtr<ScrollingTreeFixedNode> create(ScrollingTree*);
+    static PassOwnPtr<ScrollingTreeFixedNode> create(ScrollingTree*, ScrollingNodeID);
 
     virtual ~ScrollingTreeFixedNode();
 
 private:
-    ScrollingTreeFixedNode(ScrollingTree*);
+    ScrollingTreeFixedNode(ScrollingTree*, ScrollingNodeID);
 
     virtual void update(ScrollingStateNode*) OVERRIDE;
     virtual void parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta) OVERRIDE;
index 423fd30..2e6441f 100644 (file)
 
 namespace WebCore {
 
-PassOwnPtr<ScrollingTreeFixedNode> ScrollingTreeFixedNode::create(ScrollingTree* scrollingTree)
+PassOwnPtr<ScrollingTreeFixedNode> ScrollingTreeFixedNode::create(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
 {
-    return adoptPtr(new ScrollingTreeFixedNode(scrollingTree));
+    return adoptPtr(new ScrollingTreeFixedNode(scrollingTree, nodeID));
 }
 
-ScrollingTreeFixedNode::ScrollingTreeFixedNode(ScrollingTree* scrollingTree)
-    : ScrollingTreeNode(scrollingTree)
+ScrollingTreeFixedNode::ScrollingTreeFixedNode(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+    : ScrollingTreeNode(scrollingTree, nodeID)
 {
 }
 
index fe1c242..1142658 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 
 class ScrollingTreeScrollingNodeMac : public ScrollingTreeScrollingNode, private ScrollElasticityControllerClient {
 public:
-    explicit ScrollingTreeScrollingNodeMac(ScrollingTree*);
+    explicit ScrollingTreeScrollingNodeMac(ScrollingTree*, ScrollingNodeID);
     virtual ~ScrollingTreeScrollingNodeMac();
 
 private:
index 663c734..008c377 100644 (file)
@@ -47,13 +47,13 @@ static void logThreadedScrollingMode(unsigned mainThreadScrollingReasons);
 static void logWheelEventHandlerCountChanged(unsigned);
 
 
-PassOwnPtr<ScrollingTreeScrollingNode> ScrollingTreeScrollingNode::create(ScrollingTree* scrollingTree)
+PassOwnPtr<ScrollingTreeScrollingNode> ScrollingTreeScrollingNode::create(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
 {
-    return adoptPtr(new ScrollingTreeScrollingNodeMac(scrollingTree));
+    return adoptPtr(new ScrollingTreeScrollingNodeMac(scrollingTree, nodeID));
 }
 
-ScrollingTreeScrollingNodeMac::ScrollingTreeScrollingNodeMac(ScrollingTree* scrollingTree)
-    : ScrollingTreeScrollingNode(scrollingTree)
+ScrollingTreeScrollingNodeMac::ScrollingTreeScrollingNodeMac(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+    : ScrollingTreeScrollingNode(scrollingTree, nodeID)
     , m_scrollElasticityController(this)
     , m_lastScrollHadUnfilledPixels(false)
 {
index 4b15243..332b85e 100644 (file)
@@ -40,12 +40,12 @@ class StickyPositionViewportConstraints;
 
 class ScrollingTreeStickyNode : public ScrollingTreeNode {
 public:
-    static PassOwnPtr<ScrollingTreeStickyNode> create(ScrollingTree*);
+    static PassOwnPtr<ScrollingTreeStickyNode> create(ScrollingTree*, ScrollingNodeID);
 
     virtual ~ScrollingTreeStickyNode();
 
 private:
-    ScrollingTreeStickyNode(ScrollingTree*);
+    ScrollingTreeStickyNode(ScrollingTree*, ScrollingNodeID);
 
     virtual void update(ScrollingStateNode*) OVERRIDE;
     virtual void parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta) OVERRIDE;
index 0690514..e44bd88 100644 (file)
 
 namespace WebCore {
 
-PassOwnPtr<ScrollingTreeStickyNode> ScrollingTreeStickyNode::create(ScrollingTree* scrollingTree)
+PassOwnPtr<ScrollingTreeStickyNode> ScrollingTreeStickyNode::create(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
 {
-    return adoptPtr(new ScrollingTreeStickyNode(scrollingTree));
+    return adoptPtr(new ScrollingTreeStickyNode(scrollingTree, nodeID));
 }
 
-ScrollingTreeStickyNode::ScrollingTreeStickyNode(ScrollingTree* scrollingTree)
-    : ScrollingTreeNode(scrollingTree)
+ScrollingTreeStickyNode::ScrollingTreeStickyNode(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+    : ScrollingTreeNode(scrollingTree, nodeID)
 {
 }