diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-16 06:48:57 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-16 06:48:57 +0000 |
commit | 54afbdabc029fe49fc39bf121b47024a37e7f6ad (patch) | |
tree | 3e4d647c2181cb19138be567822c55c159e0ba7c /chrome/renderer/spellchecker/spellcheck.cc | |
parent | 31e1c1fa33a728878bffba2739b1676af25db865 (diff) | |
download | chromium_src-54afbdabc029fe49fc39bf121b47024a37e7f6ad.zip chromium_src-54afbdabc029fe49fc39bf121b47024a37e7f6ad.tar.gz chromium_src-54afbdabc029fe49fc39bf121b47024a37e7f6ad.tar.bz2 |
Revert 168052 - [Spellcheck] Removing cruft.
Resubmit of https://codereview.chromium.org/11377045, now with tests working
on OSX
R=rlp@chromium.org,sky@chromium.org
BUG=154918
Review URL: https://chromiumcodereview.appspot.com/11361265
TBR=groby@chromium.org
Review URL: https://codereview.chromium.org/11420035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168141 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/spellchecker/spellcheck.cc')
-rw-r--r-- | chrome/renderer/spellchecker/spellcheck.cc | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc index c470ac1..d289548 100644 --- a/chrome/renderer/spellchecker/spellcheck.cc +++ b/chrome/renderer/spellchecker/spellcheck.cc @@ -46,7 +46,6 @@ class SpellCheck::SpellcheckRequest { }; SpellCheck::SpellCheck() : auto_spell_correct_turned_on_(false) { - platform_spelling_engine_.reset(CreateNativeSpellingEngine()); } SpellCheck::~SpellCheck() { @@ -91,8 +90,19 @@ void SpellCheck::OnEnableAutoSpellCorrect(bool enable) { void SpellCheck::Init(base::PlatformFile file, const std::vector<std::string>& custom_words, const std::string& language) { - platform_spelling_engine_->Init(file, custom_words); - + bool use_platform_spelling_engine = + file == base::kInvalidPlatformFileValue && !language.empty(); + + // Some tests under OSX still exercise hunspell. Only init native engine + // when no dictionary was specified. + // TODO(groby): Figure out if we can kill the hunspell dependency for OSX. + if (use_platform_spelling_engine) { + platform_spelling_engine_.reset(CreateNativeSpellingEngine()); + } else { + HunspellEngine* engine = new HunspellEngine; + engine->Init(file, custom_words); + platform_spelling_engine_.reset(engine); + } character_attributes_.SetDefaultLanguage(language); text_iterator_.Reset(); contraction_iterator_.Reset(); @@ -271,8 +281,13 @@ void SpellCheck::RequestTextChecking( } #endif + bool SpellCheck::InitializeIfNeeded() { - DCHECK(platform_spelling_engine_.get()); + // TODO(groby): OSX creates a hunspell engine here, too. That seems + // wrong, but is (AFAICT) the existing flow. Fix that. + if (!platform_spelling_engine_.get()) + platform_spelling_engine_.reset(new HunspellEngine); + return platform_spelling_engine_->InitializeIfNeeded(); } @@ -344,8 +359,8 @@ bool SpellCheck::IsValidContraction(const string16& contraction, int tag) { return true; } +#if !defined(OS_MACOSX) void SpellCheck::CreateTextCheckingResults( - ResultFilter filter, int line_offset, const string16& line_text, const std::vector<SpellCheckResult>& spellcheck_results, @@ -360,8 +375,7 @@ void SpellCheck::CreateTextCheckingResults( static_cast<WebTextCheckingType>(spellcheck_results[i].type); int word_location = spellcheck_results[i].location; int word_length = spellcheck_results[i].length; - if (type == WebKit::WebTextCheckingTypeSpelling && - filter == USE_NATIVE_CHECKER) { + if (type == WebKit::WebTextCheckingTypeSpelling) { int misspelling_start = 0; int misspelling_length = 0; if (SpellCheckWord(text + word_location, word_length, 0, @@ -376,3 +390,4 @@ void SpellCheck::CreateTextCheckingResults( } textcheck_results->swap(list); } +#endif |