Skip to content

Commit

Permalink
Bug 1497480 - Part 2: Make spellchecking to work in ShadowDOM after a…
Browse files Browse the repository at this point in the history
…nchor navigates away from it; r=smaug

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
EdgarChen committed Oct 31, 2018
1 parent 383ec68 commit af96c25
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions extensions/spellcheck/src/mozInlineSpellChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit af96c25

Please sign in to comment.