Bug 1260680 - Filter out unwanted data in getProperties to reduce protocol traffic; r=miker
authorPatrick Brosset <pbrosset@mozilla.com>
Wed, 30 Mar 2016 12:12:36 +0200
changeset 347685 d3223eecac1f7dcc0f618c203aff39d177f80493
parent 347684 0cfa4f8c142913e697706ec92bd48fb90ff3cf53
child 347686 7e34593bd9edad80833782f1c94e0f40fdb3ff4b
push id14647
push userbmo:ahunt@mozilla.com
push dateTue, 05 Apr 2016 18:15:38 +0000
reviewersmiker
bugs1260680
milestone48.0a1
Bug 1260680 - Filter out unwanted data in getProperties to reduce protocol traffic; r=miker MozReview-Commit-ID: 9Gybp724gja
devtools/client/animationinspector/components/animation-details.js
devtools/client/animationinspector/test/browser_animation_keyframe_markers.js
devtools/server/actors/animation.js
devtools/server/tests/browser/browser_animation_getProperties.js
--- a/devtools/client/animationinspector/components/animation-details.js
+++ b/devtools/client/animationinspector/components/animation-details.js
@@ -75,24 +75,22 @@ AnimationDetails.prototype = {
      * that returns the animated css properties of the animation and their
      * keyframes values.
      * If the animation actor has the getProperties function, we use it, and if
      * not, we fall back to getFrames, which then returns values we used to
      * handle.
      */
     if (this.serverTraits.hasGetProperties) {
       let properties = yield this.animation.getProperties();
-      for (let propertyObject of properties) {
-        let name = propertyObject.property;
-
+      for (let {name, values} of properties) {
         if (!tracks[name]) {
           tracks[name] = [];
         }
 
-        for (let {value, offset} of propertyObject.values) {
+        for (let {value, offset} of values) {
           tracks[name].push({value, offset});
         }
       }
     } else {
       let frames = yield this.animation.getFrames();
       for (let frame of frames) {
         for (let name in frame) {
           if (this.NON_PROPERTIES.indexOf(name) != -1) {
--- a/devtools/client/animationinspector/test/browser_animation_keyframe_markers.js
+++ b/devtools/client/animationinspector/test/browser_animation_keyframe_markers.js
@@ -55,23 +55,20 @@ add_task(function*() {
 function* getExpectedKeyframesData(animation) {
   // We're testing the UI state here, so it's fine to get the list of expected
   // properties from the animation actor.
   let properties = yield animation.getProperties();
   let data = {};
 
   for (let expectedProperty of EXPECTED_PROPERTIES) {
     data[expectedProperty] = [];
-    for (let propertyObject of properties) {
-      if (propertyObject.property !== expectedProperty) {
+    for (let {name, values} of properties) {
+      if (name !== expectedProperty) {
         continue;
       }
-      for (let valueObject of propertyObject.values) {
-        data[expectedProperty].push({
-          offset: valueObject.offset,
-          value: valueObject.value
-        });
+      for (let {offset, value} of values) {
+        data[expectedProperty].push({offset, value});
       }
     }
   }
 
   return data;
 }
--- a/devtools/server/actors/animation.js
+++ b/devtools/server/actors/animation.js
@@ -439,25 +439,27 @@ var AnimationPlayerActor = ActorClass({
     request: {},
     response: {
       frames: RetVal("json")
     }
   }),
 
   /**
    * Get data about the animated properties of this animation player.
-   * @return {Object} Returns a list of animated properties.
+   * @return {Array} Returns a list of animated properties.
    * Each property contains a list of values and their offsets
    */
   getProperties: method(function() {
-    return this.player.effect.getProperties();
+    return this.player.effect.getProperties().map(property => {
+      return {name: property.property, values: property.values};
+    });
   }, {
     request: {},
     response: {
-      frames: RetVal("json")
+      properties: RetVal("array:json")
     }
   })
 });
 
 exports.AnimationPlayerActor = AnimationPlayerActor;
 
 var AnimationPlayerFront = FrontClass(AnimationPlayerActor, {
   initialize: function(conn, form, detail, ctx) {
--- a/devtools/server/tests/browser/browser_animation_getProperties.js
+++ b/devtools/server/tests/browser/browser_animation_getProperties.js
@@ -5,30 +5,29 @@
 "use strict";
 
 // Check that the AnimationPlayerActor exposes a getProperties method that
 // returns the list of animated properties in the animation.
 
 const URL = MAIN_DOMAIN + "animation.html";
 
 add_task(function*() {
-  let {client, walker, animations} =
-    yield initAnimationsFrontForUrl(MAIN_DOMAIN + "animation.html");
+  let {client, walker, animations} = yield initAnimationsFrontForUrl(URL);
 
   info("Get the test node and its animation front");
   let node = yield walker.querySelector(walker.rootNode, ".simple-animation");
   let [player] = yield animations.getAnimationPlayersForNode(node);
 
   ok(player.getProperties, "The front has the getProperties method");
 
   let properties = yield player.getProperties();
   is(properties.length, 1, "The correct number of properties was retrieved");
 
   let propertyObject = properties[0];
-  is(propertyObject.property, "transform", "Property 0 is transform");
+  is(propertyObject.name, "transform", "Property 0 is transform");
 
   is(propertyObject.values.length, 2,
     "The correct number of property values was retrieved");
 
   // Note that we don't really test the content of the frame object here on
   // purpose. This object comes straight out of the web animations API
   // unmodified.