Index: chrome/renderer/spellchecker/spellcheck_worditerator.h |
diff --git a/chrome/renderer/spellchecker/spellcheck_worditerator.h b/chrome/renderer/spellchecker/spellcheck_worditerator.h |
index 6b6a2f4eac20bc1884c79a2ce1a99aa604aaa09f..3d17c684a7be82cb6d06e5638d037e97bd0c0c09 100644 |
--- a/chrome/renderer/spellchecker/spellcheck_worditerator.h |
+++ b/chrome/renderer/spellchecker/spellcheck_worditerator.h |
@@ -112,6 +112,17 @@ class SpellcheckCharAttribute { |
// |
class SpellcheckWordIterator { |
public: |
+ enum WordIteratorStatus { |
+ // The end of a sequence of text that the iterator recognizes as characters |
+ // that can form a word. |
+ IS_WORD, |
+ // Non-word characters that the iterator can skip past, such as punctuation, |
+ // whitespace, and characters from another character set. |
+ IS_SKIPPABLE, |
+ // The end of the text that the iterator is going over. |
+ IS_END_OF_TEXT |
+ }; |
+ |
SpellcheckWordIterator(); |
~SpellcheckWordIterator(); |
@@ -130,19 +141,30 @@ class SpellcheckWordIterator { |
// without calling Initialize(). |
bool SetText(const base::char16* text, size_t length); |
- // Retrieves a word (or a contraction), stores its copy to 'word_string', and |
- // stores the position and the length for input word to 'word_start'. Since |
- // this function normalizes the output word, the length of 'word_string' may |
- // be different from the 'word_length'. Therefore, when we call functions that |
- // changes the input text, such as string16::replace(), we need to use |
- // 'word_start' and 'word_length' as listed in the following snippet. |
+ // Advances |iterator_| through |text_| and gets the current status of the |
+ // word iterator within |text|: |
+ // |
+ // - Returns IS_WORD if the iterator just found the end of a sequence of word |
+ // characters and it was able to normalize the sequence. This stores the |
+ // normalized string into |word_string| and stores the position and length |
+ // into |word_start| and |word_length| respectively. Keep in mind that |
+ // since this function normalizes the output word, the length of |
+ // |word_string| may be different from the |word_length|. Therefore, when |
+ // we call functions that change the input text, such as |
+ // string16::replace(), we need to use |word_start| and |word_length| as |
+ // listed in the following snippet: |
+ // |
+ // while(iterator.GetNextWord(&word, &offset, &length)) |
+ // text.replace(offset, length, word); |
// |
- // while(iterator.GetNextWord(&word, &offset, &length)) |
- // text.replace(offset, length, word); |
+ // - Returns IS_SKIPPABLE if the iterator just found a character that the |
+ // iterator can skip past such as punctuation, whitespace, and characters |
+ // from another character set. This stores the character, position, and |
+ // length into |word_string|, |word_start|, and |word_length| respectively. |
// |
- bool GetNextWord(base::string16* word_string, |
- int* word_start, |
- int* word_length); |
+ // - Returns IS_END_OF_TEXT if the iterator has reached the end of |text_|. |
+ SpellcheckWordIterator::WordIteratorStatus |
+ GetNextWord(base::string16* word_string, int* word_start, int* word_length); |
// Releases all the resources attached to this object. |
void Reset(); |