From af96c255f6232a7e91ddb0c4f97f6a069a48d045 Mon Sep 17 00:00:00 2001 From: Edgar Chen <echen@mozilla.com> Date: Wed, 31 Oct 2018 14:35:42 +0000 Subject: [PATCH] Bug 1497480 - Part 2: Make spellchecking to work in ShadowDOM after anchor navigates away from it; r=smaug Differential Revision: https://phabricator.services.mozilla.com/D9543 --HG-- extra : moz-landing-system : lando --- .../spellcheck/src/mozInlineSpellChecker.cpp | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp index 4eb942ec19def..fe09a45ad1a8d 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp +++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp @@ -86,9 +86,6 @@ using namespace mozilla::dom; #define INLINESPELL_STARTED_TOPIC "inlineSpellChecker-spellCheck-started" #define INLINESPELL_ENDED_TOPIC "inlineSpellChecker-spellCheck-ended" -static bool ContentIsDescendantOf(nsINode* aPossibleDescendant, - nsINode* aPossibleAncestor); - static const char kMaxSpellCheckSelectionSize[] = "extensions.spellcheck.inline.max-misspellings"; static const PRTime kMaxSpellCheckTimeInUsec = @@ -228,7 +225,8 @@ mozInlineSpellStatus::InitForNavigation( return NS_ERROR_FAILURE; } // the anchor node might not be in the DOM anymore, check - if (root && aOldAnchorNode && ! ContentIsDescendantOf(aOldAnchorNode, root)) { + if (root && aOldAnchorNode && + !nsContentUtils::ContentIsShadowIncludingDescendantOf(aOldAnchorNode, root)) { *aContinue = false; return NS_OK; } @@ -1728,24 +1726,6 @@ mozInlineSpellChecker::SaveCurrentSelectionPosition() return NS_OK; } -// This is a copy of nsContentUtils::ContentIsDescendantOf. Another crime -// for XPCOM's rap sheet -bool // static -ContentIsDescendantOf(nsINode* aPossibleDescendant, - nsINode* aPossibleAncestor) -{ - MOZ_ASSERT(aPossibleDescendant, "The possible descendant is null!"); - MOZ_ASSERT(aPossibleAncestor, "The possible ancestor is null!"); - - do { - if (aPossibleDescendant == aPossibleAncestor) - return true; - aPossibleDescendant = aPossibleDescendant->GetParentNode(); - } while (aPossibleDescendant); - - return false; -} - // mozInlineSpellChecker::HandleNavigationEvent // // Acts upon mouse clicks and keyboard navigation changes, spell checking