Bug 1053898 - support pseudo elements under shadow host
MozReview-Commit-ID: BhuuEFyRIZ7
--- a/devtools/server/actors/inspector/walker-actor.js
+++ b/devtools/server/actors/inspector/walker-actor.js
@@ -642,24 +642,24 @@ var WalkerActor = protocol.ActorClassWit
if (maxNodes == -1) {
maxNodes = Number.MAX_VALUE;
}
let isShadowHost = !!node.rawNode.shadowRoot;
// We're going to create a few document walkers with the same filter,
// make it easier.
- let getFilteredWalker = documentWalkerNode => {
+ let getFilteredWalker = (documentWalkerNode, showAnonymousContent) => {
let { whatToShow } = options;
// Use SKIP_TO_SIBLING to force the walker to use a sibling of the provided node
// in case this one is incompatible with the walker's filter function.
return this.getDocumentWalker(documentWalkerNode, {
whatToShow,
skipTo: SKIP_TO_SIBLING,
- showAnonymousContent: !isShadowHost
+ showAnonymousContent: showAnonymousContent || !isShadowHost
});
};
// Need to know the first and last child.
let rawNode = node.rawNode;
let firstChild = getFilteredWalker(rawNode).firstChild();
let lastChild = getFilteredWalker(rawNode).lastChild();
@@ -709,21 +709,32 @@ var WalkerActor = protocol.ActorClassWit
}
return this._ref(n, true);
});
if (nodes.length === 0) {
return { hasFirst: true, hasLast: true, nodes: [] };
}
- return {
- hasFirst: nodes[0].rawNode == firstChild,
- hasLast: nodes[nodes.length - 1].rawNode == lastChild,
- nodes: isShadowHost ? [this._ref(node.rawNode.shadowRoot), ...nodes] : nodes
- };
+ let hasFirst = nodes[0].rawNode == firstChild;
+ let hasLast = nodes[nodes.length - 1].rawNode == lastChild;
+
+ if (isShadowHost) {
+ let before = this._ref(getFilteredWalker(rawNode, true).firstChild());
+ let after = this._ref(getFilteredWalker(rawNode, true).lastChild());
+ if (before.isBeforePseudoElement) {
+ nodes = [before, ...nodes];
+ }
+ if (after.isAfterPseudoElement) {
+ nodes.push(after);
+ }
+ nodes = [this._ref(node.rawNode.shadowRoot), ...nodes];
+ }
+
+ return {hasFirst, hasLast, nodes};
},
/**
* Return siblings of the given node. By default this method will return
* all siblings of the node, but there are options that can restrict this
* to a more manageable subset.
*
* If `start` or `center` are not specified, this method will center on the