Bug 1460101: Check whether the node is an element in the chain instead of ContentIsDescendantOf. r?smaug
We rely on :hover and :active being hierarchical, and on the fact that there are
only elements and documents in the flattened tree ancestor chain if the element
is in the composed doc.
MozReview-Commit-ID: LMQkidMe9wp
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -5446,25 +5446,31 @@ EventStateManager::ContentRemoved(nsIDoc
IMEStateManager::OnRemoveContent(mPresContext, aContent);
// inform the focus manager that the content is being removed. If this
// content is focused, the focus will be removed without firing events.
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm)
fm->ContentRemoved(aDocument, aContent);
- if (mHoverContent &&
- nsContentUtils::ContentIsDescendantOf(mHoverContent, aContent)) {
+ if (aContent->IsElement() &&
+ aContent->AsElement()->State().HasState(NS_EVENT_STATE_HOVER)) {
+ MOZ_ASSERT(mHoverContent);
+ MOZ_ASSERT(nsContentUtils::ContentIsFlattenedTreeDescendantOf(mHoverContent,
+ aContent));
// Since hover is hierarchical, set the current hover to the
// content's parent node.
SetContentState(aContent->GetParent(), NS_EVENT_STATE_HOVER);
}
- if (mActiveContent &&
- nsContentUtils::ContentIsDescendantOf(mActiveContent, aContent)) {
+ if (aContent->IsElement() &&
+ aContent->AsElement()->State().HasState(NS_EVENT_STATE_ACTIVE)) {
+ MOZ_ASSERT(mActiveContent);
+ MOZ_ASSERT(nsContentUtils::ContentIsFlattenedTreeDescendantOf(mActiveContent,
+ aContent));
// Active is hierarchical, so set the current active to the
// content's parent node.
SetContentState(aContent->GetParent(), NS_EVENT_STATE_ACTIVE);
}
if (sDragOverContent &&
sDragOverContent->OwnerDoc() == aContent->OwnerDoc() &&
nsContentUtils::ContentIsDescendantOf(sDragOverContent, aContent)) {