зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1053898 - Update NodeActor with new properties to detect slotted nodes in markup-view;r=bgrins
Instead of filtering light DOM nodes in the actor, return enough information for the markup-view to filter out the nodes itself. The nodes will be displayed in a later changeset when the markup view can accommodate several containers for a single nodeFront. MozReview-Commit-ID: LFKYU24BLZB --HG-- extra : rebase_source : 232795c1ee91a41ec667c8bcdc21eb73bcfcbf9a
This commit is contained in:
Родитель
8fe5897c42
Коммит
57820cf88e
|
@ -1670,6 +1670,8 @@ MarkupView.prototype = {
|
|||
// If the dirty flag is re-set while we're fetching we'll need to fetch
|
||||
// again.
|
||||
container.childrenDirty = false;
|
||||
|
||||
let isShadowHost = container.node.isShadowHost;
|
||||
let updatePromise =
|
||||
this._getVisibleChildren(container, centered).then(children => {
|
||||
if (!this._containers) {
|
||||
|
@ -1686,6 +1688,12 @@ MarkupView.prototype = {
|
|||
let fragment = this.doc.createDocumentFragment();
|
||||
|
||||
for (let child of children.nodes) {
|
||||
let { isDirectShadowHostChild } = child;
|
||||
if (!isShadowHost && isDirectShadowHostChild) {
|
||||
// Temporarily skip light DOM nodes if the container's node is not a host
|
||||
// element, which means that the node is a "slotted" node.
|
||||
continue;
|
||||
}
|
||||
let childContainer = this.importNode(child, flash);
|
||||
fragment.appendChild(childContainer.elt);
|
||||
}
|
||||
|
|
|
@ -124,6 +124,8 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
isXBLAnonymous: isXBLAnonymous(this.rawNode),
|
||||
isShadowAnonymous: isShadowAnonymous(this.rawNode),
|
||||
isShadowRoot: this.isShadowRoot,
|
||||
isShadowHost: this.isShadowHost,
|
||||
isDirectShadowHostChild: this.isDirectShadowHostChild,
|
||||
pseudoClassLocks: this.writePseudoClassLocks(),
|
||||
|
||||
isDisplayed: this.isDisplayed,
|
||||
|
@ -197,6 +199,11 @@ const NodeActor = protocol.ActorClassWithSpec(nodeSpec, {
|
|||
return isFragment && this.rawNode.host;
|
||||
},
|
||||
|
||||
get isShadowHost() {
|
||||
let shadowRoot = this.rawNode.shadowRoot;
|
||||
return shadowRoot && shadowRoot.nodeType === Ci.nsIDOMNode.DOCUMENT_FRAGMENT_NODE;
|
||||
},
|
||||
|
||||
get isDirectShadowHostChild() {
|
||||
// Pseudo elements are always part of the anonymous tree.
|
||||
if (this.isBeforePseudoElement || this.isAfterPseudoElement) {
|
||||
|
|
|
@ -607,13 +607,12 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
|
|||
maxNodes = Number.MAX_VALUE;
|
||||
}
|
||||
|
||||
let isShadowHost = !!node.rawNode.shadowRoot;
|
||||
let isShadowRoot = !!node.rawNode.host;
|
||||
let { isShadowHost, isShadowRoot, isDirectShadowHostChild } = node;
|
||||
|
||||
// Detect special case of unslotted shadow host children that cannot rely on a
|
||||
// regular anonymous walker.
|
||||
let isUnslottedHostChild = false;
|
||||
if (node.isDirectShadowHostChild) {
|
||||
if (isDirectShadowHostChild) {
|
||||
try {
|
||||
this.getDocumentWalker(node.rawNode, options.whatToShow, SKIP_TO_SIBLING);
|
||||
} catch (e) {
|
||||
|
@ -694,12 +693,6 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
|
|||
}
|
||||
}
|
||||
|
||||
// Temporarily filter out shadow host children when a walker returns them in a <slot>.
|
||||
if (!isShadowHost) {
|
||||
// Shadow host children should only be displayed under the host.
|
||||
nodes = nodes.filter(n => !n.isDirectShadowHostChild);
|
||||
}
|
||||
|
||||
let hasFirst, hasLast;
|
||||
if (nodes.length > 0) {
|
||||
// Compare first/last with expected nodes before modifying the nodes array in case
|
||||
|
|
|
@ -299,6 +299,14 @@ const NodeFront = FrontClassWithSpec(nodeSpec, {
|
|||
return this._form.isShadowRoot;
|
||||
},
|
||||
|
||||
get isShadowHost() {
|
||||
return this._form.isShadowHost;
|
||||
},
|
||||
|
||||
get isDirectShadowHostChild() {
|
||||
return this._form.isDirectShadowHostChild;
|
||||
},
|
||||
|
||||
// doctype properties
|
||||
get name() {
|
||||
return this._form.name;
|
||||
|
|
Загрузка…
Ссылка в новой задаче