Bug 1596800 - Remove document.getBindingParent. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 18 Nov 2019 19:06:51 +0000
changeset 502475 26d109ef85da49b7f113e65c61908dbb5d7ea846
parent 502474 d5db2146b9c5519a2d42233c4699818ba347ec2a
child 502476 ba115d212e18bad5168af1ae0541c44de1a20089
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
bugs1596800
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 1596800 - Remove document.getBindingParent. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D53342
dom/base/Document.cpp
dom/base/Document.h
dom/base/test/mochitest.ini
dom/base/test/test_bug330925.html
dom/webidl/Document.webidl
js/xpconnect/tests/mochitest/test_bug912322.html
widget/tests/test_imestate.html
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -7796,25 +7796,16 @@ 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) {
-  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)) {
     rv.Throw(res);
     return nullptr;
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -3700,17 +3700,16 @@ class Document : public nsINode,
   // A way to check whether a given element is what would get returned from
   // GetScrollingElement.  It can be faster than comparing to the return value
   // of GetScrollingElement() due to being able to avoid flushes in various
   // cases.  This method assumes that null is NOT passed.
   bool IsScrollingElement(Element* aElement);
 
   // QuerySelector and QuerySelectorAll already defined on nsINode
   nsINodeList* GetAnonymousNodes(Element& aElement);
-  Element* GetBindingParent(nsINode& aNode);
 
   XPathExpression* CreateExpression(const nsAString& aExpression,
                                     XPathNSResolver* aResolver,
                                     ErrorResult& rv);
   nsINode* CreateNSResolver(nsINode& aNodeResolver);
   already_AddRefed<XPathResult> Evaluate(
       JSContext* aCx, const nsAString& aExpression, nsINode& aContextNode,
       XPathNSResolver* aResolver, uint16_t aType, JS::Handle<JSObject*> aResult,
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -306,17 +306,16 @@ skip-if = headless # headless != clipboa
 [test_bug282547.html]
 [test_bug298064.html]
 [test_bug300992.html]
 [test_bug311681.xml]
 [test_bug313646.html]
 [test_bug320799.html]
 [test_bug322317.html]
 [test_bug326337.html]
-[test_bug330925.html]
 [test_bug331959.html]
 [test_bug333064.html]
 skip-if = headless # Headless: Bug 1405868
 [test_bug333198.html]
 [test_bug333673.html]
 [test_bug337631.html]
 [test_bug338541.xhtml]
 [test_bug338583.html]
deleted file mode 100644
--- a/dom/base/test/test_bug330925.html
+++ /dev/null
@@ -1,58 +0,0 @@
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=330925
--->
-<head>
-  <title>Test for Bug 330925</title>
-  <script src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=330925">Mozilla Bug 330925</a>
-
-<p id="display">
-<el-custom id="t"></el-custom>
-</p>
-
-<pre id="test">
-<script class="testbody" type="text/javascript">
-customElements.define("el-custom", class extends HTMLElement {
-  constructor() {
-    super();
-    this.attachShadow({ mode: "open" });
-    this.shadowRoot.innerHTML = `
-xbl textnode1
-<div>
-xbl textnode2
-<slot></slot>
-</div>
-    `;
-  }
-});
-
-let t = document.getElementById("t");
-let d = SpecialPowers.wrap(document);
-
-let tn1 = t.shadowRoot.firstChild;
-let tn2 = t.shadowRoot.firstChild.nextSibling.firstChild;
-
-is(SpecialPowers.unwrap(d.getBindingParent(tn1)),
-   t,
-   "Wrong binding parent for shadow DOM node");
-
-is(SpecialPowers.unwrap(d.getBindingParent(tn2)),
-   t,
-   "Wrong binding parent for child of shadow DOM node");
-
-is(d.getBindingParent(t),
-   null,
-   "Non shadow DOM node should not have a binding parent");
-
-is(d.getBindingParent(document.documentElement),
-   null,
-   "Document element should not have a binding parent");
-</script>
-</pre>
-</body>
-</html>
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -372,22 +372,19 @@ partial interface Document {
 // https://svgwg.org/svg2-draft/struct.html#InterfaceDocumentExtensions
 partial interface Document {
   [BinaryName="SVGRootElement"]
   readonly attribute SVGSVGElement? rootElement;
 };
 
 //  Mozilla extensions of various sorts
 partial interface Document {
-  // XBL support.  Wish we could make these [ChromeOnly], but
-  // that would likely break bindings running with the page principal.
+  // XBL support.
   [Func="IsChromeOrXBL"]
   NodeList? getAnonymousNodes(Element elt);
-  [Func="IsChromeOrXBL"]
-  Element? getBindingParent(Node node);
   // Creates a new XUL element regardless of the document's default type.
   [CEReactions, NewObject, Throws, Func="IsChromeOrXBL"]
   Element createXULElement(DOMString localName, optional (ElementCreationOptions or DOMString) options = {});
   // Wether the document was loaded using a nsXULPrototypeDocument.
   [ChromeOnly]
   readonly attribute boolean loadedFromPrototype;
 
   // The principal to use for the storage area of this document
--- a/js/xpconnect/tests/mochitest/test_bug912322.html
+++ b/js/xpconnect/tests/mochitest/test_bug912322.html
@@ -6,17 +6,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 912322</title>
   <script src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   /** Test that XBL functions aren't exposed to the web. **/
-  funs = ['getAnonymousNodes', 'getBindingParent'];
+  funs = ['getAnonymousNodes'];
   for (var f of funs) {
     ok(!(f in document), f + " should not be available to content");
     ok(f in SpecialPowers.wrap(document), f + " should be available to chrome via Xray");
   }
 
   var {AppConstants} = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
   // Test window.controllers.
   if (AppConstants.RELEASE_OR_BETA) {
--- a/widget/tests/test_imestate.html
+++ b/widget/tests/test_imestate.html
@@ -190,21 +190,19 @@ function runBasicTest(aIsEditable, aInDe
       onIMEFocusBlurHandler = aFocusEventHandler;
 
       element.focus();
 
       focusEventTarget.removeEventListener("focus", aFocusEventHandler, true);
       onIMEFocusBlurHandler = null;
 
       var focusedElement = gFM.focusedElement;
-      if (focusedElement) {
-        var bindingParent = document.getBindingParent(focusedElement);
-        if (bindingParent) {
-          focusedElement = bindingParent;
-        }
+      // FIXME(emilio, bug 981248): This is needed just for <input type=number>
+      while (focusedElement && focusedElement.isNativeAnonymous) {
+        focusedElement = focusedElement.parentNode;
       }
       if (aTest.focusable) {
         is(focusedElement, element,
            aDescription + ": " + aTest.description + ", focus didn't move");
         return (element == focusedElement);
       }
       is(focusedElement, previousFocusedElement,
          aDescription + ": " + aTest.description + ", focus moved as unexpected");