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

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

Issue 1848463002: Include the surrogate character count when updating text state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@svg-metrics-cleanup-5
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/text/surrogate-pair-attribute-positions-expected.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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 bool currentCharacterIsWhiteSpace = calculator.currentCharacterIsWhiteSp ace(); 276 bool currentCharacterIsWhiteSpace = calculator.currentCharacterIsWhiteSp ace();
277 if (currentCharacterIsWhiteSpace && !preserveWhiteSpace && textState.las tCharacterWasWhiteSpace) { 277 if (currentCharacterIsWhiteSpace && !preserveWhiteSpace && textState.las tCharacterWasWhiteSpace) {
278 if (attributesToUpdate) 278 if (attributesToUpdate)
279 attributesToUpdate->addMetrics(SVGTextMetrics(SVGTextMetrics::Sk ippedSpaceMetrics)); 279 attributesToUpdate->addMetrics(SVGTextMetrics(SVGTextMetrics::Sk ippedSpaceMetrics));
280 ASSERT(calculator.currentCharacterMetrics().length() == 1); 280 ASSERT(calculator.currentCharacterMetrics().length() == 1);
281 skippedWhitespace++; 281 skippedWhitespace++;
282 continue; 282 continue;
283 } 283 }
284 284
285 if (attributesToUpdate) { 285 if (attributesToUpdate) {
286 attributesToUpdate->updateCharacterDataMap(textState.valueListPositi on - skippedWhitespace - surrogatePairCharacters + calculator.currentPosition() + 1, calculator.currentPosition() + 1); 286 unsigned currentTextValueListPosition = calculator.currentPosition() - skippedWhitespace - surrogatePairCharacters;
287 attributesToUpdate->updateCharacterDataMap(textState.valueListPositi on + currentTextValueListPosition + 1, calculator.currentPosition() + 1);
287 attributesToUpdate->addMetrics(calculator.currentCharacterMetrics()) ; 288 attributesToUpdate->addMetrics(calculator.currentCharacterMetrics()) ;
288 } 289 }
289 290
290 if (calculator.currentCharacterStartsSurrogatePair()) 291 if (calculator.currentCharacterStartsSurrogatePair())
291 surrogatePairCharacters++; 292 surrogatePairCharacters++;
292 textState.lastCharacterWasWhiteSpace = currentCharacterIsWhiteSpace; 293 textState.lastCharacterWasWhiteSpace = currentCharacterIsWhiteSpace;
293 } while (calculator.advancePosition()); 294 } while (calculator.advancePosition());
294 295
295 textState.valueListPosition += calculator.currentPosition() - skippedWhitesp ace; 296 unsigned currentTextValueListPosition = calculator.currentPosition() - skipp edWhitespace - surrogatePairCharacters;
297 textState.valueListPosition += currentTextValueListPosition;
296 } 298 }
297 299
298 void walkTree(LayoutSVGText* start, LayoutSVGInlineText* stopAtText, SVGCharacte rDataMap* allCharactersMap = nullptr) 300 void walkTree(LayoutSVGText* start, LayoutSVGInlineText* stopAtText, SVGCharacte rDataMap* allCharactersMap = nullptr)
299 { 301 {
300 TreeWalkTextState textState; 302 TreeWalkTextState textState;
301 LayoutObject* child = start->firstChild(); 303 LayoutObject* child = start->firstChild();
302 while (child) { 304 while (child) {
303 if (child->isSVGInlineText()) { 305 if (child->isSVGInlineText()) {
304 LayoutSVGInlineText* text = toLayoutSVGInlineText(child); 306 LayoutSVGInlineText* text = toLayoutSVGInlineText(child);
305 OwnPtr<UpdateAttributes> attributesToUpdate = nullptr; 307 OwnPtr<UpdateAttributes> attributesToUpdate = nullptr;
(...skipping 22 matching lines...) Expand all
328 walkTree(textRoot, text); 330 walkTree(textRoot, text);
329 } 331 }
330 332
331 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(LayoutSVGText* textR oot, LayoutSVGInlineText* stopAtText, SVGCharacterDataMap& allCharactersMap) 333 void SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(LayoutSVGText* textR oot, LayoutSVGInlineText* stopAtText, SVGCharacterDataMap& allCharactersMap)
332 { 334 {
333 ASSERT(textRoot); 335 ASSERT(textRoot);
334 walkTree(textRoot, stopAtText, &allCharactersMap); 336 walkTree(textRoot, stopAtText, &allCharactersMap);
335 } 337 }
336 338
337 } // namespace blink 339 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/text/surrogate-pair-attribute-positions-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698