| Index: chrome/renderer/spellchecker/hunspell_engine.cc
|
| diff --git a/chrome/renderer/spellchecker/hunspell_engine.cc b/chrome/renderer/spellchecker/hunspell_engine.cc
|
| index 71a14d2d5228c9cb54f5f0eceb92a77bdf98ed91..810a24d91f27e3416dd5cc8b139927b71189401b 100644
|
| --- a/chrome/renderer/spellchecker/hunspell_engine.cc
|
| +++ b/chrome/renderer/spellchecker/hunspell_engine.cc
|
| @@ -56,9 +56,7 @@ void HunspellEngine::InitializeHunspell() {
|
| new Hunspell(bdict_file_->data(), bdict_file_->length()));
|
|
|
| // Add custom words to Hunspell.
|
| - chrome::spellcheck_common::WordList::iterator it;
|
| - for (it = custom_words_.begin(); it != custom_words_.end(); ++it)
|
| - AddWordToHunspell(*it);
|
| + AddWordsToHunspell(custom_words_);
|
|
|
| DHISTOGRAM_TIMES("Spellcheck.InitTime",
|
| base::Histogram::DebugNow() - debug_start_time);
|
| @@ -67,14 +65,27 @@ void HunspellEngine::InitializeHunspell() {
|
| }
|
| }
|
|
|
| -void HunspellEngine::AddWordToHunspell(const std::string& word) {
|
| - if (!word.empty() && word.length() < MAXWORDLEN)
|
| - hunspell_->add(word.c_str());
|
| +void HunspellEngine::AddWordsToHunspell(const std::vector<std::string>& words) {
|
| + std::string word;
|
| + for (chrome::spellcheck_common::WordList::const_iterator it = words.begin();
|
| + it != words.end();
|
| + ++it) {
|
| + word = *it;
|
| + if (!word.empty() && word.length() < MAXWORDLEN)
|
| + hunspell_->add(word.c_str());
|
| + }
|
| }
|
|
|
| -void HunspellEngine::RemoveWordFromHunspell(const std::string& word) {
|
| - if (!word.empty() && word.length() < MAXWORDLEN)
|
| - hunspell_->remove(word.c_str());
|
| +void HunspellEngine::RemoveWordsFromHunspell(
|
| + const std::vector<std::string>& words) {
|
| + std::string word;
|
| + for (std::vector<std::string>::const_iterator it = words.begin();
|
| + it != words.end();
|
| + ++it) {
|
| + word = *it;
|
| + if (!word.empty() && word.length() < MAXWORDLEN)
|
| + hunspell_->remove(word.c_str());
|
| + }
|
| }
|
|
|
| bool HunspellEngine::CheckSpelling(const string16& word_to_check, int tag) {
|
| @@ -84,7 +95,7 @@ bool HunspellEngine::CheckSpelling(const string16& word_to_check, int tag) {
|
| if (word_to_check_utf8.length() < MAXWORDLEN) {
|
| if (hunspell_.get()) {
|
| // |hunspell_->spell| returns 0 if the word is spelled correctly and
|
| - // non-zero otherwsie.
|
| + // non-zero otherwise.
|
| word_correct = (hunspell_->spell(word_to_check_utf8.c_str()) != 0);
|
| } else {
|
| // If |hunspell_| is NULL here, an error has occurred, but it's better
|
| @@ -119,23 +130,27 @@ void HunspellEngine::FillSuggestionList(
|
| free(suggestions);
|
| }
|
|
|
| -void HunspellEngine::OnWordAdded(const std::string& word) {
|
| +void HunspellEngine::OnWordsAdded(const std::vector<std::string>& words) {
|
| if (!hunspell_.get()) {
|
| // Save it for later---add it when hunspell is initialized.
|
| - custom_words_.push_back(word);
|
| + custom_words_.insert(custom_words_.end(), words.begin(), words.end());
|
| } else {
|
| - AddWordToHunspell(word);
|
| + AddWordsToHunspell(words);
|
| }
|
| }
|
|
|
| -void HunspellEngine::OnWordRemoved(const std::string& word) {
|
| +void HunspellEngine::OnWordsRemoved(const std::vector<std::string>& words) {
|
| if (!hunspell_.get()) {
|
| - chrome::spellcheck_common::WordList::iterator it = std::find(
|
| - custom_words_.begin(), custom_words_.end(), word);
|
| - if (it != custom_words_.end())
|
| - custom_words_.erase(it);
|
| + std::vector<std::string>::iterator it2;
|
| + for (std::vector<std::string>::const_iterator it = words.begin();
|
| + it != words.end();
|
| + ++it) {
|
| + it2 = std::find(custom_words_.begin(), custom_words_.end(), *it);
|
| + if (it2 != custom_words_.end())
|
| + custom_words_.erase(it2);
|
| + }
|
| } else {
|
| - RemoveWordFromHunspell(word);
|
| + RemoveWordsFromHunspell(words);
|
| }
|
| }
|
|
|
|
|