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

Unified 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: reuse breakiterator Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: base/i18n/break_iterator.cc
diff --git a/base/i18n/break_iterator.cc b/base/i18n/break_iterator.cc
index fe26a03a0b89fa85ba7501d4aaf9dd59464369f3..4d72a9f8e84665ee27c178beb3163dc06cba22ed 100644
--- a/base/i18n/break_iterator.cc
+++ b/base/i18n/break_iterator.cc
@@ -138,13 +138,13 @@ bool BreakIterator::SetText(const base::char16* text, const size_t length) {
bool BreakIterator::IsWord() const {
int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_));
if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED)
- return false;
+ return false;
return status != UBRK_WORD_NONE;
}
bool BreakIterator::IsEndOfWord(size_t position) const {
if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED)
- return false;
+ return false;
UBreakIterator* iter = static_cast<UBreakIterator*>(iter_);
UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position));
@@ -154,7 +154,7 @@ bool BreakIterator::IsEndOfWord(size_t position) const {
bool BreakIterator::IsStartOfWord(size_t position) const {
if (break_type_ != BREAK_WORD && break_type_ != RULE_BASED)
- return false;
+ return false;
UBreakIterator* iter = static_cast<UBreakIterator*>(iter_);
UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position));
@@ -163,6 +163,14 @@ bool BreakIterator::IsStartOfWord(size_t position) const {
return (!!boundary && next_status != UBRK_WORD_NONE);
}
+bool BreakIterator::IsGraphemeBoundary(size_t position) const {
+ if (break_type_ != BREAK_CHARACTER)
msw 2014/06/29 22:29:09 q: Wouldn't any other break type work, except perh
ckocagil 2014/07/24 21:46:55 Makes sense, but I'm not sure. We can ask the Brea
msw 2014/07/25 00:36:59 +jshin for thoughts here and general BreakIterator
+ return false;
+
+ UBreakIterator* iter = static_cast<UBreakIterator*>(iter_);
+ return !!ubrk_isBoundary(iter, static_cast<int32_t>(position));
+}
+
string16 BreakIterator::GetString() const {
DCHECK(prev_ != npos && pos_ != npos);
return string_.substr(prev_, pos_ - prev_);

Powered by Google App Engine
This is Rietveld 408576698