Bug 1587789 - Remove isXBLAnonymous functions defined and used in the inspector. r=bgrins
authorGabriel Luong <gabriel.luong@gmail.com>
Thu, 24 Oct 2019 21:05:44 +0000
changeset 498935 8a47372311a98d5b91e89996d92472a10b237d34
parent 498934 abfae37285fa88352064f696666c80396e5f46e3
child 498936 4b6dd8d8ad75aeb45c9fe254e6560fcf58cbf092
push id98794
push usergluong@mozilla.com
push dateThu, 24 Oct 2019 21:08:23 +0000
treeherderautoland@8a47372311a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1587789
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 1587789 - Remove isXBLAnonymous functions defined and used in the inspector. r=bgrins Differential Revision: https://phabricator.services.mozilla.com/D50517
devtools/client/inspector/markup/test/browser_markup_anonymous_02.js
devtools/client/inspector/markup/test/browser_markup_anonymous_04.js
devtools/server/actors/inspector/node.js
devtools/server/actors/inspector/utils.js
devtools/server/tests/browser/browser_inspector-anonymous.js
devtools/shared/layout/utils.js
--- a/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js
+++ b/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js
@@ -17,14 +17,13 @@ add_task(async function() {
   is(boundNode.numChildren, 2, "Correct number of children");
   is(children.nodes.length, 2, "Children returned from walker");
 
   is(boundNode.isAnonymous, false, "Node with XBL binding is not anonymous");
   await isEditingMenuEnabled(boundNode, inspector);
 
   for (const node of children.nodes) {
     ok(node.isAnonymous, "Child is anonymous");
-    ok(node._form.isXBLAnonymous, "Child is XBL anonymous");
     ok(!node._form.isShadowAnonymous, "Child is not shadow anonymous");
     ok(!node._form.isNativeAnonymous, "Child is not native anonymous");
     await isEditingMenuDisabled(node, inspector);
   }
 });
--- a/devtools/client/inspector/markup/test/browser_markup_anonymous_04.js
+++ b/devtools/client/inspector/markup/test/browser_markup_anonymous_04.js
@@ -27,14 +27,13 @@ add_task(async function() {
   is(
     grandchildren.nodes.length,
     2,
     "<input type=file> has native anonymous children"
   );
 
   for (const node of grandchildren.nodes) {
     ok(node.isAnonymous, "Child is anonymous");
-    ok(!node._form.isXBLAnonymous, "Child is not XBL anonymous");
     ok(!node._form.isShadowAnonymous, "Child is not shadow anonymous");
     ok(node._form.isNativeAnonymous, "Child is native anonymous");
     await isEditingMenuDisabled(node, inspector);
   }
 });
--- a/devtools/server/actors/inspector/node.js
+++ b/devtools/server/actors/inspector/node.js
@@ -86,22 +86,16 @@ loader.lazyRequireGetter(
 loader.lazyRequireGetter(
   this,
   "getShadowRootMode",
   "devtools/shared/layout/utils",
   true
 );
 loader.lazyRequireGetter(
   this,
-  "isXBLAnonymous",
-  "devtools/shared/layout/utils",
-  true
-);
-loader.lazyRequireGetter(
-  this,
   "isRemoteFrame",
   "devtools/shared/layout/utils",
   true
 );
 
 loader.lazyRequireGetter(
   this,
   "InspectorActorUtils",
@@ -243,17 +237,16 @@ const NodeActor = protocol.ActorClassWit
 
       attrs: this.writeAttrs(),
       customElementLocation: this.getCustomElementLocation(),
       isMarkerPseudoElement: isMarkerPseudoElement(this.rawNode),
       isBeforePseudoElement: isBeforePseudoElement(this.rawNode),
       isAfterPseudoElement: isAfterPseudoElement(this.rawNode),
       isAnonymous: isAnonymous(this.rawNode),
       isNativeAnonymous: isNativeAnonymous(this.rawNode),
-      isXBLAnonymous: isXBLAnonymous(this.rawNode),
       isShadowAnonymous: isShadowAnonymous(this.rawNode),
       isShadowRoot: shadowRoot,
       shadowRootMode: getShadowRootMode(this.rawNode),
       isShadowHost: isShadowHost(this.rawNode),
       isDirectShadowHostChild: isDirectShadowHostChild(this.rawNode),
       pseudoClassLocks: this.writePseudoClassLocks(),
       mutationBreakpoints: this.walker.getMutationBreakpoints(this),
 
--- a/devtools/server/actors/inspector/utils.js
+++ b/devtools/server/actors/inspector/utils.js
@@ -14,32 +14,24 @@ loader.lazyRequireGetter(
   "DevToolsUtils",
   "devtools/shared/DevToolsUtils"
 );
 loader.lazyRequireGetter(
   this,
   "nodeFilterConstants",
   "devtools/shared/dom-node-filter-constants"
 );
-
 loader.lazyRequireGetter(
   this,
   "isNativeAnonymous",
   "devtools/shared/layout/utils",
   true
 );
 loader.lazyRequireGetter(
   this,
-  "isXBLAnonymous",
-  "devtools/shared/layout/utils",
-  true
-);
-
-loader.lazyRequireGetter(
-  this,
   "CssLogic",
   "devtools/server/actors/inspector/css-logic",
   true
 );
 loader.lazyRequireGetter(
   this,
   "getBackgroundFor",
   "devtools/server/actors/accessibility/audit/contrast",
@@ -160,23 +152,20 @@ function standardTreeWalkerFilter(node) 
 
   // Ignore empty whitespace text nodes that do not impact the layout.
   if (isWhitespaceTextNode(node)) {
     return nodeHasSize(node)
       ? nodeFilterConstants.FILTER_ACCEPT
       : nodeFilterConstants.FILTER_SKIP;
   }
 
-  // Ignore all native and XBL anonymous content inside a non-XUL document.
+  // Ignore all native anonymous content inside a non-XUL document.
   // We need to do this to skip things like form controls, scrollbars,
   // video controls, etc (see bug 1187482).
-  if (
-    !isInXULDocument(node) &&
-    (isXBLAnonymous(node) || isNativeAnonymous(node))
-  ) {
+  if (!isInXULDocument(node) && isNativeAnonymous(node)) {
     return nodeFilterConstants.FILTER_SKIP;
   }
 
   return nodeFilterConstants.FILTER_ACCEPT;
 }
 
 /**
  * This DeepTreeWalker filter is like standardTreeWalkerFilter except that
--- a/devtools/server/tests/browser/browser_inspector-anonymous.js
+++ b/devtools/server/tests/browser/browser_inspector-anonymous.js
@@ -109,26 +109,24 @@ async function testPseudoElements(walker
     pseudo.numChildren,
     1,
     "::before/::after are not counted if there is a child"
   );
   is(children.nodes.length, 3, "Correct number of children");
 
   const before = children.nodes[0];
   ok(before.isAnonymous, "Child is anonymous");
-  ok(!before._form.isXBLAnonymous, "Child is not XBL anonymous");
   ok(!before._form.isShadowAnonymous, "Child is not shadow anonymous");
   ok(before._form.isNativeAnonymous, "Child is native anonymous");
 
   const span = children.nodes[1];
   ok(!span.isAnonymous, "Child is not anonymous");
 
   const after = children.nodes[2];
   ok(after.isAnonymous, "Child is anonymous");
-  ok(!after._form.isXBLAnonymous, "Child is not XBL anonymous");
   ok(!after._form.isShadowAnonymous, "Child is not shadow anonymous");
   ok(after._form.isNativeAnonymous, "Child is native anonymous");
 }
 
 async function testEmptyWithPseudo(walker) {
   info("Testing elements with no childrent, except for pseudos.");
 
   info("Checking an element whose only child is a pseudo element");
@@ -139,17 +137,16 @@ async function testEmptyWithPseudo(walke
     pseudo.numChildren,
     1,
     "::before/::after are is counted if there are no other children"
   );
   is(children.nodes.length, 1, "Correct number of children");
 
   const before = children.nodes[0];
   ok(before.isAnonymous, "Child is anonymous");
-  ok(!before._form.isXBLAnonymous, "Child is not XBL anonymous");
   ok(!before._form.isShadowAnonymous, "Child is not shadow anonymous");
   ok(before._form.isNativeAnonymous, "Child is native anonymous");
 }
 
 async function testShadowAnonymous(walker) {
   if (true) {
     // FIXME(bug 1465114)
     return;
@@ -160,37 +157,33 @@ async function testShadowAnonymous(walke
   const shadow = await walker.querySelector(walker.rootNode, "#shadow");
   const children = await walker.children(shadow);
 
   is(shadow.numChildren, 3, "Children of the shadow root are counted");
   is(children.nodes.length, 3, "Children returned from walker");
 
   const before = children.nodes[0];
   ok(before.isAnonymous, "Child is anonymous");
-  ok(!before._form.isXBLAnonymous, "Child is not XBL anonymous");
   ok(!before._form.isShadowAnonymous, "Child is not shadow anonymous");
   ok(before._form.isNativeAnonymous, "Child is native anonymous");
 
   // <h3>Shadow <em>DOM</em></h3>
   const shadowChild1 = children.nodes[1];
   ok(shadowChild1.isAnonymous, "Child is anonymous");
-  ok(!shadowChild1._form.isXBLAnonymous, "Child is not XBL anonymous");
   ok(shadowChild1._form.isShadowAnonymous, "Child is shadow anonymous");
   ok(!shadowChild1._form.isNativeAnonymous, "Child is not native anonymous");
 
   const shadowSubChildren = await walker.children(children.nodes[1]);
   is(shadowChild1.numChildren, 2, "Subchildren of the shadow root are counted");
   is(shadowSubChildren.nodes.length, 2, "Subchildren are returned from walker");
 
   // <em>DOM</em>
   const shadowSubChild = children.nodes[1];
   ok(shadowSubChild.isAnonymous, "Child is anonymous");
-  ok(!shadowSubChild._form.isXBLAnonymous, "Child is not XBL anonymous");
   ok(shadowSubChild._form.isShadowAnonymous, "Child is shadow anonymous");
   ok(!shadowSubChild._form.isNativeAnonymous, "Child is not native anonymous");
 
   // <select multiple></select>
   const shadowChild2 = children.nodes[2];
   ok(shadowChild2.isAnonymous, "Child is anonymous");
-  ok(!shadowChild2._form.isXBLAnonymous, "Child is not XBL anonymous");
   ok(shadowChild2._form.isShadowAnonymous, "Child is shadow anonymous");
   ok(!shadowChild2._form.isNativeAnonymous, "Child is not native anonymous");
 }
--- a/devtools/shared/layout/utils.js
+++ b/devtools/shared/layout/utils.js
@@ -489,50 +489,30 @@ exports.isAnonymous = isAnonymous;
  * @param {DOMNode} node
  * @return {Boolean}
  *
  */
 const hasBindingParent = node => !!getBindingParent(node);
 
 /**
  * Determine whether a node is native anonymous content (as opposed
- * to XBL anonymous or shadow DOM).
+ * to shadow DOM).
  * Native anonymous content includes elements like internals to form
  * controls and ::before/::after.
  *
  * @param {DOMNode} node
  * @return {Boolean}
  *
  */
 const isNativeAnonymous = node =>
-  hasBindingParent(node) && !(isXBLAnonymous(node) || isShadowAnonymous(node));
+  hasBindingParent(node) && !isShadowAnonymous(node);
 
 exports.isNativeAnonymous = isNativeAnonymous;
 
 /**
- * Determine whether a node is XBL anonymous content (as opposed
- * to native anonymous or shadow DOM).
- * See https://developer.mozilla.org/en-US/docs/XBL/XBL_1.0_Reference/Anonymous_Content.
- *
- * @param {DOMNode} node
- * @return {Boolean}
- *
- */
-function isXBLAnonymous(node) {
-  const parent = getBindingParent(node);
-  if (!parent) {
-    return false;
-  }
-
-  const anonNodes = [...(node.ownerDocument.getAnonymousNodes(parent) || [])];
-  return anonNodes.indexOf(node) > -1;
-}
-exports.isXBLAnonymous = isXBLAnonymous;
-
-/**
  * Determine whether a node is a child of a shadow root.
  * See https://w3c.github.io/webcomponents/spec/shadow/
  *
  * @param {DOMNode} node
  * @return {Boolean}
  */
 function isShadowAnonymous(node) {
   const parent = getBindingParent(node);