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

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

Issue 7841056: fix know issues in RenderText (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix a capitalization in break_iterator.h Created 9 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
« no previous file with comments | « base/i18n/break_iterator.h ('k') | ui/gfx/render_text.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 "unicode/ubrk.h" 8 #include "unicode/ubrk.h"
9 #include "unicode/uchar.h" 9 #include "unicode/uchar.h"
10 #include "unicode/ustring.h" 10 #include "unicode/ustring.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 NOTREACHED() << "invalid break_type_"; 85 NOTREACHED() << "invalid break_type_";
86 return false; 86 return false;
87 } 87 }
88 } 88 }
89 89
90 bool BreakIterator::IsWord() const { 90 bool BreakIterator::IsWord() const {
91 int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_)); 91 int32_t status = ubrk_getRuleStatus(static_cast<UBreakIterator*>(iter_));
92 return (break_type_ == BREAK_WORD && status != UBRK_WORD_NONE); 92 return (break_type_ == BREAK_WORD && status != UBRK_WORD_NONE);
93 } 93 }
94 94
95 bool BreakIterator::IsEndOfWord(size_t position) const {
96 if (break_type_ != BREAK_WORD)
97 return false;
98
99 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_);
100 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position));
101 int32_t status = ubrk_getRuleStatus(iter);
102 return (!!boundary && status != UBRK_WORD_NONE);
103 }
104
105 bool BreakIterator::IsStartOfWord(size_t position) const {
106 if (break_type_ != BREAK_WORD)
107 return false;
108
109 UBreakIterator* iter = static_cast<UBreakIterator*>(iter_);
110 UBool boundary = ubrk_isBoundary(iter, static_cast<int32_t>(position));
111 ubrk_next(iter);
112 int32_t next_status = ubrk_getRuleStatus(iter);
113 return (!!boundary && next_status != UBRK_WORD_NONE);
114 }
115
95 string16 BreakIterator::GetString() const { 116 string16 BreakIterator::GetString() const {
96 DCHECK(prev_ != npos && pos_ != npos); 117 DCHECK(prev_ != npos && pos_ != npos);
97 return string_.substr(prev_, pos_ - prev_); 118 return string_.substr(prev_, pos_ - prev_);
98 } 119 }
99 120
100 } // namespace i18n 121 } // namespace i18n
101 } // namespace base 122 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/break_iterator.h ('k') | ui/gfx/render_text.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698