Bug 1053898 - Update DocumentWalker constructor to support showAnonymousContent parameter;r=pbro draft
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 05 Mar 2018 14:27:45 +0100
changeset 773386 b32b14c180d94082ae8ecdb6195daa6f44f40209
parent 773385 456a89d4c7026c9503544778d7b1a998056d88e8
child 773387 6c9161d2fb95adcd68345d24583fcfbbfc2bef66
child 773664 4e7c5c219e0c7db9324fd363f4597a653bcae109
push id104222
push userjdescottes@mozilla.com
push dateTue, 27 Mar 2018 21:45:46 +0000
reviewerspbro
bugs1053898
milestone61.0a1
Bug 1053898 - Update DocumentWalker constructor to support showAnonymousContent parameter;r=pbro MozReview-Commit-ID: 6c7qlnbe5ND
devtools/server/actors/inspector/document-walker.js
--- a/devtools/server/actors/inspector/document-walker.js
+++ b/devtools/server/actors/inspector/document-walker.js
@@ -25,30 +25,36 @@ const SKIP_TO_SIBLING = "SKIP_TO_SIBLING
  *          See nodeFilterConstants / inIDeepTreeWalker for options.
  *        - {Function} filter
  *          A custom filter function Taking in a DOMNode and returning an Int. See
  *          WalkerActor.nodeFilter for an example.
  *        - {String} skipTo
  *          Either SKIP_TO_PARENT or SKIP_TO_SIBLING. If the provided node is not
  *          compatible with the filter function for this walker, try to find a compatible
  *          one either in the parents or in the siblings of the node.
+ *        - {Boolean} showAnonymousContent
+ *          Pass true to let the walker return and traverse anonymous content.
+ *          When navigating host elements to which shadow DOM is attached, the light tree
+ *          will be visible only to a walker with showAnonymousContent=false. The shadow
+ *          tree will only be visible to a walker with showAnonymousContent=true.
  */
 function DocumentWalker(node, rootWin,
   {
     whatToShow = nodeFilterConstants.SHOW_ALL,
     filter = standardTreeWalkerFilter,
-    skipTo = SKIP_TO_PARENT
+    skipTo = SKIP_TO_PARENT,
+    showAnonymousContent = true
   } = {}) {
   if (Cu.isDeadWrapper(rootWin) || !rootWin.location) {
     throw new Error("Got an invalid root window in DocumentWalker");
   }
 
   this.walker = Cc["@mozilla.org/inspector/deep-tree-walker;1"]
     .createInstance(Ci.inIDeepTreeWalker);
-  this.walker.showAnonymousContent = true;
+  this.walker.showAnonymousContent = showAnonymousContent;
   this.walker.showSubDocuments = true;
   this.walker.showDocumentsAsNodes = true;
   this.walker.init(rootWin.document, whatToShow);
   this.filter = filter;
 
   // Make sure that the walker knows about the initial node (which could
   // be skipped due to a filter).
   this.walker.currentNode = this.getStartingNode(node, skipTo);