| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 inline unsigned CountGraphemesInCluster(const UChar* str, | 66 inline unsigned CountGraphemesInCluster(const UChar* str, |
| 67 unsigned str_length, | 67 unsigned str_length, |
| 68 uint16_t start_index, | 68 uint16_t start_index, |
| 69 uint16_t end_index) { | 69 uint16_t end_index) { |
| 70 if (start_index > end_index) { | 70 if (start_index > end_index) { |
| 71 uint16_t temp_index = start_index; | 71 uint16_t temp_index = start_index; |
| 72 start_index = end_index; | 72 start_index = end_index; |
| 73 end_index = temp_index; | 73 end_index = temp_index; |
| 74 } | 74 } |
| 75 uint16_t length = end_index - start_index; | 75 uint16_t length = end_index - start_index; |
| 76 ASSERT(static_cast<unsigned>(start_index + length) <= str_length); | 76 DCHECK_LE(static_cast<unsigned>(start_index + length), str_length); |
| 77 TextBreakIterator* cursor_pos_iterator = | 77 TextBreakIterator* cursor_pos_iterator = |
| 78 CursorMovementIterator(&str[start_index], length); | 78 CursorMovementIterator(&str[start_index], length); |
| 79 | 79 |
| 80 int cursor_pos = cursor_pos_iterator->current(); | 80 int cursor_pos = cursor_pos_iterator->current(); |
| 81 int num_graphemes = -1; | 81 int num_graphemes = -1; |
| 82 while (0 <= cursor_pos) { | 82 while (0 <= cursor_pos) { |
| 83 cursor_pos = cursor_pos_iterator->next(); | 83 cursor_pos = cursor_pos_iterator->next(); |
| 84 num_graphemes++; | 84 num_graphemes++; |
| 85 } | 85 } |
| 86 return std::max(0, num_graphemes); | 86 return std::max(0, num_graphemes); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 } | 461 } |
| 462 target_x -= word_result->Width(); | 462 target_x -= word_result->Width(); |
| 463 } | 463 } |
| 464 } else { | 464 } else { |
| 465 total_offset = 0; | 465 total_offset = 0; |
| 466 for (const auto& word_result : results_) { | 466 for (const auto& word_result : results_) { |
| 467 if (!word_result) | 467 if (!word_result) |
| 468 continue; | 468 continue; |
| 469 int offset_for_word = | 469 int offset_for_word = |
| 470 word_result->OffsetForPosition(target_x, include_partial_glyphs); | 470 word_result->OffsetForPosition(target_x, include_partial_glyphs); |
| 471 ASSERT(offset_for_word >= 0); | 471 DCHECK_GE(offset_for_word, 0); |
| 472 total_offset += offset_for_word; | 472 total_offset += offset_for_word; |
| 473 if (target_x >= 0 && target_x <= word_result->Width()) | 473 if (target_x >= 0 && target_x <= word_result->Width()) |
| 474 return total_offset; | 474 return total_offset; |
| 475 target_x -= word_result->Width(); | 475 target_x -= word_result->Width(); |
| 476 } | 476 } |
| 477 } | 477 } |
| 478 return total_offset; | 478 return total_offset; |
| 479 } | 479 } |
| 480 | 480 |
| 481 Vector<ShapeResultBuffer::RunFontData> ShapeResultBuffer::GetRunFontData() | 481 Vector<ShapeResultBuffer::RunFontData> ShapeResultBuffer::GetRunFontData() |
| (...skipping 20 matching lines...) Expand all Loading... |
| 502 return GlyphData( | 502 return GlyphData( |
| 503 run->glyph_data_[0].glyph, | 503 run->glyph_data_[0].glyph, |
| 504 run->font_data_->EmphasisMarkFontData(font_description).Get()); | 504 run->font_data_->EmphasisMarkFontData(font_description).Get()); |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 | 507 |
| 508 return GlyphData(); | 508 return GlyphData(); |
| 509 } | 509 } |
| 510 | 510 |
| 511 } // namespace blink | 511 } // namespace blink |
| OLD | NEW |