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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |