Chromium Code Reviews| Index: chrome/renderer/spellchecker/spellcheck_language.cc |
| diff --git a/chrome/renderer/spellchecker/spellcheck_language.cc b/chrome/renderer/spellchecker/spellcheck_language.cc |
| index c7ad42df1d734bc445b0349fdcc4e9bf6f3db9bd..61381cebf4d60e4ff449c5208dc1f57a1551c807 100644 |
| --- a/chrome/renderer/spellchecker/spellcheck_language.cc |
| +++ b/chrome/renderer/spellchecker/spellcheck_language.cc |
| @@ -67,16 +67,28 @@ bool SpellcheckLanguage::SpellCheckWord( |
| text_iterator_.SetText(in_word, in_word_len); |
| DCHECK(platform_spelling_engine_.get()); |
| - while (text_iterator_.GetNextWord(&word, &word_start, &word_length)) { |
| + SpellcheckWordIterator::WordIteratorStatus status = |
| + text_iterator_.GetNextWord(&word, &word_start, &word_length); |
| + while (status != SpellcheckWordIterator::IS_END_OF_TEXT) { |
|
please use gerrit instead
2015/08/11 22:54:10
Is this loop easier to understand? Should be less
Julius
2015/08/12 20:25:59
Done.
|
| + // Found a character that is not able to be spellchecked so skip it. |
| + if (status == SpellcheckWordIterator::IS_SKIPPABLE_CHAR) { |
| + status = text_iterator_.GetNextWord(&word, &word_start, &word_length); |
| + continue; |
| + } |
| + |
| // Found a word (or a contraction) that the spellchecker can check the |
| // spelling of. |
| - if (platform_spelling_engine_->CheckSpelling(word, tag)) |
| + if (platform_spelling_engine_->CheckSpelling(word, tag)) { |
| + status = text_iterator_.GetNextWord(&word, &word_start, &word_length); |
| continue; |
| + } |
| // If the given word is a concatenated word of two or more valid words |
| // (e.g. "hello:hello"), we should treat it as a valid word. |
| - if (IsValidContraction(word, tag)) |
| + if (IsValidContraction(word, tag)) { |
| + status = text_iterator_.GetNextWord(&word, &word_start, &word_length); |
| continue; |
| + } |
| *misspelling_start = word_start; |
| *misspelling_len = word_length; |
| @@ -112,9 +124,13 @@ bool SpellcheckLanguage::IsValidContraction(const base::string16& contraction, |
| int word_length; |
| DCHECK(platform_spelling_engine_.get()); |
| - while (contraction_iterator_.GetNextWord(&word, &word_start, &word_length)) { |
| + SpellcheckWordIterator::WordIteratorStatus status = |
| + contraction_iterator_.GetNextWord(&word, &word_start, &word_length); |
| + while (status != SpellcheckWordIterator::IS_END_OF_TEXT) { |
|
please use gerrit instead
2015/08/11 22:54:10
for loop again.
Julius
2015/08/12 20:25:59
Done.
|
| if (!platform_spelling_engine_->CheckSpelling(word, tag)) |
| return false; |
| + status = |
| + contraction_iterator_.GetNextWord(&word, &word_start, &word_length); |
| } |
| return true; |
| } |