Title: [159207] trunk/Source/WebCore
Revision
159207
Author
[email protected]
Date
2013-11-13 10:17:40 -0800 (Wed, 13 Nov 2013)

Log Message

Generate casting helpers for scrolling tree classes.
<https://webkit.org/b/124286>

Added SCROLLING_STATE_NODE_TYPE_CASTS and used it to replace the
hand-written toFoo() casts for ScrollingStateNode subclasses.

Reviewed by Anders Carlsson.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (159206 => 159207)


--- trunk/Source/WebCore/ChangeLog	2013-11-13 17:59:33 UTC (rev 159206)
+++ trunk/Source/WebCore/ChangeLog	2013-11-13 18:17:40 UTC (rev 159207)
@@ -1,3 +1,13 @@
+2013-11-13  Andreas Kling  <[email protected]>
+
+        Generate casting helpers for scrolling tree classes.
+        <https://webkit.org/b/124286>
+
+        Added SCROLLING_STATE_NODE_TYPE_CASTS and used it to replace the
+        hand-written toFoo() casts for ScrollingStateNode subclasses.
+
+        Reviewed by Anders Carlsson.
+
 2013-11-13  Hans Muller  <[email protected]>
 
         [CSS Shapes] Determining if a line is inside of a shape should only happen in one place

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h (159206 => 159207)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h	2013-11-13 17:59:33 UTC (rev 159206)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h	2013-11-13 18:17:40 UTC (rev 159207)
@@ -37,7 +37,7 @@
 
 class FixedPositionViewportConstraints;
 
-class ScrollingStateFixedNode : public ScrollingStateNode {
+class ScrollingStateFixedNode FINAL : public ScrollingStateNode {
 public:
     static PassOwnPtr<ScrollingStateFixedNode> create(ScrollingStateTree*, ScrollingNodeID);
 
@@ -56,7 +56,7 @@
     ScrollingStateFixedNode(ScrollingStateTree*, ScrollingNodeID);
     ScrollingStateFixedNode(const ScrollingStateFixedNode&);
 
-    virtual bool isFixedNode() OVERRIDE { return true; }
+    virtual bool isFixedNode() const OVERRIDE { return true; }
 
     virtual void syncLayerPositionForViewportRect(const LayoutRect& viewportRect) OVERRIDE;
 
@@ -65,14 +65,7 @@
     FixedPositionViewportConstraints m_constraints;
 };
 
-inline ScrollingStateFixedNode* toScrollingStateFixedNode(ScrollingStateNode* node)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isFixedNode());
-    return static_cast<ScrollingStateFixedNode*>(node);
-}
-    
-// This will catch anyone doing an unnecessary cast.
-void toScrollingStateFixedNode(const ScrollingStateFixedNode*);
+SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateFixedNode, isFixedNode());
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h (159206 => 159207)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h	2013-11-13 17:59:33 UTC (rev 159206)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h	2013-11-13 18:17:40 UTC (rev 159207)
@@ -49,9 +49,9 @@
     ScrollingStateNode(ScrollingStateTree*, ScrollingNodeID);
     virtual ~ScrollingStateNode();
 
-    virtual bool isScrollingNode() { return false; }
-    virtual bool isFixedNode() { return false; }
-    virtual bool isStickyNode() { return false; }
+    virtual bool isScrollingNode() const { return false; }
+    virtual bool isFixedNode() const { return false; }
+    virtual bool isStickyNode() const { return false; }
 
     virtual PassOwnPtr<ScrollingStateNode> clone() = 0;
     PassOwnPtr<ScrollingStateNode> cloneAndReset();
@@ -112,9 +112,11 @@
     RetainPtr<PlatformLayer> m_platformScrollLayer;
 #endif
     GraphicsLayer* m_graphicsLayer;
-
 };
 
+#define SCROLLING_STATE_NODE_TYPE_CASTS(ToValueTypeName, predicate) \
+    TYPE_CASTS_BASE(ToValueTypeName, ScrollingStateNode, value, value->predicate, value.predicate)
+
 } // namespace WebCore
 
 #endif // ENABLE(THREADED_SCROLLING) || USE(COORDINATED_GRAPHICS)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h (159206 => 159207)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h	2013-11-13 17:59:33 UTC (rev 159206)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h	2013-11-13 18:17:40 UTC (rev 159207)
@@ -40,7 +40,7 @@
 
 class Scrollbar;
 
-class ScrollingStateScrollingNode : public ScrollingStateNode {
+class ScrollingStateScrollingNode FINAL : public ScrollingStateNode {
 public:
     static PassOwnPtr<ScrollingStateScrollingNode> create(ScrollingStateTree*, ScrollingNodeID);
 
@@ -71,8 +71,6 @@
         PainterForScrollbar
     };
 
-    virtual bool isScrollingNode() OVERRIDE { return true; }
-
     const IntRect& viewportRect() const { return m_viewportRect; }
     void setViewportRect(const IntRect&);
 
@@ -150,6 +148,8 @@
     ScrollingStateScrollingNode(ScrollingStateTree*, ScrollingNodeID);
     ScrollingStateScrollingNode(const ScrollingStateScrollingNode&);
 
+    virtual bool isScrollingNode() const OVERRIDE { return true; }
+
     GraphicsLayer* m_counterScrollingLayer;
     GraphicsLayer* m_headerLayer;
     GraphicsLayer* m_footerLayer;
@@ -189,14 +189,7 @@
     int m_footerHeight;
 };
 
-inline ScrollingStateScrollingNode* toScrollingStateScrollingNode(ScrollingStateNode* node)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isScrollingNode());
-    return static_cast<ScrollingStateScrollingNode*>(node);
-}
-    
-// This will catch anyone doing an unnecessary cast.
-void toScrollingStateScrollingNode(const ScrollingStateScrollingNode*);
+SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateScrollingNode, isScrollingNode());
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h (159206 => 159207)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h	2013-11-13 17:59:33 UTC (rev 159206)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h	2013-11-13 18:17:40 UTC (rev 159207)
@@ -37,7 +37,7 @@
 
 class StickyPositionViewportConstraints;
 
-class ScrollingStateStickyNode : public ScrollingStateNode {
+class ScrollingStateStickyNode FINAL : public ScrollingStateNode {
 public:
     static PassOwnPtr<ScrollingStateStickyNode> create(ScrollingStateTree*, ScrollingNodeID);
 
@@ -56,7 +56,7 @@
     ScrollingStateStickyNode(ScrollingStateTree*, ScrollingNodeID);
     ScrollingStateStickyNode(const ScrollingStateStickyNode&);
 
-    virtual bool isStickyNode() OVERRIDE { return true; }
+    virtual bool isStickyNode() const OVERRIDE { return true; }
 
     virtual void syncLayerPositionForViewportRect(const LayoutRect& viewportRect) OVERRIDE;
 
@@ -65,14 +65,7 @@
     StickyPositionViewportConstraints m_constraints;
 };
 
-inline ScrollingStateStickyNode* toScrollingStateStickyNode(ScrollingStateNode* node)
-{
-    ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isStickyNode());
-    return static_cast<ScrollingStateStickyNode*>(node);
-}
-    
-// This will catch anyone doing an unnecessary cast.
-void toScrollingStateStickyNode(const ScrollingStateStickyNode*);
+SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateStickyNode, isStickyNode());
 
 } // namespace WebCore
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to