Modernize loop code in scrolling tree code
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jun 2014 22:14:46 +0000 (22:14 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Jun 2014 22:14:46 +0000 (22:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133688

Reviewed by Anders Carlsson.

Use new loop syntax for walking children.

* page/scrolling/ScrollingStateNode.cpp:
(WebCore::ScrollingStateNode::cloneAndResetChildren):
(WebCore::ScrollingStateNode::removeChild):
(WebCore::ScrollingStateNode::willBeRemovedFromStateTree):
(WebCore::ScrollingStateNode::dump):
* page/scrolling/ScrollingTreeNode.cpp:
(WebCore::ScrollingTreeNode::removeChild):
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition):

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

Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/ScrollingStateNode.cpp
Source/WebCore/page/scrolling/ScrollingTreeNode.cpp
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

index 139108d..0425be5 100644 (file)
@@ -1,3 +1,22 @@
+2014-06-10  Simon Fraser  <simon.fraser@apple.com>
+
+        Modernize loop code in scrolling tree code
+        https://bugs.webkit.org/show_bug.cgi?id=133688
+
+        Reviewed by Anders Carlsson.
+
+        Use new loop syntax for walking children.
+
+        * page/scrolling/ScrollingStateNode.cpp:
+        (WebCore::ScrollingStateNode::cloneAndResetChildren):
+        (WebCore::ScrollingStateNode::removeChild):
+        (WebCore::ScrollingStateNode::willBeRemovedFromStateTree):
+        (WebCore::ScrollingStateNode::dump):
+        * page/scrolling/ScrollingTreeNode.cpp:
+        (WebCore::ScrollingTreeNode::removeChild):
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition):
+
 2014-06-10  Anders Carlsson  <andersca@apple.com>
 
         Add -[WKWebView evaluateJavaScript:completionHandler:]
index 0b60c5a..a929cf5 100644 (file)
@@ -88,9 +88,8 @@ void ScrollingStateNode::cloneAndResetChildren(ScrollingStateNode& clone, Scroll
     if (!m_children)
         return;
 
-    size_t size = m_children->size();
-    for (size_t i = 0; i < size; ++i)
-        clone.appendChild(m_children->at(i)->cloneAndReset(adoptiveTree));
+    for (auto& child : *m_children)
+        clone.appendChild(child->cloneAndReset(adoptiveTree));
 }
 
 void ScrollingStateNode::appendChild(PassOwnPtr<ScrollingStateNode> childNode)
@@ -118,9 +117,8 @@ void ScrollingStateNode::removeChild(ScrollingStateNode* node)
         return;
     }
 
-    size_t size = m_children->size();
-    for (size_t i = 0; i < size; ++i)
-        m_children->at(i)->removeChild(node);
+    for (auto& child : *m_children)
+        child->removeChild(node);
 }
 
 void ScrollingStateNode::willBeRemovedFromStateTree()
@@ -130,9 +128,8 @@ void ScrollingStateNode::willBeRemovedFromStateTree()
     if (!m_children)
         return;
 
-    size_t size = m_children->size();
-    for (size_t i = 0; i < size; ++i)
-        m_children->at(i)->willBeRemovedFromStateTree();
+    for (auto& child : *m_children)
+        child->willBeRemovedFromStateTree();
 }
 
 void ScrollingStateNode::setLayer(const LayerRepresentation& layerRepresentation)
@@ -152,11 +149,10 @@ void ScrollingStateNode::dump(TextStream& ts, int indent) const
 
     if (m_children) {
         writeIndent(ts, indent + 1);
-        size_t size = children()->size();
-        ts << "(children " << size << "\n";
+        ts << "(children " << children()->size() << "\n";
         
-        for (size_t i = 0; i < size; i++)
-            m_children->at(i)->dump(ts, indent + 2);
+        for (auto& child : *m_children)
+            child->dump(ts, indent + 2);
         writeIndent(ts, indent + 1);
         ts << ")\n";
     }
index a7fcf72..a953714 100644 (file)
@@ -68,9 +68,8 @@ void ScrollingTreeNode::removeChild(ScrollingTreeNode* node)
         return;
     }
 
-    size_t size = m_children->size();
-    for (size_t i = 0; i < size; ++i)
-        m_children->at(i)->removeChild(node);
+    for (auto& child : *m_children)
+        child->removeChild(node);
 }
 
 } // namespace WebCore
index e3c18f5..73a1bab 100644 (file)
@@ -411,9 +411,8 @@ void ScrollingTreeFrameScrollingNodeMac::setScrollLayerPosition(const FloatPoint
 
     viewportRect.setLocation(FloatPoint() + scrollOffsetForFixedChildren);
 
-    size_t size = m_children->size();
-    for (size_t i = 0; i < size; ++i)
-        m_children->at(i)->updateLayersAfterAncestorChange(*this, viewportRect, FloatSize());
+    for (auto& child : *m_children)
+        child->updateLayersAfterAncestorChange(*this, viewportRect, FloatSize());
 }
 
 void ScrollingTreeFrameScrollingNodeMac::updateLayersAfterViewportChange(const FloatRect&, double)