Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp

Issue 1878583002: Refactor SVGTextLayoutAttributesBuilder::collectTextPositioningElements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@svg-metrics-cleanup-17
Patch Set: Use for-range loop Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698