Title: [161323] trunk/Source/WebCore
Revision
161323
Author
[email protected]
Date
2014-01-05 03:45:54 -0800 (Sun, 05 Jan 2014)

Log Message

Use lineageOfType to simplify two rendering helpers.
<https://webkit.org/b/126498>

Reviewed by Antti Koivisto.

* rendering/RenderRuby.cpp:
(WebCore::findRubyRunParent):
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::findTreeRootObject):

    Simplify two functions that walk their parent chain to find the
    closest ancestor of a certain type.

* rendering/RenderRubyRun.h:

    Add requisite isRendererOfType<RenderRubyRun>().

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (161322 => 161323)


--- trunk/Source/WebCore/ChangeLog	2014-01-05 10:34:04 UTC (rev 161322)
+++ trunk/Source/WebCore/ChangeLog	2014-01-05 11:45:54 UTC (rev 161323)
@@ -1,3 +1,22 @@
+2014-01-05  Andreas Kling  <[email protected]>
+
+        Use lineageOfType to simplify two rendering helpers.
+        <https://webkit.org/b/126498>
+
+        Reviewed by Antti Koivisto.
+
+        * rendering/RenderRuby.cpp:
+        (WebCore::findRubyRunParent):
+        * rendering/svg/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderSupport::findTreeRootObject):
+
+            Simplify two functions that walk their parent chain to find the
+            closest ancestor of a certain type.
+
+        * rendering/RenderRubyRun.h:
+
+            Add requisite isRendererOfType<RenderRubyRun>().
+
 2014-01-05  Csaba Osztrogonác  <[email protected]>
 
         Fix the Mac build too.

Modified: trunk/Source/WebCore/rendering/RenderRuby.cpp (161322 => 161323)


--- trunk/Source/WebCore/rendering/RenderRuby.cpp	2014-01-05 10:34:04 UTC (rev 161322)
+++ trunk/Source/WebCore/rendering/RenderRuby.cpp	2014-01-05 11:45:54 UTC (rev 161323)
@@ -32,6 +32,7 @@
 
 #include "RenderRuby.h"
 
+#include "RenderIterator.h"
 #include "RenderRubyRun.h"
 #include "RenderStyle.h"
 #include "StyleInheritedData.h"
@@ -101,11 +102,7 @@
 
 static inline RenderRubyRun& findRubyRunParent(RenderObject& child)
 {
-    RenderObject* ancestor = &child;
-    while (ancestor && !ancestor->isRubyRun())
-        ancestor = ancestor->parent();
-    ASSERT(ancestor);
-    return toRenderRubyRun(*ancestor);
+    return *lineageOfType<RenderRubyRun>(child).first();
 }
 
 //=== ruby as inline object ===

Modified: trunk/Source/WebCore/rendering/RenderRubyRun.h (161322 => 161323)


--- trunk/Source/WebCore/rendering/RenderRubyRun.h	2014-01-05 10:34:04 UTC (rev 161322)
+++ trunk/Source/WebCore/rendering/RenderRubyRun.h	2014-01-05 11:45:54 UTC (rev 161323)
@@ -77,6 +77,8 @@
     virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
 };
 
+template<> inline bool isRendererOfType<const RenderRubyRun>(const RenderObject& renderer) { return renderer.isRubyRun(); }
+
 RENDER_OBJECT_TYPE_CASTS(RenderRubyRun, isRubyRun())
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp (161322 => 161323)


--- trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2014-01-05 10:34:04 UTC (rev 161322)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp	2014-01-05 11:45:54 UTC (rev 161323)
@@ -28,7 +28,9 @@
 #include "SVGRenderSupport.h"
 
 #include "NodeRenderStyle.h"
+#include "RenderElement.h"
 #include "RenderGeometryMap.h"
+#include "RenderIterator.h"
 #include "RenderLayer.h"
 #include "RenderSVGResource.h"
 #include "RenderSVGResourceClipper.h"
@@ -182,12 +184,7 @@
 
 const RenderSVGRoot& SVGRenderSupport::findTreeRootObject(const RenderElement& start)
 {
-    auto renderer = &start;
-    while (renderer && !renderer->isSVGRoot())
-        renderer = renderer->parent();
-
-    ASSERT(renderer);
-    return toRenderSVGRoot(*renderer);
+    return *lineageOfType<RenderSVGRoot>(start).first();
 }
 
 static inline void invalidateResourcesOfChildren(RenderObject& start)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to