Title: [161190] trunk/Source/WebCore
Revision
161190
Author
[email protected]
Date
2014-01-01 10:14:27 -0800 (Wed, 01 Jan 2014)

Log Message

Give ScrollingStateNodes a nodeType()
https://bugs.webkit.org/show_bug.cgi?id=126347

Reviewed by Tim Horton.

When we start serializing ScrollingStateNodes to send to the UI process,
it's more convenient if they have a nodeType member rather than virtual functions,
so give them one, and fix the casting macros to use it. This allows us to use
a switch() on node creation, so the compiler will tell us if we forgot to create
a node type.

* page/scrolling/ScrollingStateFixedNode.cpp:
(WebCore::ScrollingStateFixedNode::ScrollingStateFixedNode):
* page/scrolling/ScrollingStateFixedNode.h:
* page/scrolling/ScrollingStateNode.cpp:
(WebCore::ScrollingStateNode::ScrollingStateNode):
* page/scrolling/ScrollingStateNode.h: const ScrollingNodeType field
(can't be modified after construction), and move the m_scrollingStateTree
member after it (the awkward protected:/private: will be cleaned up in a later patch).
(WebCore::ScrollingStateNode::nodeType):
* page/scrolling/ScrollingStateScrollingNode.cpp:
(WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
* page/scrolling/ScrollingStateScrollingNode.h:
* page/scrolling/ScrollingStateStickyNode.cpp:
(WebCore::ScrollingStateStickyNode::ScrollingStateStickyNode):
* page/scrolling/ScrollingStateStickyNode.h:
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::updateTreeFromStateNode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (161189 => 161190)


--- trunk/Source/WebCore/ChangeLog	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/ChangeLog	2014-01-01 18:14:27 UTC (rev 161190)
@@ -1,3 +1,34 @@
+2013-12-31  Simon Fraser  <[email protected]>
+
+        Give ScrollingStateNodes a nodeType()
+        https://bugs.webkit.org/show_bug.cgi?id=126347
+
+        Reviewed by Tim Horton.
+
+        When we start serializing ScrollingStateNodes to send to the UI process,
+        it's more convenient if they have a nodeType member rather than virtual functions,
+        so give them one, and fix the casting macros to use it. This allows us to use
+        a switch() on node creation, so the compiler will tell us if we forgot to create
+        a node type.
+
+        * page/scrolling/ScrollingStateFixedNode.cpp:
+        (WebCore::ScrollingStateFixedNode::ScrollingStateFixedNode):
+        * page/scrolling/ScrollingStateFixedNode.h:
+        * page/scrolling/ScrollingStateNode.cpp:
+        (WebCore::ScrollingStateNode::ScrollingStateNode):
+        * page/scrolling/ScrollingStateNode.h: const ScrollingNodeType field
+        (can't be modified after construction), and move the m_scrollingStateTree
+        member after it (the awkward protected:/private: will be cleaned up in a later patch).
+        (WebCore::ScrollingStateNode::nodeType):
+        * page/scrolling/ScrollingStateScrollingNode.cpp:
+        (WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
+        * page/scrolling/ScrollingStateScrollingNode.h:
+        * page/scrolling/ScrollingStateStickyNode.cpp:
+        (WebCore::ScrollingStateStickyNode::ScrollingStateStickyNode):
+        * page/scrolling/ScrollingStateStickyNode.h:
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::updateTreeFromStateNode):
+
 2013-12-31  Andreas Kling  <[email protected]>
 
         Out-of-line RenderStyle substructure copying helpers.

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp	2014-01-01 18:14:27 UTC (rev 161190)
@@ -41,7 +41,7 @@
 }
 
 ScrollingStateFixedNode::ScrollingStateFixedNode(ScrollingStateTree* tree, ScrollingNodeID nodeID)
-    : ScrollingStateNode(tree, nodeID)
+    : ScrollingStateNode(FixedNode, tree, nodeID)
 {
 }
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h	2014-01-01 18:14:27 UTC (rev 161190)
@@ -56,8 +56,6 @@
     ScrollingStateFixedNode(ScrollingStateTree*, ScrollingNodeID);
     ScrollingStateFixedNode(const ScrollingStateFixedNode&);
 
-    virtual bool isFixedNode() const OVERRIDE { return true; }
-
     virtual void syncLayerPositionForViewportRect(const LayoutRect& viewportRect) OVERRIDE;
 
     virtual void dumpProperties(TextStream&, int indent) const OVERRIDE;
@@ -65,7 +63,7 @@
     FixedPositionViewportConstraints m_constraints;
 };
 
-SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateFixedNode, isFixedNode());
+SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateFixedNode, nodeType() == FixedNode);
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.cpp	2014-01-01 18:14:27 UTC (rev 161190)
@@ -36,10 +36,11 @@
 
 namespace WebCore {
 
-ScrollingStateNode::ScrollingStateNode(ScrollingStateTree* scrollingStateTree, ScrollingNodeID nodeID)
-    : m_scrollingStateTree(scrollingStateTree)
+ScrollingStateNode::ScrollingStateNode(ScrollingNodeType nodeType, ScrollingStateTree* scrollingStateTree, ScrollingNodeID nodeID)
+    : m_nodeType(nodeType)
     , m_nodeID(nodeID)
     , m_changedProperties(0)
+    , m_scrollingStateTree(scrollingStateTree)
     , m_parent(0)
 {
 }
@@ -48,9 +49,10 @@
 // to clone the relationship pointers, so don't copy that information from the original
 // node.
 ScrollingStateNode::ScrollingStateNode(const ScrollingStateNode& stateNode)
-    : m_scrollingStateTree(0)
+    : m_nodeType(stateNode.nodeType())
     , m_nodeID(stateNode.scrollingNodeID())
     , m_changedProperties(stateNode.changedProperties())
+    , m_scrollingStateTree(0)
     , m_parent(0)
 {
     // FIXME: why doesn't this set the GraphicsLayer?

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateNode.h	2014-01-01 18:14:27 UTC (rev 161190)
@@ -46,13 +46,11 @@
 
 class ScrollingStateNode {
 public:
-    ScrollingStateNode(ScrollingStateTree*, ScrollingNodeID);
+    ScrollingStateNode(ScrollingNodeType, ScrollingStateTree*, ScrollingNodeID);
     virtual ~ScrollingStateNode();
+    
+    ScrollingNodeType nodeType() const { return m_nodeType; }
 
-    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();
     void cloneAndResetChildren(ScrollingStateNode*);
@@ -93,8 +91,6 @@
 protected:
     ScrollingStateNode(const ScrollingStateNode&);
 
-    ScrollingStateTree* m_scrollingStateTree;
-
 private:
     void dump(TextStream&, int indent) const;
 
@@ -102,9 +98,14 @@
     ChangedProperties changedProperties() const { return m_changedProperties; }
     void willBeRemovedFromStateTree();
 
+    const ScrollingNodeType m_nodeType;
     ScrollingNodeID m_nodeID;
     ChangedProperties m_changedProperties;
 
+protected:
+    ScrollingStateTree* m_scrollingStateTree; // FIXME: this should be a reference.
+
+private:
     ScrollingStateNode* m_parent;
     OwnPtr<Vector<OwnPtr<ScrollingStateNode>>> m_children;
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp	2014-01-01 18:14:27 UTC (rev 161190)
@@ -40,7 +40,7 @@
 }
 
 ScrollingStateScrollingNode::ScrollingStateScrollingNode(ScrollingStateTree* stateTree, ScrollingNodeID nodeID)
-    : ScrollingStateNode(stateTree, nodeID)
+    : ScrollingStateNode(ScrollingNode, stateTree, nodeID)
     , m_counterScrollingLayer(0)
     , m_headerLayer(0)
     , m_footerLayer(0)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h	2014-01-01 18:14:27 UTC (rev 161190)
@@ -132,8 +132,6 @@
     ScrollingStateScrollingNode(ScrollingStateTree*, ScrollingNodeID);
     ScrollingStateScrollingNode(const ScrollingStateScrollingNode&);
 
-    virtual bool isScrollingNode() const OVERRIDE { return true; }
-
     GraphicsLayer* m_counterScrollingLayer;
     GraphicsLayer* m_headerLayer;
     GraphicsLayer* m_footerLayer;
@@ -161,7 +159,7 @@
     bool m_requestedScrollPositionRepresentsProgrammaticScroll;
 };
 
-SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateScrollingNode, isScrollingNode());
+SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateScrollingNode, nodeType() == ScrollingNode);
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp	2014-01-01 18:14:27 UTC (rev 161190)
@@ -41,7 +41,7 @@
 }
 
 ScrollingStateStickyNode::ScrollingStateStickyNode(ScrollingStateTree* tree, ScrollingNodeID nodeID)
-    : ScrollingStateNode(tree, nodeID)
+    : ScrollingStateNode(StickyNode, tree, nodeID)
 {
 }
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h	2014-01-01 18:14:27 UTC (rev 161190)
@@ -56,8 +56,6 @@
     ScrollingStateStickyNode(ScrollingStateTree*, ScrollingNodeID);
     ScrollingStateStickyNode(const ScrollingStateStickyNode&);
 
-    virtual bool isStickyNode() const OVERRIDE { return true; }
-
     virtual void syncLayerPositionForViewportRect(const LayoutRect& viewportRect) OVERRIDE;
 
     virtual void dumpProperties(TextStream&, int indent) const OVERRIDE;
@@ -65,7 +63,7 @@
     StickyPositionViewportConstraints m_constraints;
 };
 
-SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateStickyNode, isStickyNode());
+SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateStickyNode, nodeType() == StickyNode);
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2014-01-01 18:14:27 UTC (rev 161190)
@@ -180,14 +180,17 @@
             node = m_rootNode.get();
         } else {
             OwnPtr<ScrollingTreeNode> newNode;
-            if (stateNode->isScrollingNode())
+            switch (stateNode->nodeType()) {
+            case ScrollingNode:
                 newNode = ScrollingTreeScrollingNode::create(*this, nodeID);
-            else if (stateNode->isFixedNode())
+                break;
+            case FixedNode:
                 newNode = ScrollingTreeFixedNode::create(*this, nodeID);
-            else if (stateNode->isStickyNode())
+                break;
+            case StickyNode:
                 newNode = ScrollingTreeStickyNode::create(*this, nodeID);
-            else
-                ASSERT_NOT_REACHED();
+                break;
+            }
 
             node = newNode.get();
             m_nodeMap.set(nodeID, node);

Modified: trunk/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp (161189 => 161190)


--- trunk/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp	2014-01-01 15:41:43 UTC (rev 161189)
+++ trunk/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp	2014-01-01 18:14:27 UTC (rev 161190)
@@ -61,7 +61,7 @@
 void ScrollingCoordinatorCoordinatedGraphics::detachFromStateTree(ScrollingNodeID nodeID)
 {
     ScrollingStateNode* node = m_scrollingStateTree->stateNodeForID(nodeID);
-    if (node && node->isFixedNode())
+    if (node && node->nodeType() == FixedNode)
         toCoordinatedGraphicsLayer(node->graphicsLayer())->setFixedToViewport(false);
 
     m_scrollingStateTree->detachNode(nodeID);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to