Spellchecking on contenteditable elemens runs automatically (focus is not yet moved to contenteditable elemens)

RESOLVED FIXED in Firefox 65

Status

()

defect
RESOLVED FIXED
8 months ago
8 months ago

People

(Reporter: edgar, Assigned: edgar)

Tracking

unspecified
mozilla65
Points:
---

Firefox Tracking Flags

(firefox65 fixed)

Details

Attachments

(3 attachments)

Posted file test.html
STR:
1. load test script

Actually Result:
Spellchecker runs automatically

Expected Result:
Spellchecker doesn't run until user move focus to contenteditable element.
(In reply to Edgar Chen [:edgar] from comment #0)
> Expected Result:
> Spellchecker doesn't run until user move focus to contenteditable element.

This is something related to bug 1489437 comment 22. The EditorSpellCheck initialization happens in nsHTMLDocument::EndUpdate() call. And the active editing host [2] is <div contenteditable>, so the EditorSpellCheck fetch the dictionary immediately and do spell-check after dictionary is fetched.

From the reftest https://searchfox.org/mozilla-central/rev/c0b26c40769a1e5607a1ae8be37fe64df64fc55e/editor/reftests/reftest.list#122, it seems that we don't expect spellchecker runs without focus.

[1] https://searchfox.org/mozilla-central/rev/d850d799a0009f851b5535580e0a8b4bb2c591d7/dom/html/nsHTMLDocument.cpp#2176
[2] https://searchfox.org/mozilla-central/rev/d850d799a0009f851b5535580e0a8b4bb2c591d7/editor/libeditor/HTMLEditor.cpp#5211
(In reply to Edgar Chen [:edgar] from comment #1)
> And the active editing host [2] is <div contenteditable>

It is because we set it to end of the document in TextEditRules::Init,
https://searchfox.org/mozilla-central/rev/d850d799a0009f851b5535580e0a8b4bb2c591d7/editor/libeditor/TextEditRules.cpp#167.
Comment on attachment 9026114 [details] [diff] [review]
Patch, v1

We could fix this by using GetFocusedContent() to check if we allow fetching dictionary. And try result in comment #4 looks good. What do you think, Makoto? Thanks.
Attachment #9026114 - Flags: feedback?(m_kato)
Attachment #9026114 - Flags: feedback?(m_kato) → feedback+
Pushed by echen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5e2fad03c885
Spellchecker for contenteditable/design-mode should not run without focus; r=m_kato
https://hg.mozilla.org/mozilla-central/rev/5e2fad03c885
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
You need to log in before you can comment on or make changes to this bug.