diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index 8f06173bb644..386f0c994c9f 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -341,6 +341,13 @@ nsEditor::PostCreate() if (target) { InitializeSelection(target); } + + // If the text control gets reframed during focus, Focus() would not be + // called, so take a chance here to see if we need to spell check the text + // control. + nsEditorEventListener* listener = + reinterpret_cast (mEventListener.get()); + listener->SpellCheckIfNeeded(); } return NS_OK; } diff --git a/editor/libeditor/base/nsEditorEventListener.cpp b/editor/libeditor/base/nsEditorEventListener.cpp index 50aa05206c5c..48164bf52ce4 100644 --- a/editor/libeditor/base/nsEditorEventListener.cpp +++ b/editor/libeditor/base/nsEditorEventListener.cpp @@ -905,17 +905,9 @@ nsEditorEventListener::Focus(nsIDOMEvent* aEvent) if (mEditor->IsDisabled()) { return NS_OK; } - - // If the spell check skip flag is still enabled from creation time, - // disable it because focused editors are allowed to spell check. - PRUint32 currentFlags = 0; - mEditor->GetFlags(¤tFlags); - if(currentFlags & nsIPlaintextEditor::eEditorSkipSpellCheck) - { - currentFlags ^= nsIPlaintextEditor::eEditorSkipSpellCheck; - mEditor->SetFlags(currentFlags); - } - + + // Spell check a textarea the first time that it is focused. + SpellCheckIfNeeded(); nsCOMPtr target; aEvent->GetTarget(getter_AddRefs(target)); @@ -1013,3 +1005,16 @@ nsEditorEventListener::Blur(nsIDOMEvent* aEvent) return NS_OK; } +void +nsEditorEventListener::SpellCheckIfNeeded() { + // If the spell check skip flag is still enabled from creation time, + // disable it because focused editors are allowed to spell check. + PRUint32 currentFlags = 0; + mEditor->GetFlags(¤tFlags); + if(currentFlags & nsIPlaintextEditor::eEditorSkipSpellCheck) + { + currentFlags ^= nsIPlaintextEditor::eEditorSkipSpellCheck; + mEditor->SetFlags(currentFlags); + } +} + diff --git a/editor/libeditor/base/nsEditorEventListener.h b/editor/libeditor/base/nsEditorEventListener.h index 0c8efcd7419a..346654204586 100644 --- a/editor/libeditor/base/nsEditorEventListener.h +++ b/editor/libeditor/base/nsEditorEventListener.h @@ -86,6 +86,8 @@ public: NS_IMETHOD Focus(nsIDOMEvent* aEvent); NS_IMETHOD Blur(nsIDOMEvent* aEvent); + void SpellCheckIfNeeded(); + protected: nsresult InstallToEditor(); void UninstallFromEditor(); diff --git a/layout/reftests/editor/reftest.list b/layout/reftests/editor/reftest.list index f50a9a3a4371..6367ae2ccb21 100644 --- a/layout/reftests/editor/reftest.list +++ b/layout/reftests/editor/reftest.list @@ -42,7 +42,8 @@ fails-if(Android) != spellcheck-input-property-dynamic-override.html spellcheck- fails-if(Android) != spellcheck-input-property-dynamic-override-inherit.html spellcheck-input-ref.html == spellcheck-textarea-attr.html spellcheck-textarea-nofocus-ref.html fails-if(Android) != spellcheck-textarea-attr.html spellcheck-textarea-ref.html -== spellcheck-textarea-focused.html spellcheck-textarea-ref.html +needs-focus == spellcheck-textarea-focused.html spellcheck-textarea-ref.html +needs-focus == spellcheck-textarea-focused-reframe.html spellcheck-textarea-ref.html fails-if(Android) != spellcheck-textarea-nofocus.html spellcheck-textarea-ref.html fails-if(Android) != spellcheck-textarea-disabled.html spellcheck-textarea-ref.html fails-if(Android) != spellcheck-textarea-attr-inherit.html spellcheck-textarea-ref.html diff --git a/layout/reftests/editor/spellcheck-textarea-focused-reframe.html b/layout/reftests/editor/spellcheck-textarea-focused-reframe.html new file mode 100644 index 000000000000..73443e8a28df --- /dev/null +++ b/layout/reftests/editor/spellcheck-textarea-focused-reframe.html @@ -0,0 +1,17 @@ + + + + + + + + +