Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: ui/gfx/text_utils.cc

Issue 1543183002: Switch to standard integer types in ui/gfx/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/text_utils.h ('k') | ui/gfx/text_utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/gfx/text_utils.h ('k') | ui/gfx/text_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698