Index: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp |
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp |
index 8153cff9904aed86f413c3bd8e6a57d878b9c798..becc390eb3c7063a18046ccfaab099f49106335f 100644 |
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp |
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp |
@@ -113,6 +113,10 @@ static SVGTextPositioningElement* positioningElementFromLayoutObject(LayoutObjec |
void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(LayoutBoxModelObject& start) |
{ |
ASSERT(!start.isSVGText() || m_textPositions.isEmpty()); |
+ SVGTextPositioningElement* element = positioningElementFromLayoutObject(start); |
+ unsigned atPosition = m_textPositions.size(); |
+ if (element) |
+ m_textPositions.append(TextPosition(element, m_characterCount)); |
for (LayoutObject* child = start.slowFirstChild(); child; child = child->nextSibling()) { |
if (child->isSVGInlineText()) { |
@@ -120,40 +124,26 @@ void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(LayoutBoxMod |
continue; |
} |
- if (!child->isSVGInline()) |
+ if (child->isSVGInline()) { |
+ collectTextPositioningElements(toLayoutSVGInline(*child)); |
continue; |
+ } |
+ } |
- LayoutSVGInline& inlineChild = toLayoutSVGInline(*child); |
- SVGTextPositioningElement* element = positioningElementFromLayoutObject(inlineChild); |
- unsigned atPosition = m_textPositions.size(); |
- if (element) |
- m_textPositions.append(TextPosition(element, m_characterCount)); |
- |
- collectTextPositioningElements(inlineChild); |
- |
- if (!element) |
- continue; |
+ if (!element) |
+ return; |
- // Update text position, after we're back from recursion. |
- TextPosition& position = m_textPositions[atPosition]; |
- ASSERT(!position.length); |
- position.length = m_characterCount - position.start; |
- } |
+ // Compute the length of the subtree after all children have been visited. |
+ TextPosition& position = m_textPositions[atPosition]; |
+ ASSERT(!position.length); |
+ position.length = m_characterCount - position.start; |
} |
void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(LayoutSVGText& textRoot) |
{ |
- SVGTextPositioningElement* outermostTextElement = positioningElementFromLayoutObject(textRoot); |
- ASSERT(outermostTextElement); |
- |
- // Grab outermost <text> element value lists and insert them in the character data map. |
- TextPosition wholeTextPosition(outermostTextElement, 0, m_characterCount); |
- fillCharacterDataMap(wholeTextPosition); |
- |
- // Fill character data map using child text positioning elements in top-down order. |
- unsigned size = m_textPositions.size(); |
- for (unsigned i = 0; i < size; ++i) |
- fillCharacterDataMap(m_textPositions[i]); |
+ // Fill character data map using text positioning elements in top-down order. |
+ for (const TextPosition& position : m_textPositions) |
+ fillCharacterDataMap(position); |
// Handle x/y default attributes. |
SVGCharacterData& data = m_characterDataMap.add(1, SVGCharacterData()).storedValue->value; |