mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 734530 - Spell check textareas if they're reframed when focused; r=roc
--HG-- rename : layout/reftests/editor/spellcheck-textarea-focused.html => layout/reftests/editor/spellcheck-textarea-focused-reframe.html
This commit is contained in:
parent
3a073edda8
commit
a36bef1294
@ -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<nsEditorEventListener*> (mEventListener.get());
|
||||
listener->SpellCheckIfNeeded();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -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<nsIDOMEventTarget> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,6 +86,8 @@ public:
|
||||
NS_IMETHOD Focus(nsIDOMEvent* aEvent);
|
||||
NS_IMETHOD Blur(nsIDOMEvent* aEvent);
|
||||
|
||||
void SpellCheckIfNeeded();
|
||||
|
||||
protected:
|
||||
nsresult InstallToEditor();
|
||||
void UninstallFromEditor();
|
||||
|
@ -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
|
||||
|
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<textarea id="testBox" onfocus="reframe(this);">blahblahblah</textarea>
|
||||
<script type="text/javascript">
|
||||
function reframe(textbox) {
|
||||
textbox.style.display = "none";
|
||||
textbox.style.display = "";
|
||||
textbox.clientWidth;
|
||||
}
|
||||
//Adding focus to the textbox should trigger a spellcheck
|
||||
document.getElementById("testBox").focus();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user