Use is<>() / downcast<>() for ScrollingTreeNode subclasses
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 00:15:07 +0000 (00:15 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 00:15:07 +0000 (00:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137451

Reviewed by Tim Horton.

Use is<>() / downcast<>() for ScrollingTreeNode subclasses.

No new tests, no behavior change.

* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::handleWheelEvent):
(WebCore::ScrollingTree::viewportChangedViaDelegatedScrolling):
(WebCore::ScrollingTree::scrollPositionChangedViaDelegatedScrolling):
* page/scrolling/ScrollingTreeFrameScrollingNode.h:
* page/scrolling/ScrollingTreeNode.h:
* page/scrolling/ScrollingTreeOverflowScrollingNode.h:
* page/scrolling/ScrollingTreeScrollingNode.h:
* page/scrolling/mac/ScrollingTreeFixedNode.h:
* page/scrolling/mac/ScrollingTreeStickyNode.h:
* page/scrolling/mac/ScrollingTreeStickyNode.mm:
(WebCore::ScrollingTreeStickyNode::updateLayersAfterAncestorChange):

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

Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h
Source/WebCore/page/scrolling/ScrollingTreeNode.h
Source/WebCore/page/scrolling/ScrollingTreeOverflowScrollingNode.h
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
Source/WebCore/page/scrolling/mac/ScrollingTreeFixedNode.h
Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.h
Source/WebCore/page/scrolling/mac/ScrollingTreeStickyNode.mm

index aed9d42..5183d8b 100644 (file)
@@ -1,3 +1,27 @@
+2014-10-06  Christophe Dumez  <cdumez@apple.com>
+
+        Use is<>() / downcast<>() for ScrollingTreeNode subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137451
+
+        Reviewed by Tim Horton.
+
+        Use is<>() / downcast<>() for ScrollingTreeNode subclasses.
+
+        No new tests, no behavior change.
+
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::handleWheelEvent):
+        (WebCore::ScrollingTree::viewportChangedViaDelegatedScrolling):
+        (WebCore::ScrollingTree::scrollPositionChangedViaDelegatedScrolling):
+        * page/scrolling/ScrollingTreeFrameScrollingNode.h:
+        * page/scrolling/ScrollingTreeNode.h:
+        * page/scrolling/ScrollingTreeOverflowScrollingNode.h:
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+        * page/scrolling/mac/ScrollingTreeFixedNode.h:
+        * page/scrolling/mac/ScrollingTreeStickyNode.h:
+        * page/scrolling/mac/ScrollingTreeStickyNode.mm:
+        (WebCore::ScrollingTreeStickyNode::updateLayersAfterAncestorChange):
+
 2014-10-06  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Addressing post-review comment on r174297.
index 2139693..5ce5834 100644 (file)
@@ -31,6 +31,7 @@
 #include "PlatformWheelEvent.h"
 #include "ScrollingStateTree.h"
 #include "ScrollingTreeNode.h"
+#include "ScrollingTreeOverflowScrollingNode.h"
 #include "ScrollingTreeScrollingNode.h"
 #include <wtf/TemporaryChange.h>
 
@@ -96,32 +97,26 @@ void ScrollingTree::setOrClearLatchedNode(const PlatformWheelEvent& wheelEvent,
 void ScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 {
     if (m_rootNode)
-        toScrollingTreeScrollingNode(m_rootNode.get())->handleWheelEvent(wheelEvent);
+        downcast<ScrollingTreeScrollingNode>(*m_rootNode).handleWheelEvent(wheelEvent);
 }
 
 void ScrollingTree::viewportChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const WebCore::FloatRect& fixedPositionRect, double scale)
 {
     ScrollingTreeNode* node = nodeForID(nodeID);
-    if (!node)
+    if (!is<ScrollingTreeScrollingNode>(node))
         return;
 
-    if (!node->isScrollingNode())
-        return;
-
-    toScrollingTreeScrollingNode(node)->updateLayersAfterViewportChange(fixedPositionRect, scale);
+    downcast<ScrollingTreeScrollingNode>(*node).updateLayersAfterViewportChange(fixedPositionRect, scale);
 }
 
 void ScrollingTree::scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const WebCore::FloatPoint& scrollPosition, bool inUserInteration)
 {
     ScrollingTreeNode* node = nodeForID(nodeID);
-    if (!node)
-        return;
-
-    if (node->nodeType() != OverflowScrollingNode)
+    if (!is<ScrollingTreeOverflowScrollingNode>(node))
         return;
 
     // Update descendant nodes
-    toScrollingTreeScrollingNode(node)->updateLayersAfterDelegatedScroll(scrollPosition);
+    downcast<ScrollingTreeOverflowScrollingNode>(*node).updateLayersAfterDelegatedScroll(scrollPosition);
 
     // Update GraphicsLayers and scroll state.
     scrollingTreeNodeDidScroll(nodeID, scrollPosition, inUserInteration ? SyncScrollingLayerPosition : SetScrollingLayerPosition);
index 52b7917..3544168 100644 (file)
@@ -79,10 +79,10 @@ private:
     ScrollBehaviorForFixedElements m_behaviorForFixed;
 };
 
-SCROLLING_NODE_TYPE_CASTS(ScrollingTreeFrameScrollingNode, isFrameScrollingNode());
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeFrameScrollingNode, isFrameScrollingNode())
+
 #endif // ENABLE(ASYNC_SCROLLING)
 
 #endif // ScrollingTreeScrollingNode_h
index 190bc38..846caae 100644 (file)
@@ -32,6 +32,7 @@
 #include "ScrollTypes.h"
 #include "ScrollingCoordinator.h"
 #include <wtf/RefCounted.h>
+#include <wtf/TypeCasts.h>
 
 namespace WebCore {
 
@@ -81,11 +82,13 @@ private:
     ScrollingTreeNode* m_parent;
 };
 
-#define SCROLLING_NODE_TYPE_CASTS(ToValueTypeName, predicate) \
-    TYPE_CASTS_BASE(ToValueTypeName, ScrollingTreeNode, value, value->predicate, value.predicate)
-
 } // namespace WebCore
 
+#define SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+    static bool isType(const WebCore::ScrollingTreeNode& node) { return node.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif // ENABLE(ASYNC_SCROLLING)
 
 #endif // ScrollingTreeNode_h
index 9451ead..42a4f4b 100644 (file)
@@ -41,10 +41,10 @@ protected:
     WEBCORE_EXPORT ScrollingTreeOverflowScrollingNode(ScrollingTree&, ScrollingNodeID);
 };
 
-SCROLLING_NODE_TYPE_CASTS(ScrollingTreeOverflowScrollingNode, isOverflowScrollingNode());
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeOverflowScrollingNode, isOverflowScrollingNode())
+
 #endif // ENABLE(ASYNC_SCROLLING)
 
 #endif // ScrollingTreeOverflowScrollingNode_h
index 1fbc598..e20ac44 100644 (file)
@@ -104,10 +104,10 @@ private:
     ScrollableAreaParameters m_scrollableAreaParameters;
 };
 
-SCROLLING_NODE_TYPE_CASTS(ScrollingTreeScrollingNode, isScrollingNode());
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeScrollingNode, isScrollingNode())
+
 #endif // ENABLE(ASYNC_SCROLLING)
 
 #endif // ScrollingTreeScrollingNode_h
index 98c1690..576accd 100644 (file)
@@ -54,10 +54,10 @@ private:
     RetainPtr<CALayer> m_layer;
 };
 
-SCROLLING_NODE_TYPE_CASTS(ScrollingTreeFixedNode, isFixedNode());
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeFixedNode, isFixedNode())
+
 #endif // ENABLE(ASYNC_SCROLLING)
 
 #endif // ScrollingTreeFixedNode_h
index a92a31e..e8222de 100644 (file)
@@ -54,10 +54,10 @@ private:
     RetainPtr<CALayer> m_layer;
 };
 
-SCROLLING_NODE_TYPE_CASTS(ScrollingTreeStickyNode, isStickyNode());
-
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeStickyNode, isStickyNode())
+
 #endif // ENABLE(ASYNC_SCROLLING)
 
 #endif // ScrollingTreeStickyNode_h
index 6d7e00e..67c4dbe 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "ScrollingStateStickyNode.h"
 #include "ScrollingTree.h"
+#include "ScrollingTreeFrameScrollingNode.h"
 #include "ScrollingTreeOverflowScrollingNode.h"
 #include <QuartzCore/CALayer.h>
 
@@ -72,10 +73,10 @@ void ScrollingTreeStickyNode::updateLayersAfterAncestorChange(const ScrollingTre
     bool adjustStickyLayer = false;
     FloatRect constrainingRect;
 
-    if (parent()->isOverflowScrollingNode()) {
-        constrainingRect = FloatRect(toScrollingTreeOverflowScrollingNode(parent())->scrollPosition(), m_constraints.constrainingRectAtLastLayout().size());
+    if (is<ScrollingTreeOverflowScrollingNode>(*parent())) {
+        constrainingRect = FloatRect(downcast<ScrollingTreeOverflowScrollingNode>(*parent()).scrollPosition(), m_constraints.constrainingRectAtLastLayout().size());
         adjustStickyLayer = true;
-    } else if (parent()->isFrameScrollingNode()) {
+    } else if (is<ScrollingTreeFrameScrollingNode>(*parent())) {
         constrainingRect = fixedPositionRect;
         adjustStickyLayer = true;
     }