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

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

Issue 351963002: RenderTextHarfBuzz: Allow mid-glyph cursors in multi-grapheme clusters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile fix Created 6 years, 4 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
« no previous file with comments | « base/i18n/break_iterator.h ('k') | ui/gfx/render_text_harfbuzz.h » ('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 (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/break_iterator.h" 5 #include "base/i18n/break_iterator.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/icu/source/common/unicode/ubrk.h" 8 #include "third_party/icu/source/common/unicode/ubrk.h"
9 #include "third_party/icu/source/common/unicode/uchar.h" 9 #include "third_party/icu/source/common/unicode/uchar.h"
10 #include "third_party/icu/source/common/unicode/ustring.h" 10 #include "third_party/icu/source/common/unicode/ustring.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (U_FAILURE(status)) { 131 if (U_FAILURE(status)) {
132 NOTREACHED() << "ubrk_setText failed"; 132 NOTREACHED() << "ubrk_setText failed";
133 return false; 133 return false;
134 } 134 }
135 return true; 135 return true;
136 } 136 }
137 137
138 bool BreakIterator::IsWord() const { 138 bool BreakIterator::IsWord() const {
139 int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)); 139 int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_));
140 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED) 140 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED)
141 return false; 141 return false;
142 return status != UBRK_WORD_NONE; 142 return status != UBRK_WORD_NONE;
143 } 143 }
144 144
145 bool BreakIterator::IsEndOfWord(size_t position) const { 145 bool BreakIterator::IsEndOfWord(size_t position) const {
146 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED) 146 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED)
147 return false; 147 return false;
148 148
149 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_); 149 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_);
150 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position)); 150 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position));
151 int32_t status = ubrk_getRuleStatus(iter); 151 int32_t status = ubrk_getRuleStatus(iter);
152 return (!!boundary && status != UBRK_WORD_NONE); 152 return (!!boundary && status != UBRK_WORD_NONE);
153 } 153 }
154 154
155 bool BreakIterator::IsStartOfWord(size_t position) const { 155 bool BreakIterator::IsStartOfWord(size_t position) const {
156 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED) 156 if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED)
157 return false; 157 return false;
158 158
159 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_); 159 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_);
160 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position)); 160 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position));
161 ubrk_next(iter); 161 ubrk_next(iter);
162 int32_t next_status = ubrk_getRuleStatus(iter); 162 int32_t next_status = ubrk_getRuleStatus(iter);
163 return (!!boundary && next_status != UBRK_WORD_NONE); 163 return (!!boundary && next_status != UBRK_WORD_NONE);
164 } 164 }
165 165
166 bool BreakIterator::IsGraphemeBoundary(size_t position) const {
167 if (break_type_ != BREAK_CHARACTER)
168 return false;
169
170 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_);
171 return !!ubrk_isBoundary(iter, static_cast<int32_t>(position));
172 }
173
166 string16 BreakIterator::GetString() const { 174 string16 BreakIterator::GetString() const {
167 DCHECK(prev_ != npos && pos_ != npos); 175 DCHECK(prev_ != npos && pos_ != npos);
168 return string_.substr(prev_, pos_ - prev_); 176 return string_.substr(prev_, pos_ - prev_);
169 } 177 }
170 178
171 } // namespace i18n 179 } // namespace i18n
172 } // namespace base 180 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/break_iterator.h ('k') | ui/gfx/render_text_harfbuzz.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698