Skip to content

Commit

Permalink
Bug 1507543 - Spellchecker for contenteditable/design-mode should not…
Browse files Browse the repository at this point in the history
… run without focus; r=m_kato

Differential Revision: https://phabricator.services.mozilla.com/D12875

--HG--
rename : editor/reftests/spellcheck-contenteditable-nofocus.html => editor/reftests/spellcheck-contenteditable-nofocus-1.html
extra : moz-landing-system : lando
  • Loading branch information
EdgarChen committed Dec 3, 2018
1 parent cfaa5a1 commit 30d48a6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions editor/libeditor/tests/test_bug366682.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
editDoc().body.innerHTML = "<div>errror and an other errror</div>";
gMisspeltWords = ["errror", "errror"];
editDoc().designMode = "on";
editDoc().defaultView.focus();

SpecialPowers.Cu.import(
"resource://testing-common/AsyncSpellCheckTestHelper.jsm")
Expand Down
3 changes: 2 additions & 1 deletion editor/reftests/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ needs-focus != 824080-6.html 824080-7.html
fails-if(Android) needs-focus != spellcheck-contenteditable-attr.html spellcheck-contenteditable-ref.html
needs-focus == spellcheck-contenteditable-focused.html spellcheck-contenteditable-ref.html
needs-focus == spellcheck-contenteditable-focused-reframe.html spellcheck-contenteditable-ref.html
== spellcheck-contenteditable-nofocus.html spellcheck-contenteditable-disabled-ref.html
== spellcheck-contenteditable-nofocus-1.html spellcheck-contenteditable-disabled-ref.html
== spellcheck-contenteditable-nofocus-2.html spellcheck-contenteditable-disabled-ref.html
== spellcheck-contenteditable-disabled.html spellcheck-contenteditable-disabled-ref.html
== spellcheck-contenteditable-disabled-partial.html spellcheck-contenteditable-disabled-partial-ref.html
== spellcheck-contenteditable-attr-inherit.html spellcheck-contenteditable-disabled-ref.html
Expand Down
2 changes: 2 additions & 0 deletions editor/reftests/spellcheck-contenteditable-nofocus-2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<html><body><div contenteditable>blahblahblah</div></body></html>
13 changes: 8 additions & 5 deletions editor/spellchecker/EditorSpellCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,15 @@ EditorSpellCheck::UpdateCurrentDictionary(
nsCOMPtr<nsIContent> rootContent;
HTMLEditor* htmlEditor = mEditor->AsHTMLEditor();
if (htmlEditor) {
rootContent = htmlEditor->GetActiveEditingHost();
rootContent = htmlEditor->GetFocusedContent();
} else {
rootContent = mEditor->GetRoot();
}

if (!rootContent) {
return NS_ERROR_FAILURE;
}

// Try to get topmost document's document element for embedded mail editor.
uint32_t flags = 0;
mEditor->GetFlags(&flags);
Expand All @@ -660,13 +664,12 @@ EditorSpellCheck::UpdateCurrentDictionary(
nsIDocument* parentDoc = ownerDoc->GetParentDocument();
if (parentDoc) {
rootContent = parentDoc->GetDocumentElement();
if (!rootContent) {
return NS_ERROR_FAILURE;
}
}
}

if (!rootContent) {
return NS_ERROR_FAILURE;
}

RefPtr<DictionaryFetcher> fetcher =
new DictionaryFetcher(this, aCallback, mDictionaryFetcherGroup);
rootContent->GetLang(fetcher->mRootContentLang);
Expand Down

0 comments on commit 30d48a6

Please sign in to comment.