Bug 1053898 - Get correct parent node for first level light tree element
MozReview-Commit-ID: 32dQykTwGHF
--- 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-actor.js
+++ b/devtools/server/actors/inspector/node-actor.js
@@ -107,16 +107,18 @@ const NodeActor = protocol.ActorClassWit
name: this.rawNode.name,
publicId: this.rawNode.publicId,
systemId: this.rawNode.systemId,
attrs: this.writeAttrs(),
isBeforePseudoElement: this.isBeforePseudoElement,
isAfterPseudoElement: this.isAfterPseudoElement,
isAnonymous: isAnonymous(this.rawNode),
+ isShadowRoot: !!this.rawNode.host,
+ isShadowNode: false,
isNativeAnonymous: isNativeAnonymous(this.rawNode),
isXBLAnonymous: isXBLAnonymous(this.rawNode),
isShadowAnonymous: isShadowAnonymous(this.rawNode),
pseudoClassLocks: this.writePseudoClassLocks(),
isDisplayed: this.isDisplayed,
isInHTMLDocument: this.rawNode.ownerDocument &&
this.rawNode.ownerDocument.contentType === "text/html",
--- a/devtools/server/actors/inspector/shadow-node-actor.js
+++ b/devtools/server/actors/inspector/shadow-node-actor.js
@@ -39,16 +39,17 @@ const ShadowNodeActor = protocol.ActorCl
return this.actorID;
}
let form = this.nodeActor.form();
form.actor = this.actorID;
form.nodeActor = this.nodeActor.actorID;
form.numChildren = 0;
form.inlineTextChild = undefined;
+ form.isShadowNode = true;
return form;
},
watchDocument: function () {
// no-op
},
--- a/devtools/server/actors/inspector/walker-actor.js
+++ b/devtools/server/actors/inspector/walker-actor.js
@@ -463,17 +463,23 @@ var WalkerActor = protocol.ActorClassWit
parents.push(this._ref(cur));
}
return parents;
},
parentNode: function (node) {
try {
- let walker = this.getDocumentWalker(node.rawNode);
+ let walker;
+ if (node.rawNode && node.rawNode.parentNode &&
+ node.rawNode.parentNode.shadowRoot && !node.nodeActor) {
+ walker = this.getDocumentWalker(node.rawNode, {showAnonymousContent: false});
+ } else {
+ walker = this.getDocumentWalker(node.rawNode);
+ }
let parent = walker.parentNode();
if (parent) {
return this._ref(parent);
}
} catch (e) {
dump("CAUGHT ERROR\n");
}
return null;
--- a/devtools/shared/fronts/node.js
+++ b/devtools/shared/fronts/node.js
@@ -267,16 +267,22 @@ const NodeFront = FrontClassWithSpec(nod
},
get numChildren() {
return this._form.numChildren;
},
get hasEventListeners() {
return this._form.hasEventListeners;
},
+ get isShadowRoot() {
+ return this._form.isShadowRoot;
+ },
+ get isShadowNode() {
+ return this._form.isShadowNode;
+ },
get isBeforePseudoElement() {
return this._form.isBeforePseudoElement;
},
get isAfterPseudoElement() {
return this._form.isAfterPseudoElement;
},
get isPseudoElement() {
return this.isBeforePseudoElement || this.isAfterPseudoElement;