OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "ui/gfx/text_utils.h" | 5 #include "ui/gfx/text_utils.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/i18n/char_iterator.h" | 9 #include "base/i18n/char_iterator.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
10 #include "third_party/icu/source/common/unicode/uchar.h" | 12 #include "third_party/icu/source/common/unicode/uchar.h" |
11 #include "third_party/icu/source/common/unicode/utf16.h" | 13 #include "third_party/icu/source/common/unicode/utf16.h" |
12 | 14 |
13 namespace gfx { | 15 namespace gfx { |
14 | 16 |
15 namespace { | 17 namespace { |
16 | 18 |
(...skipping 20 matching lines...) Expand all Loading... |
37 int* accelerated_char_pos, | 39 int* accelerated_char_pos, |
38 int* accelerated_char_span) { | 40 int* accelerated_char_span) { |
39 bool escaped = false; | 41 bool escaped = false; |
40 ptrdiff_t last_char_pos = -1; | 42 ptrdiff_t last_char_pos = -1; |
41 int last_char_span = 0; | 43 int last_char_span = 0; |
42 base::i18n::UTF16CharIterator chars(&s); | 44 base::i18n::UTF16CharIterator chars(&s); |
43 base::string16 accelerator_removed; | 45 base::string16 accelerator_removed; |
44 | 46 |
45 accelerator_removed.reserve(s.size()); | 47 accelerator_removed.reserve(s.size()); |
46 while (!chars.end()) { | 48 while (!chars.end()) { |
47 int32 c = chars.get(); | 49 int32_t c = chars.get(); |
48 int array_pos = chars.array_pos(); | 50 int array_pos = chars.array_pos(); |
49 chars.Advance(); | 51 chars.Advance(); |
50 | 52 |
51 if (c != accelerator_char || escaped) { | 53 if (c != accelerator_char || escaped) { |
52 int span = chars.array_pos() - array_pos; | 54 int span = chars.array_pos() - array_pos; |
53 if (escaped && c != accelerator_char) { | 55 if (escaped && c != accelerator_char) { |
54 last_char_pos = accelerator_removed.size(); | 56 last_char_pos = accelerator_removed.size(); |
55 last_char_span = span; | 57 last_char_span = span; |
56 } | 58 } |
57 for (int i = 0; i < span; i++) | 59 for (int i = 0; i < span; i++) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 CharIsMark(GetCodePointAt(text, text_index))) { | 102 CharIsMark(GetCodePointAt(text, text_index))) { |
101 ++text_index; | 103 ++text_index; |
102 } | 104 } |
103 | 105 |
104 // If |index| straddles a UTF-16 surrogate pair, go forward. | 106 // If |index| straddles a UTF-16 surrogate pair, go forward. |
105 U16_SET_CP_LIMIT(text.data(), 0, text_index, text_length); | 107 U16_SET_CP_LIMIT(text.data(), 0, text_index, text_length); |
106 return static_cast<size_t>(text_index); | 108 return static_cast<size_t>(text_index); |
107 } | 109 } |
108 | 110 |
109 } // namespace gfx | 111 } // namespace gfx |
OLD | NEW |