OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/app_list/search/term_break_iterator.h" | 5 #include "ui/app_list/search/term_break_iterator.h" |
6 | 6 |
7 #include "base/i18n/char_iterator.h" | 7 #include "base/i18n/char_iterator.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "third_party/icu/source/common/unicode/uchar.h" | 10 #include "third_party/icu/source/common/unicode/uchar.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 return prev_ != pos_ || !iter_->end(); | 48 return prev_ != pos_ || !iter_->end(); |
49 } | 49 } |
50 | 50 |
51 const base::string16 TermBreakIterator::GetCurrentTerm() const { | 51 const base::string16 TermBreakIterator::GetCurrentTerm() const { |
52 DCHECK(prev_ != npos && pos_ != npos); | 52 DCHECK(prev_ != npos && pos_ != npos); |
53 return word_.substr(prev_, pos_ - prev_); | 53 return word_.substr(prev_, pos_ - prev_); |
54 } | 54 } |
55 | 55 |
56 TermBreakIterator::State TermBreakIterator::GetNewState(base::char16 ch) { | 56 TermBreakIterator::State TermBreakIterator::GetNewState(base::char16 ch) { |
57 if (IsAsciiDigit(ch) || ch == '.' || ch == ',') | 57 if (base::IsAsciiDigit(ch) || ch == '.' || ch == ',') |
58 return STATE_NUMBER; | 58 return STATE_NUMBER; |
59 | 59 |
60 const bool is_upper = !!u_isUUppercase(ch); | 60 const bool is_upper = !!u_isUUppercase(ch); |
61 const bool is_lower = !!u_isULowercase(ch); | 61 const bool is_lower = !!u_isULowercase(ch); |
62 | 62 |
63 if (is_upper && is_lower) { | 63 if (is_upper && is_lower) { |
64 NOTREACHED() << "Invalid state for ch=" << ch; | 64 NOTREACHED() << "Invalid state for ch=" << ch; |
65 return STATE_CHAR; | 65 return STATE_CHAR; |
66 } | 66 } |
67 | 67 |
68 if (is_upper) | 68 if (is_upper) |
69 return STATE_UPPER; | 69 return STATE_UPPER; |
70 if (is_lower) | 70 if (is_lower) |
71 return STATE_LOWER; | 71 return STATE_LOWER; |
72 | 72 |
73 return STATE_CHAR; | 73 return STATE_CHAR; |
74 } | 74 } |
75 | 75 |
76 } // namespace app_list | 76 } // namespace app_list |
OLD | NEW |