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

Side by Side Diff: base/i18n/char_iterator.cc

Issue 23522018: RenderTextWin: Break runs between any two characters that are not in the same code block (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use CharIterator Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/i18n/char_iterator.h" 5 #include "base/i18n/char_iterator.h"
6 6
7 #include "third_party/icu/source/common/unicode/utf8.h" 7 #include "third_party/icu/source/common/unicode/utf8.h"
8 #include "third_party/icu/source/common/unicode/utf16.h" 8 #include "third_party/icu/source/common/unicode/utf16.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 18 matching lines...) Expand all
29 return false; 29 return false;
30 30
31 array_pos_ = next_pos_; 31 array_pos_ = next_pos_;
32 char_pos_++; 32 char_pos_++;
33 if (next_pos_ < len_) 33 if (next_pos_ < len_)
34 U8_NEXT(str_, next_pos_, len_, char_); 34 U8_NEXT(str_, next_pos_, len_, char_);
35 35
36 return true; 36 return true;
37 } 37 }
38 38
39 void UTF8CharIterator::SetPosition(int32 position) {
40 U8_SET_CP_START(str_, position, array_pos_);
41 next_pos_ = array_pos_;
42 U8_NEXT(str_, next_pos_, len_, char_);
43 }
44
39 UTF16CharIterator::UTF16CharIterator(const string16* str) 45 UTF16CharIterator::UTF16CharIterator(const string16* str)
40 : str_(reinterpret_cast<const char16*>(str->data())), 46 : str_(reinterpret_cast<const char16*>(str->data())),
41 len_(str->size()), 47 len_(str->size()),
42 array_pos_(0), 48 array_pos_(0),
43 next_pos_(0), 49 next_pos_(0),
44 char_pos_(0), 50 char_pos_(0),
45 char_(0) { 51 char_(0) {
46 if (len_) 52 if (len_)
47 ReadChar(); 53 ReadChar();
48 } 54 }
(...skipping 17 matching lines...) Expand all
66 return false; 72 return false;
67 73
68 array_pos_ = next_pos_; 74 array_pos_ = next_pos_;
69 char_pos_++; 75 char_pos_++;
70 if (next_pos_ < len_) 76 if (next_pos_ < len_)
71 ReadChar(); 77 ReadChar();
72 78
73 return true; 79 return true;
74 } 80 }
75 81
82 void UTF16CharIterator::SetPosition(int32 position) {
83 array_pos_ = position;
84 U16_SET_CP_START(str_, 0, array_pos_);
85 next_pos_ = array_pos_;
86 ReadChar();
87 }
88
76 void UTF16CharIterator::ReadChar() { 89 void UTF16CharIterator::ReadChar() {
77 // This is actually a huge macro, so is worth having in a separate function. 90 // This is actually a huge macro, so is worth having in a separate function.
78 U16_NEXT(str_, next_pos_, len_, char_); 91 U16_NEXT(str_, next_pos_, len_, char_);
79 } 92 }
80 93
81 } // namespace i18n 94 } // namespace i18n
82 } // namespace base 95 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/char_iterator.h ('k') | ui/gfx/render_text_win.cc » ('j') | ui/gfx/render_text_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698