Bug 1596768 - Remove GetBindingParentUsage in xpath. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 15 Nov 2019 17:09:15 +0000
changeset 502253 4cd52ac39a817b6d794d4edc170d046e81d4d9ee
parent 502252 6777cec97d189411d2713a2231593cbe046b480e
child 502254 9c323325a513be734648b73aaf0b8b688701344f
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1596768
milestone72.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 1596768 - Remove GetBindingParentUsage in xpath. r=smaug Wants to check that the change happens in the same anon tree, use the right function for that. Depends on D53199 Differential Revision: https://phabricator.services.mozilla.com/D53200
dom/xslt/xpath/XPathResult.cpp
--- a/dom/xslt/xpath/XPathResult.cpp
+++ b/dom/xslt/xpath/XPathResult.cpp
@@ -200,32 +200,21 @@ nsresult XPathResult::SetExprResult(txAE
     }
   }
 
   return NS_OK;
 }
 
 void XPathResult::Invalidate(const nsIContent* aChangeRoot) {
   nsCOMPtr<nsINode> contextNode = do_QueryReferent(mContextNode);
-  if (contextNode && aChangeRoot && aChangeRoot->GetBindingParent()) {
-    // If context node is in anonymous content, changes to
-    // non-anonymous content need to invalidate the XPathResult. If
-    // the changes are happening in a different anonymous trees, no
-    // invalidation should happen.
-    nsIContent* ctxBindingParent = nullptr;
-    if (contextNode->IsContent()) {
-      ctxBindingParent = contextNode->AsContent()->GetBindingParent();
-    } else if (auto* attr = Attr::FromNode(contextNode)) {
-      if (Element* parent = attr->GetElement()) {
-        ctxBindingParent = parent->GetBindingParent();
-      }
-    }
-    if (ctxBindingParent != aChangeRoot->GetBindingParent()) {
-      return;
-    }
+  // If the changes are happening in a different anonymous trees, no
+  // invalidation should happen.
+  if (contextNode && aChangeRoot &&
+      !nsContentUtils::IsInSameAnonymousTree(contextNode, aChangeRoot)) {
+    return;
   }
 
   mInvalidIteratorState = true;
   // Make sure nulling out mDocument is the last thing we do.
   if (mDocument) {
     mDocument->RemoveMutationObserver(this);
     mDocument = nullptr;
   }