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

Unified Diff: Source/core/rendering/svg/SVGTextMetricsBuilder.cpp

Issue 175323002: Eliminate recursion in SVGTextMetricsBuilder::walkTree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Re-upload. Created 6 years, 10 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: Source/core/rendering/svg/SVGTextMetricsBuilder.cpp
diff --git a/Source/core/rendering/svg/SVGTextMetricsBuilder.cpp b/Source/core/rendering/svg/SVGTextMetricsBuilder.cpp
index 55dc71f7ab71e0af722c755874900b889f7cfeea..c11ee7532ec01c59658c4dbd3db4a0bde47a4e71 100644
--- a/Source/core/rendering/svg/SVGTextMetricsBuilder.cpp
+++ b/Source/core/rendering/svg/SVGTextMetricsBuilder.cpp
@@ -183,27 +183,22 @@ void SVGTextMetricsBuilder::measureTextRenderer(RenderSVGInlineText* text, Measu
void SVGTextMetricsBuilder::walkTree(RenderObject* start, RenderSVGInlineText* stopAtLeaf, MeasureTextData* data)
{
- for (RenderObject* child = start->firstChild(); child; child = child->nextSibling()) {
+ RenderObject* child = start->firstChild();
+ while (child) {
if (child->isSVGInlineText()) {
RenderSVGInlineText* text = toRenderSVGInlineText(child);
- if (stopAtLeaf && stopAtLeaf != text) {
- data->processRenderer = false;
- measureTextRenderer(text, data);
- continue;
- }
-
- data->processRenderer = true;
+ data->processRenderer = !stopAtLeaf || stopAtLeaf == text;
measureTextRenderer(text, data);
- if (stopAtLeaf)
+ if (stopAtLeaf && stopAtLeaf == text)
return;
-
- continue;
+ } else if (child->isSVGInline()) {
+ // Visit children of text content elements.
+ if (RenderObject* inlineChild = child->firstChild()) {
+ child = inlineChild;
+ continue;
+ }
}
-
- if (!child->isSVGInline())
- continue;
-
- walkTree(child, stopAtLeaf, data);
+ child = child->nextInPreOrderAfterChildren(start);
}
}
« 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