Bug 1450526 - Part 2: Change the target node of animation on pseudo element in the actor to proper node. r?pbro
In this patch fix not only new animation inspector, but also previous one.
MozReview-Commit-ID: KYdaUXXea70
--- a/devtools/server/actors/animation.js
+++ b/devtools/server/actors/animation.js
@@ -101,41 +101,23 @@ var AnimationPlayerActor = protocol.Acto
Actor.prototype.destroy.call(this);
},
get isPseudoElement() {
return !this.player.effect.target.ownerDocument;
},
get node() {
- if (this._node) {
- return this._node;
+ if (!this.isPseudoElement) {
+ return this.player.effect.target;
}
- let node = this.player.effect.target;
-
- if (this.isPseudoElement) {
- // The target is a CSSPseudoElement object which just has a property that
- // points to its parent element and a string type (::before or ::after).
- let treeWalker = this.walker.getDocumentWalker(node.parentElement);
- while (treeWalker.nextNode()) {
- let currentNode = treeWalker.currentNode;
- if ((currentNode.nodeName === "_moz_generated_content_before" &&
- node.type === "::before") ||
- (currentNode.nodeName === "_moz_generated_content_after" &&
- node.type === "::after")) {
- this._node = currentNode;
- }
- }
- } else {
- // The target is a DOM node.
- this._node = node;
- }
-
- return this._node;
+ const pseudo = this.player.effect.target;
+ const treeWalker = this.walker.getDocumentWalker(pseudo.parentElement);
+ return pseudo.type === "::before" ? treeWalker.firstChild() : treeWalker.lastChild();
},
get window() {
// ownerGlobal doesn't exist in content privileged windows.
// eslint-disable-next-line mozilla/use-ownerGlobal
return this.node.ownerDocument.defaultView;
},