diff --git a/editor/composer/nsEditorSpellCheck.cpp b/editor/composer/nsEditorSpellCheck.cpp index 7efc6a140c50..d96dc83a1cfa 100644 --- a/editor/composer/nsEditorSpellCheck.cpp +++ b/editor/composer/nsEditorSpellCheck.cpp @@ -635,34 +635,6 @@ nsEditorSpellCheck::SetCurrentDictionary(const nsAString& aDictionary) return mSpellChecker->SetCurrentDictionary(aDictionary); } -NS_IMETHODIMP -nsEditorSpellCheck::CheckCurrentDictionary() -{ - mSpellChecker->CheckCurrentDictionary(); - - // Check if our current dictionary is still available. - nsAutoString currentDictionary; - nsresult rv = GetCurrentDictionary(currentDictionary); - if (NS_SUCCEEDED(rv) && !currentDictionary.IsEmpty()) { - return NS_OK; - } - - // If our preferred current dictionary has gone, pick another one. - nsTArray dictList; - rv = mSpellChecker->GetDictionaryList(&dictList); - NS_ENSURE_SUCCESS(rv, rv); - - if (dictList.Length() > 0) { - // Use RAII object to prevent content preferences being written during - // this call. - UpdateDictionaryHolder holder(this); - rv = SetCurrentDictionary(dictList[0]); - NS_ENSURE_SUCCESS(rv, rv); - } - - return NS_OK; -} - NS_IMETHODIMP nsEditorSpellCheck::UninitSpellChecker() { @@ -835,6 +807,14 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher) #endif } + // Auxiliary status. + nsresult rv2; + + // We obtain a list of available dictionaries. + nsTArray dictList; + rv2 = mSpellChecker->GetDictionaryList(&dictList); + NS_ENSURE_SUCCESS(rv2, rv2); + // Priority 1: // If we successfully fetched a dictionary from content prefs, do not go // further. Use this exact dictionary. @@ -845,7 +825,7 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher) if (!(flags & nsIPlaintextEditor::eEditorMailMask)) { dictName.Assign(aFetcher->mDictionary); if (!dictName.IsEmpty()) { - if (NS_SUCCEEDED(SetCurrentDictionary(dictName))) { + if (NS_SUCCEEDED(TryDictionary(dictName, dictList, DICT_NORMAL_COMPARE))) { #ifdef DEBUG_DICT printf("***** Assigned from content preferences |%s|\n", NS_ConvertUTF16toUTF8(dictName).get()); @@ -871,14 +851,6 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher) NS_ConvertUTF16toUTF8(dictName).get()); #endif - // Auxiliary status. - nsresult rv2; - - // We obtain a list of available dictionaries. - nsTArray dictList; - rv2 = mSpellChecker->GetDictionaryList(&dictList); - NS_ENSURE_SUCCESS(rv2, rv2); - // Get the preference value. nsAutoString preferredDict; preferredDict = Preferences::GetLocalizedString("spellchecker.dictionary"); diff --git a/editor/libeditor/nsEditor.cpp b/editor/libeditor/nsEditor.cpp index 083b73861553..bfd12eae413e 100644 --- a/editor/libeditor/nsEditor.cpp +++ b/editor/libeditor/nsEditor.cpp @@ -1328,15 +1328,6 @@ NS_IMETHODIMP nsEditor::Observe(nsISupports* aSubj, const char *aTopic, // When nsIEditorSpellCheck::GetCurrentDictionary changes if (mInlineSpellChecker) { - // if the current dictionary is no longer available, find another one - nsCOMPtr editorSpellCheck; - mInlineSpellChecker->GetSpellChecker(getter_AddRefs(editorSpellCheck)); - if (editorSpellCheck) { - // Note: This might change the current dictionary, which may call - // this observer recursively. - editorSpellCheck->CheckCurrentDictionary(); - } - // update the inline spell checker to reflect the new current dictionary mInlineSpellChecker->SpellCheckRange(nullptr); // causes recheck } diff --git a/editor/nsIEditorSpellCheck.idl b/editor/nsIEditorSpellCheck.idl index c211742020d3..7e113a6102d0 100644 --- a/editor/nsIEditorSpellCheck.idl +++ b/editor/nsIEditorSpellCheck.idl @@ -9,17 +9,10 @@ interface nsIEditor; interface nsITextServicesFilter; interface nsIEditorSpellCheckCallback; -[scriptable, uuid(dd32ef3b-a7d8-43d1-9617-5f2dddbe29eb)] +[scriptable, uuid(c9e630b8-79fd-4546-b068-be1b2a84c347)] interface nsIEditorSpellCheck : nsISupports { - /** - * Call this on any change in installed dictionaries to ensure that the spell - * checker is not using a current dictionary which is no longer available. - * If the current dictionary is no longer available, then pick another one. - */ - void checkCurrentDictionary(); - /** * Returns true if we can enable spellchecking. If there are no available * dictionaries, this will return false.