Bug 1053898 - Update markup view to display shadow roots as #shadow-root;r=bgrins draft
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 05 Mar 2018 16:41:43 +0100
changeset 773665 a71f90edb139122d0561b4a51ef42082e64e381e
parent 773664 4e7c5c219e0c7db9324fd363f4597a653bcae109
child 773666 d4f9698a772c1ac3bc749303e96ef132c247d850
push id104269
push userjdescottes@mozilla.com
push dateWed, 28 Mar 2018 08:16:27 +0000
reviewersbgrins
bugs1053898
milestone61.0a1
Bug 1053898 - Update markup view to display shadow roots as #shadow-root;r=bgrins MozReview-Commit-ID: 36Zr2P6j6W6
devtools/client/inspector/markup/views/read-only-editor.js
devtools/server/actors/inspector/node.js
devtools/shared/fronts/node.js
--- a/devtools/client/inspector/markup/views/read-only-editor.js
+++ b/devtools/client/inspector/markup/views/read-only-editor.js
@@ -15,16 +15,18 @@ function ReadOnlyEditor(container, node)
   this.buildMarkup();
 
   if (node.isPseudoElement) {
     this.tag.classList.add("theme-fg-color5");
     this.tag.textContent = node.isBeforePseudoElement ? "::before" : "::after";
   } else if (node.nodeType == nodeConstants.DOCUMENT_TYPE_NODE) {
     this.elt.classList.add("comment", "doctype");
     this.tag.textContent = node.doctypeString;
+  } else if (node.isShadowRoot) {
+    this.tag.textContent = "#shadow-root";
   } else {
     this.tag.textContent = node.nodeName;
   }
 
   // Make the "tag" part of this editor focusable.
   this.tag.setAttribute("tabindex", "-1");
 }
 
--- a/devtools/server/actors/inspector/node.js
+++ b/devtools/server/actors/inspector/node.js
@@ -110,16 +110,17 @@ const NodeActor = protocol.ActorClassWit
 
       attrs: this.writeAttrs(),
       isBeforePseudoElement: this.isBeforePseudoElement,
       isAfterPseudoElement: this.isAfterPseudoElement,
       isAnonymous: isAnonymous(this.rawNode),
       isNativeAnonymous: isNativeAnonymous(this.rawNode),
       isXBLAnonymous: isXBLAnonymous(this.rawNode),
       isShadowAnonymous: isShadowAnonymous(this.rawNode),
+      isShadowRoot: this.isShadowRoot,
       pseudoClassLocks: this.writePseudoClassLocks(),
 
       isDisplayed: this.isDisplayed,
       isInHTMLDocument: this.rawNode.ownerDocument &&
         this.rawNode.ownerDocument.contentType === "text/html",
       hasEventListeners: this._hasEventListeners,
     };
 
@@ -170,16 +171,21 @@ const NodeActor = protocol.ActorClassWit
   get isBeforePseudoElement() {
     return this.rawNode.nodeName === "_moz_generated_content_before";
   },
 
   get isAfterPseudoElement() {
     return this.rawNode.nodeName === "_moz_generated_content_after";
   },
 
+  get isShadowRoot() {
+    let isFragment = this.rawNode.nodeType === Ci.nsIDOMNode.DOCUMENT_FRAGMENT_NODE;
+    return isFragment && this.rawNode.host;
+  },
+
   // Estimate the number of children that the walker will return without making
   // a call to children() if possible.
   get numChildren() {
     // For pseudo elements, childNodes.length returns 1, but the walker
     // will return 0.
     if (this.isBeforePseudoElement || this.isAfterPseudoElement) {
       return 0;
     }
--- a/devtools/shared/fronts/node.js
+++ b/devtools/shared/fronts/node.js
@@ -290,16 +290,20 @@ const NodeFront = FrontClassWithSpec(nod
   get tagName() {
     return this.nodeType === nodeConstants.ELEMENT_NODE ? this.nodeName : null;
   },
 
   get isDocumentElement() {
     return !!this._form.isDocumentElement;
   },
 
+  get isShadowRoot() {
+    return this._form.isShadowRoot;
+  },
+
   // doctype properties
   get name() {
     return this._form.name;
   },
   get publicId() {
     return this._form.publicId;
   },
   get systemId() {