Use renderer iterators in two more places.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Feb 2014 08:45:47 +0000 (08:45 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Feb 2014 08:45:47 +0000 (08:45 +0000)
<https://webkit.org/b/128371>

Reviewed by Antti Koivisto.

* dom/Position.cpp:
(WebCore::Position::primaryDirection):

    Use lineageOfType instead of walking the parent chain.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::insertOnlyThisLayer):

    Use childrenOfType instead of walking the children.

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

Source/WebCore/ChangeLog
Source/WebCore/dom/Position.cpp
Source/WebCore/rendering/RenderLayer.cpp

index c37bdcf1a4ae8c6fccf7c8fbfe8e1f3364115e29..0e6c9175e1b9fcd900caf0de53428238ebc60e8a 100644 (file)
@@ -1,3 +1,20 @@
+2014-02-08  Andreas Kling  <akling@apple.com>
+
+        Use renderer iterators in two more places.
+        <https://webkit.org/b/128371>
+
+        Reviewed by Antti Koivisto.
+
+        * dom/Position.cpp:
+        (WebCore::Position::primaryDirection):
+
+            Use lineageOfType instead of walking the parent chain.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::insertOnlyThisLayer):
+
+            Use childrenOfType instead of walking the children.
+
 2014-02-07  David Kilzer  <ddkilzer@apple.com>
 
         [ASan] Use new/delete in PODFreeListArena
index 746f75eb795493bc0eb796bcd63aa85dd67e2a06..161d90773ce1d891ced5bcefb9c4cece9338e61f 100644 (file)
@@ -36,6 +36,7 @@
 #include "PositionIterator.h"
 #include "RenderBlock.h"
 #include "RenderInline.h"
+#include "RenderIterator.h"
 #include "RenderLineBreak.h"
 #include "RenderText.h"
 #include "RuntimeEnabledFeatures.h"
@@ -1334,15 +1335,11 @@ void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi
 
 TextDirection Position::primaryDirection() const
 {
-    TextDirection primaryDirection = LTR;
-    for (const RenderObject* r = m_anchorNode->renderer(); r; r = r->parent()) {
-        if (r->isRenderBlockFlow()) {
-            primaryDirection = toRenderBlockFlow(r)->style().direction();
-            break;
-        }
-    }
-
-    return primaryDirection;
+    if (!m_anchorNode->renderer())
+        return LTR;
+    if (auto* blockFlow = lineageOfType<RenderBlockFlow>(*m_anchorNode->renderer()).first())
+        return blockFlow->style().direction();
+    return LTR;
 }
 
 
index 579295f3aed74725ea257bcaaa869954ef28bc7a..717bee5cc810d730b1da47abc6dc4a97718174a4 100644 (file)
@@ -81,6 +81,7 @@
 #include "RenderFlowThread.h"
 #include "RenderGeometryMap.h"
 #include "RenderInline.h"
+#include "RenderIterator.h"
 #include "RenderLayerBacking.h"
 #include "RenderLayerCompositor.h"
 #include "RenderMarquee.h"
@@ -1833,10 +1834,8 @@ void RenderLayer::insertOnlyThisLayer()
     }
 
     // Remove all descendant layers from the hierarchy and add them to the new position.
-    for (RenderObject* curr = renderer().firstChild(); curr; curr = curr->nextSibling()) {
-        if (curr->isRenderElement())
-            toRenderElement(curr)->moveLayers(m_parent, this);
-    }
+    for (auto& child : childrenOfType<RenderElement>(renderer()))
+        child.moveLayers(m_parent, this);
 
     // Clear out all the clip rects.
     clearClipRectsIncludingDescendants();