diff --git a/editor/libeditor/nsEditor.cpp b/editor/libeditor/nsEditor.cpp index 90bd22057..4656d1496 100644 --- a/editor/libeditor/nsEditor.cpp +++ b/editor/libeditor/nsEditor.cpp @@ -146,6 +146,7 @@ nsEditor::nsEditor() , mDispatchInputEvent(true) , mIsInEditAction(false) , mHidingCaret(false) +, mSpellCheckerDictionaryUpdated(true) { } @@ -1309,6 +1310,11 @@ NS_IMETHODIMP nsEditor::SyncRealTimeSpell() GetInlineSpellChecker(enable, getter_AddRefs(spellChecker)); if (mInlineSpellChecker) { + if (!mSpellCheckerDictionaryUpdated && enable) { + mInlineSpellChecker->UpdateCurrentDictionary(); + mSpellCheckerDictionaryUpdated = true; + } + // We might have a mInlineSpellChecker even if there are no dictionaries // available since we don't destroy the mInlineSpellChecker when the last // dictionariy is removed, but in that case spellChecker is null @@ -5122,8 +5128,10 @@ void nsEditor::OnFocus(nsIDOMEventTarget* aFocusEventTarget) { InitializeSelection(aFocusEventTarget); - if (mInlineSpellChecker) { + mSpellCheckerDictionaryUpdated = false; + if (mInlineSpellChecker && CanEnableSpellCheck()) { mInlineSpellChecker->UpdateCurrentDictionary(); + mSpellCheckerDictionaryUpdated = true; } } diff --git a/editor/libeditor/nsEditor.h b/editor/libeditor/nsEditor.h index 725898ece..feb3ed21a 100644 --- a/editor/libeditor/nsEditor.h +++ b/editor/libeditor/nsEditor.h @@ -883,6 +883,7 @@ protected: bool mDispatchInputEvent; bool mIsInEditAction; // true while the instance is handling an edit action bool mHidingCaret; // whether caret is hidden forcibly. + bool mSpellCheckerDictionaryUpdated; // Whether spellchecker dictionary is initialized after focused. friend bool NSCanUnload(nsISupports* serviceMgr); friend class nsAutoTxnsConserveSelection;