OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/fonts/shaping/ShapeResultBuffer.h" | 5 #include "platform/fonts/shaping/ShapeResultBuffer.h" |
6 | 6 |
7 #include "platform/fonts/CharacterRange.h" | 7 #include "platform/fonts/CharacterRange.h" |
8 #include "platform/fonts/SimpleFontData.h" | 8 #include "platform/fonts/SimpleFontData.h" |
9 #include "platform/fonts/shaping/ShapeResultBloberizer.h" | 9 #include "platform/fonts/shaping/ShapeResultBloberizer.h" |
10 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h" | 10 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 inline unsigned countGraphemesInCluster(const UChar* str, | 64 inline unsigned countGraphemesInCluster(const UChar* str, |
65 unsigned strLength, | 65 unsigned strLength, |
66 uint16_t startIndex, | 66 uint16_t startIndex, |
67 uint16_t endIndex) { | 67 uint16_t endIndex) { |
68 if (startIndex > endIndex) { | 68 if (startIndex > endIndex) { |
69 uint16_t tempIndex = startIndex; | 69 uint16_t tempIndex = startIndex; |
70 startIndex = endIndex; | 70 startIndex = endIndex; |
71 endIndex = tempIndex; | 71 endIndex = tempIndex; |
72 } | 72 } |
73 uint16_t length = endIndex - startIndex; | 73 uint16_t length = endIndex - startIndex; |
74 ASSERT(static_cast<unsigned>(startIndex + length) <= strLength); | 74 DCHECK_LE(static_cast<unsigned>(startIndex + length), strLength); |
75 TextBreakIterator* cursorPosIterator = | 75 TextBreakIterator* cursorPosIterator = |
76 cursorMovementIterator(&str[startIndex], length); | 76 cursorMovementIterator(&str[startIndex], length); |
77 | 77 |
78 int cursorPos = cursorPosIterator->current(); | 78 int cursorPos = cursorPosIterator->current(); |
79 int numGraphemes = -1; | 79 int numGraphemes = -1; |
80 while (0 <= cursorPos) { | 80 while (0 <= cursorPos) { |
81 cursorPos = cursorPosIterator->next(); | 81 cursorPos = cursorPosIterator->next(); |
82 numGraphemes++; | 82 numGraphemes++; |
83 } | 83 } |
84 return std::max(0, numGraphemes); | 84 return std::max(0, numGraphemes); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 457 } |
458 targetX -= wordResult->width(); | 458 targetX -= wordResult->width(); |
459 } | 459 } |
460 } else { | 460 } else { |
461 totalOffset = 0; | 461 totalOffset = 0; |
462 for (const auto& wordResult : m_results) { | 462 for (const auto& wordResult : m_results) { |
463 if (!wordResult) | 463 if (!wordResult) |
464 continue; | 464 continue; |
465 int offsetForWord = | 465 int offsetForWord = |
466 wordResult->offsetForPosition(targetX, includePartialGlyphs); | 466 wordResult->offsetForPosition(targetX, includePartialGlyphs); |
467 ASSERT(offsetForWord >= 0); | 467 DCHECK_GE(offsetForWord, 0); |
468 totalOffset += offsetForWord; | 468 totalOffset += offsetForWord; |
469 if (targetX >= 0 && targetX <= wordResult->width()) | 469 if (targetX >= 0 && targetX <= wordResult->width()) |
470 return totalOffset; | 470 return totalOffset; |
471 targetX -= wordResult->width(); | 471 targetX -= wordResult->width(); |
472 } | 472 } |
473 } | 473 } |
474 return totalOffset; | 474 return totalOffset; |
475 } | 475 } |
476 | 476 |
477 Vector<ShapeResultBuffer::RunFontData> | 477 Vector<ShapeResultBuffer::RunFontData> |
(...skipping 20 matching lines...) Expand all Loading... |
498 return GlyphData( | 498 return GlyphData( |
499 run->m_glyphData[0].glyph, | 499 run->m_glyphData[0].glyph, |
500 run->m_fontData->emphasisMarkFontData(fontDescription).get()); | 500 run->m_fontData->emphasisMarkFontData(fontDescription).get()); |
501 } | 501 } |
502 } | 502 } |
503 | 503 |
504 return GlyphData(); | 504 return GlyphData(); |
505 } | 505 } |
506 | 506 |
507 } // namespace blink | 507 } // namespace blink |
OLD | NEW |