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

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: Addressed comments. 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..e308115a36ba988b4ee3a36ef15f1907a563fefe 100644
--- a/chrome/renderer/spellchecker/spellcheck_language.cc
+++ b/chrome/renderer/spellchecker/spellcheck_language.cc
@@ -67,7 +67,14 @@ 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)) {
+ for (SpellcheckWordIterator::WordIteratorStatus status =
+ text_iterator_.GetNextWord(&word, &word_start, &word_length);
+ status != SpellcheckWordIterator::IS_END_OF_TEXT;
+ status = text_iterator_.GetNextWord(&word, &word_start, &word_length)) {
+ // Found a character that is not able to be spellchecked so skip it.
+ if (status == SpellcheckWordIterator::IS_SKIPPABLE)
+ continue;
+
// Found a word (or a contraction) that the spellchecker can check the
// spelling of.
if (platform_spelling_engine_->CheckSpelling(word, tag))
@@ -112,7 +119,14 @@ bool SpellcheckLanguage::IsValidContraction(const base::string16& contraction,
int word_length;
DCHECK(platform_spelling_engine_.get());
- while (contraction_iterator_.GetNextWord(&word, &word_start, &word_length)) {
+ for (SpellcheckWordIterator::WordIteratorStatus status =
+ contraction_iterator_.GetNextWord(&word, &word_start, &word_length);
+ status != SpellcheckWordIterator::IS_END_OF_TEXT;
+ status = contraction_iterator_.GetNextWord(&word, &word_start,
+ &word_length)) {
+ if (status == SpellcheckWordIterator::IS_SKIPPABLE)
+ continue;
+
if (!platform_spelling_engine_->CheckSpelling(word, tag))
return false;
}

Powered by Google App Engine
This is Rietveld 408576698