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

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

Issue 2018253002: Change TextRun's length() and charactersLength() to return an unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and remove one static_cast added in r396668 Created 4 years, 6 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 | « no previous file | third_party/WebKit/Source/core/paint/TextPainter.h » ('j') | 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) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
3 * Copyright (C) 2006 Apple Computer Inc. 3 * Copyright (C) 2006 Apple Computer Inc.
4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
5 * Copyright (C) 2008 Rob Buis <buis@kde.org> 5 * Copyright (C) 2008 Rob Buis <buis@kde.org>
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 int offset = closestDistanceBox->offsetForPositionInFragment(*closestDistanc eFragment, LayoutUnit(absolutePoint.x() - closestDistancePosition), true); 190 int offset = closestDistanceBox->offsetForPositionInFragment(*closestDistanc eFragment, LayoutUnit(absolutePoint.x() - closestDistancePosition), true);
191 return createPositionWithAffinity(offset + closestDistanceBox->start(), offs et > 0 ? VP_UPSTREAM_IF_POSSIBLE : TextAffinity::Downstream); 191 return createPositionWithAffinity(offset + closestDistanceBox->start(), offs et > 0 ? VP_UPSTREAM_IF_POSSIBLE : TextAffinity::Downstream);
192 } 192 }
193 193
194 namespace { 194 namespace {
195 195
196 inline bool isValidSurrogatePair(const TextRun& run, unsigned index) 196 inline bool isValidSurrogatePair(const TextRun& run, unsigned index)
197 { 197 {
198 if (!U16_IS_LEAD(run[index])) 198 if (!U16_IS_LEAD(run[index]))
199 return false; 199 return false;
200 if (index + 1 >= static_cast<unsigned>(run.length())) 200 if (index + 1 >= run.length())
201 return false; 201 return false;
202 return U16_IS_TRAIL(run[index + 1]); 202 return U16_IS_TRAIL(run[index + 1]);
203 } 203 }
204 204
205 TextRun constructTextRun(LayoutSVGInlineText& text, unsigned position, unsigned length, TextDirection textDirection) 205 TextRun constructTextRun(LayoutSVGInlineText& text, unsigned position, unsigned length, TextDirection textDirection)
206 { 206 {
207 const ComputedStyle& style = text.styleRef(); 207 const ComputedStyle& style = text.styleRef();
208 208
209 TextRun run(static_cast<const LChar*>(nullptr) // characters, will be set be low if non-zero. 209 TextRun run(static_cast<const LChar*>(nullptr) // characters, will be set be low if non-zero.
210 , 0 // length, will be set below if non-zero. 210 , 0 // length, will be set below if non-zero.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } // namespace 268 } // namespace
269 269
270 void LayoutSVGInlineText::addMetricsFromRun( 270 void LayoutSVGInlineText::addMetricsFromRun(
271 const TextRun& run, bool& lastCharacterWasWhiteSpace) 271 const TextRun& run, bool& lastCharacterWasWhiteSpace)
272 { 272 {
273 Vector<CharacterRange> charRanges = scaledFont().individualCharacterRanges(r un); 273 Vector<CharacterRange> charRanges = scaledFont().individualCharacterRanges(r un);
274 synthesizeGraphemeWidths(run, charRanges); 274 synthesizeGraphemeWidths(run, charRanges);
275 275
276 const float cachedFontHeight = scaledFont().getFontMetrics().floatHeight() / m_scalingFactor; 276 const float cachedFontHeight = scaledFont().getFontMetrics().floatHeight() / m_scalingFactor;
277 const bool preserveWhiteSpace = styleRef().whiteSpace() == PRE; 277 const bool preserveWhiteSpace = styleRef().whiteSpace() == PRE;
278 const unsigned runLength = static_cast<unsigned>(run.length()); 278 const unsigned runLength = run.length();
279 279
280 // TODO(pdr): Character-based iteration is ambiguous and error-prone. It 280 // TODO(pdr): Character-based iteration is ambiguous and error-prone. It
281 // should be unified under a single concept. See: https://crbug.com/593570 281 // should be unified under a single concept. See: https://crbug.com/593570
282 unsigned characterIndex = 0; 282 unsigned characterIndex = 0;
283 while (characterIndex < runLength) { 283 while (characterIndex < runLength) {
284 bool currentCharacterIsWhiteSpace = run[characterIndex] == ' '; 284 bool currentCharacterIsWhiteSpace = run[characterIndex] == ' ';
285 if (!preserveWhiteSpace && lastCharacterWasWhiteSpace && currentCharacte rIsWhiteSpace) { 285 if (!preserveWhiteSpace && lastCharacterWasWhiteSpace && currentCharacte rIsWhiteSpace) {
286 m_metrics.append(SVGTextMetrics(SVGTextMetrics::SkippedSpaceMetrics) ); 286 m_metrics.append(SVGTextMetrics(SVGTextMetrics::SkippedSpaceMetrics) );
287 characterIndex++; 287 characterIndex++;
288 continue; 288 continue;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 378
379 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const 379 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const
380 { 380 {
381 RefPtr<StringImpl> result = LayoutText::originalText(); 381 RefPtr<StringImpl> result = LayoutText::originalText();
382 if (!result) 382 if (!result)
383 return nullptr; 383 return nullptr;
384 return normalizeWhitespace(result); 384 return normalizeWhitespace(result);
385 } 385 }
386 386
387 } // namespace blink 387 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/paint/TextPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698