Index: Source/core/layout/svg/LayoutSVGText.cpp |
diff --git a/Source/core/layout/svg/LayoutSVGText.cpp b/Source/core/layout/svg/LayoutSVGText.cpp |
index 1f76ce3a176786a71b937669163b679e8bd72946..63c6cf49d6ac17b1fe900fffcdc81516330b62cc 100644 |
--- a/Source/core/layout/svg/LayoutSVGText.cpp |
+++ b/Source/core/layout/svg/LayoutSVGText.cpp |
@@ -54,6 +54,20 @@ |
namespace blink { |
+namespace { |
+ |
+const LayoutSVGText* findTextRoot(const LayoutObject* start) |
+{ |
+ ASSERT(start); |
+ for (; start; start = start->parent()) { |
+ if (start->isSVGText()) |
+ return toLayoutSVGText(start); |
+ } |
+ return nullptr; |
+} |
+ |
+} |
+ |
LayoutSVGText::LayoutSVGText(SVGTextElement* node) |
: LayoutSVGBlock(node) |
, m_needsReordering(false) |
@@ -75,22 +89,12 @@ bool LayoutSVGText::isChildAllowed(LayoutObject* child, const ComputedStyle&) co |
LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(LayoutObject* start) |
{ |
- ASSERT(start); |
- while (start && !start->isSVGText()) |
- start = start->parent(); |
- if (!start || !start->isSVGText()) |
- return nullptr; |
- return toLayoutSVGText(start); |
+ return const_cast<LayoutSVGText*>(findTextRoot(start)); |
} |
const LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(const LayoutObject* start) |
{ |
- ASSERT(start); |
- while (start && !start->isSVGText()) |
- start = start->parent(); |
- if (!start || !start->isSVGText()) |
- return nullptr; |
- return toLayoutSVGText(start); |
+ return findTextRoot(start); |
} |
static inline void collectLayoutAttributes(LayoutObject* text, Vector<SVGTextLayoutAttributes*>& attributes) |