Index: chrome/renderer/spellchecker/spellcheck_worditerator.cc |
diff --git a/chrome/renderer/spellchecker/spellcheck_worditerator.cc b/chrome/renderer/spellchecker/spellcheck_worditerator.cc |
index cf5249c4a75ebd2c3d50e7697953b525d7cb87d4..7f261d488816e7bd5e61c15e26cbe86af5205ab6 100644 |
--- a/chrome/renderer/spellchecker/spellcheck_worditerator.cc |
+++ b/chrome/renderer/spellchecker/spellcheck_worditerator.cc |
@@ -20,6 +20,8 @@ |
#include "third_party/icu/source/common/unicode/uscript.h" |
#include "third_party/icu/source/i18n/unicode/ulocdata.h" |
+using base::i18n::BreakIterator; |
+ |
// SpellcheckCharAttribute implementation: |
SpellcheckCharAttribute::SpellcheckCharAttribute() |
@@ -324,8 +326,7 @@ bool SpellcheckWordIterator::Initialize( |
if (rule.empty()) |
return false; |
- scoped_ptr<base::i18n::BreakIterator> iterator( |
- new base::i18n::BreakIterator(base::string16(), rule)); |
+ scoped_ptr<BreakIterator> iterator(new BreakIterator(base::string16(), rule)); |
if (!iterator->Init()) { |
// Since we're not passing in any text, the only reason this could fail |
// is if we fail to parse the rules. Since the rules are hardcoded, |
@@ -359,9 +360,10 @@ bool SpellcheckWordIterator::SetText(const base::char16* text, size_t length) { |
return true; |
} |
-bool SpellcheckWordIterator::GetNextWord(base::string16* word_string, |
- int* word_start, |
- int* word_length) { |
+SpellcheckWordIterator::WordIteratorStatus SpellcheckWordIterator::GetNextWord( |
+ base::string16* word_string, |
+ int* word_start, |
+ int* word_length) { |
DCHECK(!!text_); |
word_string->clear(); |
@@ -369,28 +371,31 @@ bool SpellcheckWordIterator::GetNextWord(base::string16* word_string, |
*word_length = 0; |
if (!text_) { |
- return false; |
+ return IS_END_OF_TEXT; |
} |
- // Find a word that can be checked for spelling. Our rule sets filter out |
- // invalid words (e.g. numbers and characters not supported by the |
- // spellchecker language) so this ubrk_getRuleStatus() call returns |
- // UBRK_WORD_NONE when this iterator finds an invalid word. So, we skip such |
- // words until we can find a valid word or reach the end of the input string. |
+ // Find a word that can be checked for spelling or a character that can be |
+ // skipped over. Rather than moving past a skippable character this returns |
+ // IS_SKIPPABLE_CHAR and defers handling the character to the calling |
+ // function. |
while (iterator_->Advance()) { |
const size_t start = iterator_->prev(); |
const size_t length = iterator_->pos() - start; |
- if (iterator_->IsWord()) { |
+ BreakIterator::WordBreakStatus break_status = |
+ iterator_->GetWordBreakStatus(); |
+ if (break_status == BreakIterator::IS_WORD_BREAK) { |
if (Normalize(start, length, word_string)) { |
*word_start = start; |
*word_length = length; |
- return true; |
+ return IS_WORD; |
} |
+ } else if (break_status == BreakIterator::IS_SKIPPABLE_WORD) { |
+ return IS_SKIPPABLE_CHAR; |
please use gerrit instead
2015/08/11 22:54:10
You should update the |word_string|, |word_start|,
Julius
2015/08/12 20:25:59
Done.
|
} |
} |
// There aren't any more words in the given text. |
- return false; |
+ return IS_END_OF_TEXT; |
} |
void SpellcheckWordIterator::Reset() { |