Bug 1460101: Check whether the node is an element in the chain instead of ContentIsDescendantOf. r=smaug
☠☠ backed out by 0dde66eb4736 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 09 May 2018 02:13:06 +0200
changeset 418269 64c4562813fa24925769f3f8d3490d142a8b629a
parent 418268 7a6b6db92a0e95f19dd8d9ddf665981e02b6b198
child 418270 48f01ac94137e2f6355acc6532dc2733eaaad427
push id33997
push userncsoregi@mozilla.com
push dateTue, 15 May 2018 09:53:53 +0000
treeherdermozilla-central@cf3ee1402348 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1460101
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/events/EventStateManager.cpp
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -5387,25 +5387,35 @@ 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::ContentIsFlattenedTreeDescendantOf(mHoverContent, aContent)) {
+  if (aContent->IsElement() &&
+      aContent->AsElement()->State().HasState(NS_EVENT_STATE_HOVER)) {
+    MOZ_ASSERT(mHoverContent);
+    // XBL Likes to unbind content without notifying, thus the
+    // NODE_IS_ANONYMOUS_ROOT check...
+    MOZ_ASSERT(nsContentUtils::ContentIsFlattenedTreeDescendantOf(mHoverContent,
+                                                                  aContent) ||
+               mHoverContent->SubtreeRoot()->HasFlag(NODE_IS_ANONYMOUS_ROOT));
     // Since hover is hierarchical, set the current hover to the
     // content's parent node.
     SetContentState(aContent->GetFlattenedTreeParent(), NS_EVENT_STATE_HOVER);
   }
 
-  if (mActiveContent &&
-      nsContentUtils::ContentIsFlattenedTreeDescendantOf(mActiveContent, aContent)) {
+  if (aContent->IsElement() &&
+      aContent->AsElement()->State().HasState(NS_EVENT_STATE_ACTIVE)) {
+    MOZ_ASSERT(mActiveContent);
+    MOZ_ASSERT(nsContentUtils::ContentIsFlattenedTreeDescendantOf(mActiveContent,
+                                                                  aContent) ||
+               mHoverContent->SubtreeRoot()->HasFlag(NODE_IS_ANONYMOUS_ROOT));
     // Active is hierarchical, so set the current active to the
     // content's parent node.
     SetContentState(aContent->GetFlattenedTreeParent(), NS_EVENT_STATE_ACTIVE);
   }
 
   if (sDragOverContent &&
       sDragOverContent->OwnerDoc() == aContent->OwnerDoc() &&
       nsContentUtils::ContentIsFlattenedTreeDescendantOf(sDragOverContent, aContent)) {