| OLD | NEW |
| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 const bool preserveWhiteSpace = styleRef().whiteSpace() == EWhiteSpace::kPre; | 302 const bool preserveWhiteSpace = styleRef().whiteSpace() == EWhiteSpace::kPre; |
| 303 const unsigned runLength = run.length(); | 303 const unsigned runLength = run.length(); |
| 304 | 304 |
| 305 // TODO(pdr): Character-based iteration is ambiguous and error-prone. It | 305 // TODO(pdr): Character-based iteration is ambiguous and error-prone. It |
| 306 // should be unified under a single concept. See: https://crbug.com/593570 | 306 // should be unified under a single concept. See: https://crbug.com/593570 |
| 307 unsigned characterIndex = 0; | 307 unsigned characterIndex = 0; |
| 308 while (characterIndex < runLength) { | 308 while (characterIndex < runLength) { |
| 309 bool currentCharacterIsWhiteSpace = run[characterIndex] == ' '; | 309 bool currentCharacterIsWhiteSpace = run[characterIndex] == ' '; |
| 310 if (!preserveWhiteSpace && lastCharacterWasWhiteSpace && | 310 if (!preserveWhiteSpace && lastCharacterWasWhiteSpace && |
| 311 currentCharacterIsWhiteSpace) { | 311 currentCharacterIsWhiteSpace) { |
| 312 m_metrics.append(SVGTextMetrics(SVGTextMetrics::SkippedSpaceMetrics)); | 312 m_metrics.push_back(SVGTextMetrics(SVGTextMetrics::SkippedSpaceMetrics)); |
| 313 characterIndex++; | 313 characterIndex++; |
| 314 continue; | 314 continue; |
| 315 } | 315 } |
| 316 | 316 |
| 317 unsigned length = isValidSurrogatePair(run, characterIndex) ? 2 : 1; | 317 unsigned length = isValidSurrogatePair(run, characterIndex) ? 2 : 1; |
| 318 float width = charRanges[characterIndex].width() / m_scalingFactor; | 318 float width = charRanges[characterIndex].width() / m_scalingFactor; |
| 319 | 319 |
| 320 m_metrics.append(SVGTextMetrics(length, width, cachedFontHeight)); | 320 m_metrics.push_back(SVGTextMetrics(length, width, cachedFontHeight)); |
| 321 | 321 |
| 322 lastCharacterWasWhiteSpace = currentCharacterIsWhiteSpace; | 322 lastCharacterWasWhiteSpace = currentCharacterIsWhiteSpace; |
| 323 characterIndex += length; | 323 characterIndex += length; |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 | 326 |
| 327 void LayoutSVGInlineText::updateMetricsList(bool& lastCharacterWasWhiteSpace) { | 327 void LayoutSVGInlineText::updateMetricsList(bool& lastCharacterWasWhiteSpace) { |
| 328 m_metrics.clear(); | 328 m_metrics.clear(); |
| 329 | 329 |
| 330 if (!textLength()) | 330 if (!textLength()) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 } | 415 } |
| 416 | 416 |
| 417 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const { | 417 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const { |
| 418 RefPtr<StringImpl> result = LayoutText::originalText(); | 418 RefPtr<StringImpl> result = LayoutText::originalText(); |
| 419 if (!result) | 419 if (!result) |
| 420 return nullptr; | 420 return nullptr; |
| 421 return normalizeWhitespace(result); | 421 return normalizeWhitespace(result); |
| 422 } | 422 } |
| 423 | 423 |
| 424 } // namespace blink | 424 } // namespace blink |
| OLD | NEW |