Bug 1596768 - Keep Document::GetBindingParent doing the same without nsIContent::GetBindingParent(). r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 15 Nov 2019 16:19:35 +0000
changeset 502219 dbc1778c0ebdfa4908d66c2c700daa798bd68209
parent 502218 b2abdbdb7ba238d751dd706d5f506fcb7556b797
child 502220 3a763059a684969df0246d673943ec1d5ff8996b
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 - Keep Document::GetBindingParent doing the same without nsIContent::GetBindingParent(). r=smaug See the follow-up bug for the proposal to get rid of it. Differential Revision: https://phabricator.services.mozilla.com/D53215
dom/base/Document.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -7797,22 +7797,23 @@ already_AddRefed<nsINode> Document::Impo
       NS_WARNING("Don't know how to clone this nodetype for importNode.");
     }
   }
 
   rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
   return nullptr;
 }
 
+// FIXME(bug 1596800): This should be removed, only has a couple of callers.
 Element* Document::GetBindingParent(nsINode& aNode) {
-  nsCOMPtr<nsIContent> content(do_QueryInterface(&aNode));
-  if (!content) return nullptr;
-
-  nsIContent* bindingParent = content->GetBindingParent();
-  return bindingParent ? bindingParent->AsElement() : nullptr;
+  if (aNode.IsInNativeAnonymousSubtree()) {
+    return Element::FromNodeOrNull(
+        aNode.GetClosestNativeAnonymousSubtreeRootParent());
+  }
+  return Element::FromNodeOrNull(aNode.GetContainingShadowHost());
 }
 
 nsINodeList* Document::GetAnonymousNodes(Element& aElement) { return nullptr; }
 
 already_AddRefed<nsRange> Document::CreateRange(ErrorResult& rv) {
   RefPtr<nsRange> range = new nsRange(this);
   nsresult res = range->CollapseTo(this, 0);
   if (NS_FAILED(res)) {