CTTE: Scrolling tree nodes should always have a ScrollingTree&.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2013 02:41:19 +0000 (02:41 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2013 02:41:19 +0000 (02:41 +0000)
<https://webkit.org/b/124022>

Let ScrollingTreeNode and subclasses store the backpointer to the
tree as a ScrollingTree& reference.

Reviewed by Anders Carlsson.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158893 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 1ffdca6..b626c7e 100644 (file)
@@ -1,3 +1,13 @@
+2013-11-07  Andreas Kling  <akling@apple.com>
+
+        CTTE: Scrolling tree nodes should always have a ScrollingTree&.
+        <https://webkit.org/b/124022>
+
+        Let ScrollingTreeNode and subclasses store the backpointer to the
+        tree as a ScrollingTree& reference.
+
+        Reviewed by Anders Carlsson.
+
 2013-11-07  Simon Fraser  <simon.fraser@apple.com>
 
         Lots of layers get solid color but transparent contents layers now
index e2843f4..a7f7295 100644 (file)
@@ -174,18 +174,18 @@ void ScrollingTree::updateTreeFromStateNode(ScrollingStateNode* stateNode)
             // This is the root node. Nuke the node map.
             m_nodeMap.clear();
 
-            m_rootNode = ScrollingTreeScrollingNode::create(this, nodeID);
+            m_rootNode = ScrollingTreeScrollingNode::create(*this, nodeID);
             m_nodeMap.set(nodeID, m_rootNode.get());
             m_rootNode->updateBeforeChildren(stateNode);
             node = m_rootNode.get();
         } else {
             OwnPtr<ScrollingTreeNode> newNode;
             if (stateNode->isScrollingNode())
-                newNode = ScrollingTreeScrollingNode::create(this, nodeID);
+                newNode = ScrollingTreeScrollingNode::create(*this, nodeID);
             else if (stateNode->isFixedNode())
-                newNode = ScrollingTreeFixedNode::create(this, nodeID);
+                newNode = ScrollingTreeFixedNode::create(*this, nodeID);
             else if (stateNode->isStickyNode())
-                newNode = ScrollingTreeStickyNode::create(this, nodeID);
+                newNode = ScrollingTreeStickyNode::create(*this, nodeID);
             else
                 ASSERT_NOT_REACHED();
 
index 0412e05..3705e9b 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-ScrollingTreeNode::ScrollingTreeNode(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+ScrollingTreeNode::ScrollingTreeNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
     : m_scrollingTree(scrollingTree)
     , m_nodeID(nodeID)
     , m_parent(0)
index a526edb..22d6f30 100644 (file)
@@ -41,7 +41,6 @@ class ScrollingStateScrollingNode;
 
 class ScrollingTreeNode {
 public:
-    explicit ScrollingTreeNode(ScrollingTree*, ScrollingNodeID);
     virtual ~ScrollingTreeNode();
 
     virtual void updateBeforeChildren(ScrollingStateNode*) = 0;
@@ -58,13 +57,14 @@ public:
     void removeChild(ScrollingTreeNode*);
 
 protected:
-    ScrollingTree* scrollingTree() const { return m_scrollingTree; }
+    ScrollingTreeNode(ScrollingTree&, ScrollingNodeID);
+    ScrollingTree& scrollingTree() const { return m_scrollingTree; }
 
     typedef Vector<OwnPtr<ScrollingTreeNode>> ScrollingTreeChildrenVector;
     OwnPtr<ScrollingTreeChildrenVector> m_children;
 
 private:
-    ScrollingTree* m_scrollingTree;
+    ScrollingTree& m_scrollingTree;
 
     ScrollingNodeID m_nodeID;
 
index 8da5b70..8ddc801 100644 (file)
@@ -33,7 +33,7 @@
 
 namespace WebCore {
 
-ScrollingTreeScrollingNode::ScrollingTreeScrollingNode(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+ScrollingTreeScrollingNode::ScrollingTreeScrollingNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
     : ScrollingTreeNode(scrollingTree, nodeID)
     , m_frameScaleFactor(1)
     , m_shouldUpdateScrollLayerPositionOnMainThread(0)
@@ -60,7 +60,7 @@ void ScrollingTreeScrollingNode::updateBeforeChildren(ScrollingStateNode* stateN
         m_viewportRect = state->viewportRect();
 
     if (state->hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) {
-        if (scrollingTree()->isRubberBandInProgress())
+        if (scrollingTree().isRubberBandInProgress())
             m_totalContentsSizeForRubberBand = m_totalContentsSize;
         else
             m_totalContentsSizeForRubberBand = state->totalContentsSize();
index eaf36cc..a33d648 100644 (file)
@@ -42,7 +42,7 @@ class ScrollingStateScrollingNode;
 
 class ScrollingTreeScrollingNode : public ScrollingTreeNode {
 public:
-    static PassOwnPtr<ScrollingTreeScrollingNode> create(ScrollingTree*, ScrollingNodeID);
+    static PassOwnPtr<ScrollingTreeScrollingNode> create(ScrollingTree&, ScrollingNodeID);
     virtual ~ScrollingTreeScrollingNode();
 
     virtual void updateBeforeChildren(ScrollingStateNode*) OVERRIDE;
@@ -56,7 +56,7 @@ public:
     MainThreadScrollingReasons shouldUpdateScrollLayerPositionOnMainThread() const { return m_shouldUpdateScrollLayerPositionOnMainThread; }
 
 protected:
-    explicit ScrollingTreeScrollingNode(ScrollingTree*, ScrollingNodeID);
+    ScrollingTreeScrollingNode(ScrollingTree&, ScrollingNodeID);
 
     const IntRect& viewportRect() const { return m_viewportRect; }
     const IntSize& totalContentsSize() const { return m_totalContentsSize; }
index 4057e55..17f6b56 100644 (file)
@@ -40,12 +40,12 @@ class FixedPositionViewportConstraints;
 
 class ScrollingTreeFixedNode : public ScrollingTreeNode {
 public:
-    static PassOwnPtr<ScrollingTreeFixedNode> create(ScrollingTree*, ScrollingNodeID);
+    static PassOwnPtr<ScrollingTreeFixedNode> create(ScrollingTree&, ScrollingNodeID);
 
     virtual ~ScrollingTreeFixedNode();
 
 private:
-    ScrollingTreeFixedNode(ScrollingTree*, ScrollingNodeID);
+    ScrollingTreeFixedNode(ScrollingTree&, ScrollingNodeID);
 
     virtual void updateBeforeChildren(ScrollingStateNode*) OVERRIDE;
     virtual void parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta) OVERRIDE;
index d9e4ce5..83fa625 100644 (file)
 
 namespace WebCore {
 
-PassOwnPtr<ScrollingTreeFixedNode> ScrollingTreeFixedNode::create(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+PassOwnPtr<ScrollingTreeFixedNode> ScrollingTreeFixedNode::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
 {
     return adoptPtr(new ScrollingTreeFixedNode(scrollingTree, nodeID));
 }
 
-ScrollingTreeFixedNode::ScrollingTreeFixedNode(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+ScrollingTreeFixedNode::ScrollingTreeFixedNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
     : ScrollingTreeNode(scrollingTree, nodeID)
 {
 }
index 67e2e84..166ddd0 100644 (file)
@@ -39,7 +39,7 @@ namespace WebCore {
 
 class ScrollingTreeScrollingNodeMac : public ScrollingTreeScrollingNode, private ScrollElasticityControllerClient {
 public:
-    explicit ScrollingTreeScrollingNodeMac(ScrollingTree*, ScrollingNodeID);
+    ScrollingTreeScrollingNodeMac(ScrollingTree&, ScrollingNodeID);
     virtual ~ScrollingTreeScrollingNodeMac();
 
 private:
index 54c4a3d..330fa4a 100644 (file)
@@ -50,12 +50,12 @@ static void logThreadedScrollingMode(unsigned mainThreadScrollingReasons);
 static void logWheelEventHandlerCountChanged(unsigned);
 
 
-PassOwnPtr<ScrollingTreeScrollingNode> ScrollingTreeScrollingNode::create(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+PassOwnPtr<ScrollingTreeScrollingNode> ScrollingTreeScrollingNode::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
 {
     return adoptPtr(new ScrollingTreeScrollingNodeMac(scrollingTree, nodeID));
 }
 
-ScrollingTreeScrollingNodeMac::ScrollingTreeScrollingNodeMac(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+ScrollingTreeScrollingNodeMac::ScrollingTreeScrollingNodeMac(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
     : ScrollingTreeScrollingNode(scrollingTree, nodeID)
     , m_scrollElasticityController(this)
     , m_verticalScrollbarPainter(0)
@@ -106,12 +106,12 @@ void ScrollingTreeScrollingNodeMac::updateBeforeChildren(ScrollingStateNode* sta
             }
         }
 
-        if (scrollingTree()->scrollingPerformanceLoggingEnabled())
+        if (scrollingTree().scrollingPerformanceLoggingEnabled())
             logThreadedScrollingMode(mainThreadScrollingReasons);
     }
 
     if (scrollingStateNode->hasChangedProperty(ScrollingStateScrollingNode::WheelEventHandlerCount)) {
-        if (scrollingTree()->scrollingPerformanceLoggingEnabled())
+        if (scrollingTree().scrollingPerformanceLoggingEnabled())
             logWheelEventHandlerCountChanged(scrollingStateNode->wheelEventHandlerCount());
     }
 }
@@ -136,7 +136,7 @@ void ScrollingTreeScrollingNodeMac::handleWheelEvent(const PlatformWheelEvent& w
         return;
 
     m_scrollElasticityController.handleWheelEvent(wheelEvent);
-    scrollingTree()->handleWheelEventPhase(wheelEvent.phase());
+    scrollingTree().handleWheelEventPhase(wheelEvent.phase());
 }
 
 bool ScrollingTreeScrollingNodeMac::allowsHorizontalStretching()
@@ -183,11 +183,11 @@ IntSize ScrollingTreeScrollingNodeMac::stretchAmount()
     else if (scrollPosition().x() > maximumScrollPosition().x())
         stretch.setWidth(scrollPosition().x() - maximumScrollPosition().x());
 
-    if (scrollingTree()->rootNode() == this) {
+    if (scrollingTree().rootNode() == this) {
         if (stretch.isZero())
-            scrollingTree()->setMainFrameIsRubberBanding(false);
+            scrollingTree().setMainFrameIsRubberBanding(false);
         else
-            scrollingTree()->setMainFrameIsRubberBanding(true);
+            scrollingTree().setMainFrameIsRubberBanding(true);
     }
 
     return stretch;
@@ -268,7 +268,7 @@ void ScrollingTreeScrollingNodeMac::stopSnapRubberbandTimer()
     if (!m_snapRubberbandTimer)
         return;
 
-    scrollingTree()->setMainFrameIsRubberBanding(false);
+    scrollingTree().setMainFrameIsRubberBanding(false);
 
     // Since the rubberband timer has stopped, totalContentsSizeForRubberBand can be synchronized with totalContentsSize.
     setTotalContentsSizeForRubberBand(totalContentsSize());
@@ -294,7 +294,7 @@ void ScrollingTreeScrollingNodeMac::setScrollPosition(const IntPoint& scrollPosi
 
     setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
 
-    if (scrollingTree()->scrollingPerformanceLoggingEnabled())
+    if (scrollingTree().scrollingPerformanceLoggingEnabled())
         logExposedUnfilledArea();
 }
 
@@ -304,12 +304,12 @@ void ScrollingTreeScrollingNodeMac::setScrollPositionWithoutContentEdgeConstrain
 
     if (shouldUpdateScrollLayerPositionOnMainThread()) {
         m_probableMainThreadScrollPosition = scrollPosition;
-        scrollingTree()->updateMainFrameScrollPosition(scrollPosition, SetScrollingLayerPosition);
+        scrollingTree().updateMainFrameScrollPosition(scrollPosition, SetScrollingLayerPosition);
         return;
     }
 
     setScrollLayerPosition(scrollPosition);
-    scrollingTree()->updateMainFrameScrollPosition(scrollPosition);
+    scrollingTree().updateMainFrameScrollPosition(scrollPosition);
 }
 
 void ScrollingTreeScrollingNodeMac::setScrollLayerPosition(const IntPoint& position)
@@ -374,7 +374,7 @@ IntPoint ScrollingTreeScrollingNodeMac::minimumScrollPosition() const
 {
     IntPoint position;
     
-    if (scrollingTree()->rootNode() == this && scrollingTree()->scrollPinningBehavior() == PinToBottom)
+    if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToBottom)
         position.setY(maximumScrollPosition().y());
 
     return position;
@@ -387,7 +387,7 @@ IntPoint ScrollingTreeScrollingNodeMac::maximumScrollPosition() const
 
     position.clampNegativeToZero();
 
-    if (scrollingTree()->rootNode() == this && scrollingTree()->scrollPinningBehavior() == PinToTop)
+    if (scrollingTree().rootNode() == this && scrollingTree().scrollPinningBehavior() == PinToTop)
         position.setY(minimumScrollPosition().y());
 
     return position;
@@ -410,7 +410,7 @@ void ScrollingTreeScrollingNodeMac::updateMainFramePinState(const IntPoint& scro
     bool pinnedToTheTop = scrollPosition.y() <= minimumScrollPosition().y();
     bool pinnedToTheBottom = scrollPosition.y() >= maximumScrollPosition().y();
 
-    scrollingTree()->setMainFramePinState(pinnedToTheLeft, pinnedToTheRight, pinnedToTheTop, pinnedToTheBottom);
+    scrollingTree().setMainFramePinState(pinnedToTheLeft, pinnedToTheRight, pinnedToTheTop, pinnedToTheBottom);
 }
 
 void ScrollingTreeScrollingNodeMac::logExposedUnfilledArea()
index f56008f..f70814a 100644 (file)
@@ -40,12 +40,12 @@ class StickyPositionViewportConstraints;
 
 class ScrollingTreeStickyNode : public ScrollingTreeNode {
 public:
-    static PassOwnPtr<ScrollingTreeStickyNode> create(ScrollingTree*, ScrollingNodeID);
+    static PassOwnPtr<ScrollingTreeStickyNode> create(ScrollingTree&, ScrollingNodeID);
 
     virtual ~ScrollingTreeStickyNode();
 
 private:
-    ScrollingTreeStickyNode(ScrollingTree*, ScrollingNodeID);
+    ScrollingTreeStickyNode(ScrollingTree&, ScrollingNodeID);
 
     virtual void updateBeforeChildren(ScrollingStateNode*) OVERRIDE;
     virtual void parentScrollPositionDidChange(const IntRect& viewportRect, const FloatSize& cumulativeDelta) OVERRIDE;
index 20f8474..de6c90c 100644 (file)
 
 namespace WebCore {
 
-PassOwnPtr<ScrollingTreeStickyNode> ScrollingTreeStickyNode::create(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+PassOwnPtr<ScrollingTreeStickyNode> ScrollingTreeStickyNode::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
 {
     return adoptPtr(new ScrollingTreeStickyNode(scrollingTree, nodeID));
 }
 
-ScrollingTreeStickyNode::ScrollingTreeStickyNode(ScrollingTree* scrollingTree, ScrollingNodeID nodeID)
+ScrollingTreeStickyNode::ScrollingTreeStickyNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
     : ScrollingTreeNode(scrollingTree, nodeID)
 {
 }