Add lineageOfType renderer iterator and start using it.
[WebKit-https.git] / Source / WebCore / rendering / RenderAncestorIterator.h
index 7d2fd6edfd17f02c5bc1a920db094dbb75771112..39dd05e725213391e190c17a633f9accb4ef2581 100644 (file)
@@ -72,6 +72,8 @@ private:
 
 template <typename T> RenderAncestorIteratorAdapter<T> ancestorsOfType(RenderObject&);
 template <typename T> RenderAncestorConstIteratorAdapter<T> ancestorsOfType(const RenderObject&);
+template <typename T> RenderAncestorIteratorAdapter<T> lineageOfType(RenderObject&);
+template <typename T> RenderAncestorConstIteratorAdapter<T> lineageOfType(const RenderObject&);
 
 // RenderAncestorIterator
 
@@ -181,6 +183,22 @@ inline RenderAncestorConstIteratorAdapter<T> ancestorsOfType(const RenderObject&
     return RenderAncestorConstIteratorAdapter<T>(first);
 }
 
+template <typename T>
+inline RenderAncestorIteratorAdapter<T> lineageOfType(RenderObject& first)
+{
+    if (isRendererOfType<const T>(first))
+        return RenderAncestorIteratorAdapter<T>(static_cast<T*>(&first));
+    return ancestorsOfType<T>(first);
+}
+
+template <typename T>
+inline RenderAncestorConstIteratorAdapter<T> lineageOfType(const RenderObject& first)
+{
+    if (isRendererOfType<const T>(first))
+        return RenderAncestorConstIteratorAdapter<T>(static_cast<const T*>(&first));
+    return ancestorsOfType<T>(first);
+}
+
 }
 
 #endif