Bug 1450526 - Part 2: Change the target node of animation on pseudo element in the actor to proper node. r?pbro draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Mon, 21 May 2018 18:40:43 +0900
changeset 797672 646e146a15cdc1f782f0379cd32c3167cd339d8e
parent 797671 e76cbbfc2fdfa9edd8c6d1a7c4c92572dbbe32c5
child 797673 b736a7fb68bd2164b66e9c8275df1474b442d9e4
push id110532
push userbmo:dakatsuka@mozilla.com
push dateMon, 21 May 2018 10:23:12 +0000
reviewerspbro
bugs1450526
milestone62.0a1
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
devtools/server/actors/animation.js
--- 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;
   },