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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 if (!data->allCharactersMap) 177 if (!data->allCharactersMap)
178 return; 178 return;
179 179
180 data->valueListPosition += m_textPosition - data->skippedCharacters; 180 data->valueListPosition += m_textPosition - data->skippedCharacters;
181 data->skippedCharacters = 0; 181 data->skippedCharacters = 0;
182 } 182 }
183 183
184 void SVGTextMetricsBuilder::walkTree(RenderObject* start, RenderSVGInlineText* s topAtLeaf, MeasureTextData* data) 184 void SVGTextMetricsBuilder::walkTree(RenderObject* start, RenderSVGInlineText* s topAtLeaf, MeasureTextData* data)
185 { 185 {
186 for (RenderObject* child = start->firstChild(); child; child = child->nextSi bling()) { 186 RenderObject* child = start->firstChild();
187 while (child) {
187 if (child->isSVGInlineText()) { 188 if (child->isSVGInlineText()) {
188 RenderSVGInlineText* text = toRenderSVGInlineText(child); 189 RenderSVGInlineText* text = toRenderSVGInlineText(child);
189 if (stopAtLeaf && stopAtLeaf != text) { 190 data->processRenderer = !stopAtLeaf || stopAtLeaf == text;
190 data->processRenderer = false; 191 measureTextRenderer(text, data);
191 measureTextRenderer(text, data); 192 if (stopAtLeaf && stopAtLeaf == text)
193 return;
194 } else if (child->isSVGInline()) {
195 // Visit children of text content elements.
196 if (RenderObject* inlineChild = child->firstChild()) {
197 child = inlineChild;
192 continue; 198 continue;
193 } 199 }
194
195 data->processRenderer = true;
196 measureTextRenderer(text, data);
197 if (stopAtLeaf)
198 return;
199
200 continue;
201 } 200 }
202 201 child = child->nextInPreOrderAfterChildren(start);
203 if (!child->isSVGInline())
204 continue;
205
206 walkTree(child, stopAtLeaf, data);
207 } 202 }
208 } 203 }
209 204
210 void SVGTextMetricsBuilder::measureTextRenderer(RenderSVGInlineText* text) 205 void SVGTextMetricsBuilder::measureTextRenderer(RenderSVGInlineText* text)
211 { 206 {
212 ASSERT(text); 207 ASSERT(text);
213 208
214 RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text); 209 RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text);
215 if (!textRoot) 210 if (!textRoot)
216 return; 211 return;
217 212
218 MeasureTextData data(0); 213 MeasureTextData data(0);
219 walkTree(textRoot, text, &data); 214 walkTree(textRoot, text, &data);
220 } 215 }
221 216
222 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(RenderSVGText* textR oot, RenderSVGInlineText* stopAtLeaf, SVGCharacterDataMap& allCharactersMap) 217 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(RenderSVGText* textR oot, RenderSVGInlineText* stopAtLeaf, SVGCharacterDataMap& allCharactersMap)
223 { 218 {
224 ASSERT(textRoot); 219 ASSERT(textRoot);
225 MeasureTextData data(&allCharactersMap); 220 MeasureTextData data(&allCharactersMap);
226 walkTree(textRoot, stopAtLeaf, &data); 221 walkTree(textRoot, stopAtLeaf, &data);
227 } 222 }
228 223
229 } 224 }
OLDNEW
« 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