Bug 967494 - Sync spell checking dictionaries with Subject, Body and spellchecker.dictionary preference. r=ehsan

--HG--
extra : rebase_source : a20dc10ab6047ccc7dab58eb32b5eb96c7610545
This commit is contained in:
Jan Horak 2014-09-10 17:58:41 -04:00
parent a8a6665c3d
commit 7fe6dfc357
2 changed files with 28 additions and 17 deletions

View File

@ -738,27 +738,33 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
return NS_OK;
}
mPreferredLang.Assign(aFetcher->mRootContentLang);
// If we successfully fetched a dictionary from content prefs, do not go
// further. Use this exact dictionary.
nsAutoString dictName;
dictName.Assign(aFetcher->mDictionary);
if (!dictName.IsEmpty()) {
if (NS_FAILED(SetCurrentDictionary(dictName))) {
// may be dictionary was uninstalled ?
ClearCurrentDictionary(mEditor);
uint32_t flags;
mEditor->GetFlags(&flags);
// Don't use the content pref when writing mail
if (!(flags & nsIPlaintextEditor::eEditorMailMask)) {
mPreferredLang.Assign(aFetcher->mRootContentLang);
// If we successfully fetched a dictionary from content prefs, do not go
// further. Use this exact dictionary.
nsAutoString dictName;
dictName.Assign(aFetcher->mDictionary);
if (!dictName.IsEmpty()) {
if (NS_FAILED(SetCurrentDictionary(dictName))) {
// may be dictionary was uninstalled ?
ClearCurrentDictionary(mEditor);
}
return NS_OK;
}
return NS_OK;
}
if (mPreferredLang.IsEmpty()) {
mPreferredLang.Assign(aFetcher->mRootDocContentLang);
}
if (mPreferredLang.IsEmpty()) {
mPreferredLang.Assign(aFetcher->mRootDocContentLang);
}
// Then, try to use language computed from element
if (!mPreferredLang.IsEmpty()) {
dictName.Assign(mPreferredLang);
// Then, try to use language computed from element
if (!mPreferredLang.IsEmpty()) {
dictName.Assign(mPreferredLang);
}
}
// otherwise, get language from preferences

View File

@ -295,6 +295,11 @@ InlineSpellChecker.prototype = {
var spellchecker = this.mInlineSpellChecker.spellChecker;
spellchecker.SetCurrentDictionary(this.mDictionaryNames[index]);
this.mInlineSpellChecker.spellCheckRange(null); // causes recheck
// Save chosen dictionary to preferences only when writing mail
if (this.mEditor.flags & this.mEditor.eEditorMailMask) {
Components.utils.import("resource://gre/modules/Services.jsm");
Services.prefs.setCharPref("spellchecker.dictionary", this.mDictionaryNames[index]);
}
},
// callback for selecting a suggesteed replacement