<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[182108] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/182108">182108</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2015-03-27 22:45:27 -0700 (Fri, 27 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>More modern loops in RenderLayer.cpp
https://bugs.webkit.org/show_bug.cgi?id=143175

Reviewed by Ryosuke Niwa.

Use modern loops in more places in RenderLayer.app.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::update3DTransformedDescendantStatus):
(WebCore::RenderLayer::paint):
(WebCore::performOverlapTests):
(WebCore::RenderLayer::paintFixedLayersInNamedFlows):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::collectFragments):
(WebCore::RenderLayer::updatePaintingInfoForFragments):
(WebCore::RenderLayer::paintTransformedLayerIntoFragments):
(WebCore::RenderLayer::calculateClipRects):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (182107 => 182108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-03-28 05:45:20 UTC (rev 182107)
+++ trunk/Source/WebCore/ChangeLog        2015-03-28 05:45:27 UTC (rev 182108)
</span><span class="lines">@@ -1,5 +1,25 @@
</span><span class="cx"> 2015-03-27  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        More modern loops in RenderLayer.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=143175
+
+        Reviewed by Ryosuke Niwa.
+
+        Use modern loops in more places in RenderLayer.app.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::update3DTransformedDescendantStatus):
+        (WebCore::RenderLayer::paint):
+        (WebCore::performOverlapTests):
+        (WebCore::RenderLayer::paintFixedLayersInNamedFlows):
+        (WebCore::RenderLayer::paintList):
+        (WebCore::RenderLayer::collectFragments):
+        (WebCore::RenderLayer::updatePaintingInfoForFragments):
+        (WebCore::RenderLayer::paintTransformedLayerIntoFragments):
+        (WebCore::RenderLayer::calculateClipRects):
+
+2015-03-27  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
</ins><span class="cx">         nullptr cleanup in RenderLayer
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=143174
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (182107 => 182108)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2015-03-28 05:45:20 UTC (rev 182107)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2015-03-28 05:45:27 UTC (rev 182108)
</span><span class="lines">@@ -1281,14 +1281,14 @@
</span><span class="cx">         // Transformed or preserve-3d descendants can only be in the z-order lists, not
</span><span class="cx">         // in the normal flow list, so we only need to check those.
</span><span class="cx">         if (Vector&lt;RenderLayer*&gt;* positiveZOrderList = posZOrderList()) {
</span><del>-            for (unsigned i = 0; i &lt; positiveZOrderList-&gt;size(); ++i)
-                m_has3DTransformedDescendant |= positiveZOrderList-&gt;at(i)-&gt;update3DTransformedDescendantStatus();
</del><ins>+            for (auto layer : *positiveZOrderList)
+                m_has3DTransformedDescendant |= layer-&gt;update3DTransformedDescendantStatus();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Now check our negative z-index children.
</span><span class="cx">         if (Vector&lt;RenderLayer*&gt;* negativeZOrderList = negZOrderList()) {
</span><del>-            for (unsigned i = 0; i &lt; negativeZOrderList-&gt;size(); ++i)
-                m_has3DTransformedDescendant |= negativeZOrderList-&gt;at(i)-&gt;update3DTransformedDescendantStatus();
</del><ins>+            for (auto layer : *negativeZOrderList)
+                m_has3DTransformedDescendant |= layer-&gt;update3DTransformedDescendantStatus();
</ins><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         m_3DTransformedDescendantStatusDirty = false;
</span><span class="lines">@@ -3743,9 +3743,8 @@
</span><span class="cx">     LayerPaintingInfo paintingInfo(this, enclosingIntRect(damageRect), paintBehavior, subpixelAccumulation, subtreePaintRoot, &amp;overlapTestRequests);
</span><span class="cx">     paintLayer(context, paintingInfo, paintFlags);
</span><span class="cx"> 
</span><del>-    OverlapTestRequestMap::iterator end = overlapTestRequests.end();
-    for (OverlapTestRequestMap::iterator it = overlapTestRequests.begin(); it != end; ++it)
-        it-&gt;key-&gt;setOverlapTestResult(false);
</del><ins>+    for (auto it : overlapTestRequests)
+        it.key-&gt;setOverlapTestResult(false);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayer::paintOverlayScrollbars(GraphicsContext* context, const LayoutRect&amp; damageRect, PaintBehavior paintBehavior, RenderObject* subtreePaintRoot)
</span><span class="lines">@@ -3813,17 +3812,16 @@
</span><span class="cx"> static void performOverlapTests(OverlapTestRequestMap&amp; overlapTestRequests, const RenderLayer* rootLayer, const RenderLayer* layer)
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;OverlapTestRequestClient*&gt; overlappedRequestClients;
</span><del>-    OverlapTestRequestMap::iterator end = overlapTestRequests.end();
</del><span class="cx">     LayoutRect boundingBox = layer-&gt;boundingBox(rootLayer, layer-&gt;offsetFromAncestor(rootLayer));
</span><del>-    for (OverlapTestRequestMap::iterator it = overlapTestRequests.begin(); it != end; ++it) {
-        if (!boundingBox.intersects(it-&gt;value))
</del><ins>+    for (auto it : overlapTestRequests) {
+        if (!boundingBox.intersects(it.value))
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        it-&gt;key-&gt;setOverlapTestResult(true);
-        overlappedRequestClients.append(it-&gt;key);
</del><ins>+        it.key-&gt;setOverlapTestResult(true);
+        overlappedRequestClients.append(it.key);
</ins><span class="cx">     }
</span><del>-    for (size_t i = 0; i &lt; overlappedRequestClients.size(); ++i)
-        overlapTestRequests.remove(overlappedRequestClients[i]);
</del><ins>+    for (auto client : overlappedRequestClients)
+        overlapTestRequests.remove(client);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline bool shouldDoSoftwarePaint(const RenderLayer* layer, bool paintingReflection)
</span><span class="lines">@@ -4177,10 +4175,8 @@
</span><span class="cx">     renderer().view().flowThreadController().collectFixedPositionedLayers(fixedLayers);
</span><span class="cx"> 
</span><span class="cx">     // Paint the layers
</span><del>-    for (size_t i = 0; i &lt; fixedLayers.size(); ++i) {
-        RenderLayer* fixedLayer = fixedLayers.at(i);
</del><ins>+    for (auto fixedLayer : fixedLayers)
</ins><span class="cx">         fixedLayer-&gt;paintLayer(context, paintingInfo, paintFlags);
</span><del>-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPaintingInfo&amp; paintingInfo, PaintLayerFlags paintFlags)
</span><span class="lines">@@ -4400,8 +4396,7 @@
</span><span class="cx">     LayerListMutationDetector mutationChecker(this);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    for (size_t i = 0; i &lt; list-&gt;size(); ++i) {
-        RenderLayer* childLayer = list-&gt;at(i);
</del><ins>+    for (auto childLayer : *list) {
</ins><span class="cx">         if (childLayer-&gt;isFlowThreadCollectingGraphicsLayersUnderRegions())
</span><span class="cx">             continue;
</span><span class="cx">         childLayer-&gt;paintLayer(context, paintingInfo, paintFlags);
</span><span class="lines">@@ -4542,9 +4537,7 @@
</span><span class="cx">         ancestorClipRect.intersect(dirtyRect);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (size_t i = 0; i &lt; fragments.size(); ++i) {
-        LayerFragment&amp; fragment = fragments.at(i);
-        
</del><ins>+    for (auto&amp; fragment : fragments) {
</ins><span class="cx">         // Set our four rects with all clipping applied that was internal to the flow thread.
</span><span class="cx">         fragment.setRects(layerBoundsInFlowThread, backgroundRectInFlowThread, foregroundRectInFlowThread, outlineRectInFlowThread, &amp;layerBoundingBoxInFlowThread);
</span><span class="cx">         
</span><span class="lines">@@ -4567,8 +4560,7 @@
</span><span class="cx"> void RenderLayer::updatePaintingInfoForFragments(LayerFragments&amp; fragments, const LayerPaintingInfo&amp; localPaintingInfo, PaintLayerFlags localPaintFlags,
</span><span class="cx">     bool shouldPaintContent, const LayoutSize&amp; offsetFromRoot)
</span><span class="cx"> {
</span><del>-    for (size_t i = 0; i &lt; fragments.size(); ++i) {
-        LayerFragment&amp; fragment = fragments.at(i);
</del><ins>+    for (auto&amp; fragment : fragments) {
</ins><span class="cx">         fragment.shouldPaintContent = shouldPaintContent;
</span><span class="cx">         if (this != localPaintingInfo.rootLayer || !(localPaintFlags &amp; PaintLayerPaintingOverflowContents)) {
</span><span class="cx">             LayoutSize newOffsetFromRoot = offsetFromRoot + fragment.paginationOffset;
</span><span class="lines">@@ -4587,9 +4579,7 @@
</span><span class="cx">         (paintFlags &amp; PaintLayerTemporaryClipRects) ? TemporaryClipRects : PaintingClipRects, IgnoreOverlayScrollbarSize,
</span><span class="cx">         (paintFlags &amp; PaintLayerPaintingOverflowContents) ? IgnoreOverflowClip : RespectOverflowClip, offsetOfPaginationLayerFromRoot, &amp;transformedExtent);
</span><span class="cx">     
</span><del>-    for (size_t i = 0; i &lt; enclosingPaginationFragments.size(); ++i) {
-        const LayerFragment&amp; fragment = enclosingPaginationFragments.at(i);
-        
</del><ins>+    for (const auto&amp; fragment : enclosingPaginationFragments) {
</ins><span class="cx">         // Apply the page/column clip for this fragment, as well as any clips established by layers in between us and
</span><span class="cx">         // the enclosing pagination layer.
</span><span class="cx">         LayoutRect clipRect = fragment.backgroundRect.rect();
</span><span class="lines">@@ -5943,9 +5933,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (Vector&lt;RenderLayer*&gt;* negZOrderList = this-&gt;negZOrderList()) {
</span><del>-        size_t listSize = negZOrderList-&gt;size();
-        for (size_t i = 0; i &lt; listSize; ++i) {
-            RenderLayer* curLayer = negZOrderList-&gt;at(i);
</del><ins>+        for (auto curLayer : *negZOrderList) {
</ins><span class="cx">             if (flags &amp; IncludeCompositedDescendants || !curLayer-&gt;isComposited()) {
</span><span class="cx">                 LayoutRect childUnionBounds = curLayer-&gt;calculateLayerBounds(this, curLayer-&gt;offsetFromAncestor(this), descendantFlags);
</span><span class="cx">                 unionBounds.unite(childUnionBounds);
</span><span class="lines">@@ -5954,9 +5942,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (Vector&lt;RenderLayer*&gt;* posZOrderList = this-&gt;posZOrderList()) {
</span><del>-        size_t listSize = posZOrderList-&gt;size();
-        for (size_t i = 0; i &lt; listSize; ++i) {
-            RenderLayer* curLayer = posZOrderList-&gt;at(i);
</del><ins>+        for (auto curLayer : *posZOrderList) {
</ins><span class="cx">             // The RenderNamedFlowThread is ignored when we calculate the bounds of the RenderView.
</span><span class="cx">             if ((flags &amp; IncludeCompositedDescendants || !curLayer-&gt;isComposited()) &amp;&amp; !curLayer-&gt;isFlowThreadCollectingGraphicsLayersUnderRegions()) {
</span><span class="cx">                 LayoutRect childUnionBounds = curLayer-&gt;calculateLayerBounds(this, curLayer-&gt;offsetFromAncestor(this), descendantFlags);
</span><span class="lines">@@ -5966,9 +5952,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (Vector&lt;RenderLayer*&gt;* normalFlowList = this-&gt;normalFlowList()) {
</span><del>-        size_t listSize = normalFlowList-&gt;size();
-        for (size_t i = 0; i &lt; listSize; ++i) {
-            RenderLayer* curLayer = normalFlowList-&gt;at(i);
</del><ins>+        for (auto curLayer : *normalFlowList) {
</ins><span class="cx">             // RenderView will always return the size of the document, before reaching this point,
</span><span class="cx">             // so there's no way we could hit a RenderNamedFlowThread here.
</span><span class="cx">             ASSERT(!curLayer-&gt;isFlowThreadCollectingGraphicsLayersUnderRegions());
</span><span class="lines">@@ -6140,7 +6124,7 @@
</span><span class="cx">     if (!list || list-&gt;isEmpty())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    for (Vector&lt;RenderLayer*&gt;::const_reverse_iterator iter = list-&gt;rbegin(); iter != list-&gt;rend(); ++iter) {
</del><ins>+    for (auto iter = list-&gt;rbegin(); iter != list-&gt;rend(); ++iter) {
</ins><span class="cx">         const RenderLayer* childLayer = *iter;
</span><span class="cx">         if (childLayer-&gt;isComposited())
</span><span class="cx">             continue;
</span><span class="lines">@@ -6313,37 +6297,25 @@
</span><span class="cx">     
</span><span class="cx">     if (isStackingContainer()) {
</span><span class="cx">         if (Vector&lt;RenderLayer*&gt;* list = negZOrderList()) {
</span><del>-            size_t listSize = list-&gt;size();
-            for (size_t i = 0; i &lt; listSize; ++i) {
-                RenderLayer* childLayer = list-&gt;at(i);
</del><ins>+            for (auto childLayer : *list)
</ins><span class="cx">                 layersToUpdate.append(childLayer);
</span><del>-            }
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (Vector&lt;RenderLayer*&gt;* list = normalFlowList()) {
</span><del>-        size_t listSize = list-&gt;size();
-        for (size_t i = 0; i &lt; listSize; ++i) {
-            RenderLayer* childLayer = list-&gt;at(i);
</del><ins>+        for (auto childLayer : *list)
</ins><span class="cx">             layersToUpdate.append(childLayer);
</span><del>-        }
</del><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     if (isStackingContainer()) {
</span><span class="cx">         if (Vector&lt;RenderLayer*&gt;* list = posZOrderList()) {
</span><del>-            size_t listSize = list-&gt;size();
-            for (size_t i = 0; i &lt; listSize; ++i) {
-                RenderLayer* childLayer = list-&gt;at(i);
</del><ins>+            for (auto childLayer : *list)
</ins><span class="cx">                 layersToUpdate.append(childLayer);
</span><del>-            }
</del><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    size_t listSize = layersToUpdate.size();
-    for (size_t i = 0; i &lt; listSize; ++i) {
-        RenderLayer* childLayer = layersToUpdate.at(i);
</del><ins>+    for (auto childLayer : layersToUpdate) {
</ins><span class="cx">         childLayer-&gt;updateLayerListsIfNeeded();
</span><del>-        
</del><span class="cx">         if (recursive)
</span><span class="cx">             childLayer-&gt;updateDescendantsLayerListsIfNeeded(true);
</span><span class="cx">     }
</span><span class="lines">@@ -6968,9 +6940,7 @@
</span><span class="cx">             regionClipRect.move(offsetFromAncestor(paintingInfo.rootLayer));
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    for (size_t i = 0; i &lt; fragments.size(); ++i) {
-        const LayerFragment&amp; fragment = fragments.at(i);
-
</del><ins>+    for (const auto&amp; fragment : fragments) {
</ins><span class="cx">         ClipRect clipRect = fragment.foregroundRect;
</span><span class="cx">         if (flowFragment-&gt;shouldClipFlowThreadContent())
</span><span class="cx">             clipRect.intersect(regionClipRect);
</span></span></pre>
</div>
</div>

</body>
</html>