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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/SVGTextMetricsBuilder.cpp

Issue 1806263005: Do not crash when measuring empty SVG text nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/text/empty-text-node-crash.html ('k') | 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 SVGTextLayoutAttributes* attributes = text->layoutAttributes(); 193 SVGTextLayoutAttributes* attributes = text->layoutAttributes();
194 Vector<SVGTextMetrics>* textMetricsValues = &attributes->textMetricsValues() ; 194 Vector<SVGTextMetrics>* textMetricsValues = &attributes->textMetricsValues() ;
195 if (processLayoutObject) { 195 if (processLayoutObject) {
196 if (data->allCharactersMap) 196 if (data->allCharactersMap)
197 attributes->clear(); 197 attributes->clear();
198 else 198 else
199 textMetricsValues->clear(); 199 textMetricsValues->clear();
200 } 200 }
201 201
202 if (!text->textLength())
203 return;
204
202 // TODO(pdr): This loop is too tightly coupled to SVGTextMetricsCalculator. 205 // TODO(pdr): This loop is too tightly coupled to SVGTextMetricsCalculator.
203 // We should refactor SVGTextMetricsCalculator to be a simple bidi run 206 // We should refactor SVGTextMetricsCalculator to be a simple bidi run
204 // iterator and move all subrun logic to a single function. 207 // iterator and move all subrun logic to a single function.
205 SVGTextMetricsCalculator calculator(text); 208 SVGTextMetricsCalculator calculator(text);
206 bool preserveWhiteSpace = text->style()->whiteSpace() == PRE; 209 bool preserveWhiteSpace = text->style()->whiteSpace() == PRE;
207 unsigned surrogatePairCharacters = 0; 210 unsigned surrogatePairCharacters = 0;
208 unsigned skippedCharacters = 0; 211 unsigned skippedCharacters = 0;
209 do { 212 do {
210 SVGTextMetrics metrics = calculator.currentCharacterMetrics(); 213 SVGTextMetrics metrics = calculator.currentCharacterMetrics();
211 if (!metrics.length()) 214 if (!metrics.length())
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 277 }
275 278
276 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(LayoutSVGText* textR oot, LayoutSVGInlineText* stopAtLeaf, SVGCharacterDataMap& allCharactersMap) 279 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(LayoutSVGText* textR oot, LayoutSVGInlineText* stopAtLeaf, SVGCharacterDataMap& allCharactersMap)
277 { 280 {
278 ASSERT(textRoot); 281 ASSERT(textRoot);
279 MeasureTextData data(&allCharactersMap); 282 MeasureTextData data(&allCharactersMap);
280 walkTree(textRoot, stopAtLeaf, &data); 283 walkTree(textRoot, stopAtLeaf, &data);
281 } 284 }
282 285
283 } // namespace blink 286 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/text/empty-text-node-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698