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

Unified Diff: chrome/renderer/spellchecker/spellcheck_language.cc

Issue 1269343005: Updates SpellcheckWordIterator::GetNextWord to return an enum. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@break-iter
Patch Set: Updates comments and preserves functionality in tests. Created 5 years, 4 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: 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;
}

Powered by Google App Engine
This is Rietveld 408576698