Bug 1460101: Check whether the node is an element in the chain instead of ContentIsDescendantOf. r=smaug
☠☠ backed out by 9d8086740c86 ☠ ☠
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 09 May 2018 02:13:06 +0200
changeset 418296 783cf8b58ba412cfa7589ffde2a7374df76d8670
parent 418295 7581c1e47d4dd23a4b00c9627fbfc626cf48c087
child 418297 9a0ca81ddbcea5f74bcdf30a5ae424ada99013b4
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)) {