Bug 1254419 - Return animation property information from getProperties() even if the property is overridden; r=hiro draft
authorBrian Birtles <birtles@gmail.com>
Sun, 13 Mar 2016 19:22:35 +0800
changeset 341462 5452e8cbfb3f177985d9ea514380222895e8ee82
parent 341461 6d35edc0acca015cf7b7b725ec6a996754e71f88
child 341463 c5466cd6b4132c69bac24af0b0b004704c311371
push id13215
push userbbirtles@mozilla.com
push dateThu, 17 Mar 2016 02:17:54 +0000
reviewershiro
bugs1254419
milestone48.0a1
Bug 1254419 - Return animation property information from getProperties() even if the property is overridden; r=hiro I think the reason we originally didn't do this is that the "isRunningOnCompositor" status might be misleading for animations that are being overridden. That is, there are some animations we don't send to the compositor because they are being overridden by another animation (e.g. a CSS animation touching the 'transform' animation will cause a CSS transition on the same property not to run, despite the fact that transitions apply higher in the cascade). This is not merely a performance optimization but means we don't have to do the cascade on the compositor. In the future, once we introduce additive animation, we won't be able to handle this so simply since it an animation will be able to be partially overridden. Instead, consumers of this API will need to look at the 'composite' member of the various animation values to see if an animation is being fully or partially overridden. As a result, this API really should return all running animations, even if they are currently being overridden. MozReview-Commit-ID: DwmbXdCqF32
dom/animation/KeyframeEffect.cpp
dom/animation/test/chrome/test_animation_property_state.html
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -1799,21 +1799,16 @@ KeyframeEffectReadOnly::GetTarget(
   }
 }
 
 void
 KeyframeEffectReadOnly::GetProperties(
     nsTArray<AnimationPropertyDetails>& aProperties) const
 {
   for (const AnimationProperty& property : mProperties) {
-    // Bug 1252730: We should also expose this winsInCascade as well.
-    if (!property.mWinsInCascade) {
-      continue;
-    }
-
     AnimationPropertyDetails propertyDetails;
     propertyDetails.mProperty.Construct(
       NS_ConvertASCIItoUTF16(nsCSSProps::GetStringValue(property.mProperty)));
     propertyDetails.mRunningOnCompositor.Construct(
       property.mIsRunningOnCompositor);
 
     nsXPIDLString localizedString;
     if (property.mPerformanceWarning &&
--- a/dom/animation/test/chrome/test_animation_property_state.html
+++ b/dom/animation/test/chrome/test_animation_property_state.html
@@ -8,16 +8,20 @@
 <script type="application/javascript" src="../testcommon.js"></script>
 <style>
 .compositable {
   /* Element needs geometry to be eligible for layerization */
   width: 100px;
   height: 100px;
   background-color: white;
 }
+@keyframes fade {
+  from { opacity: 1 }
+  to   { opacity: 0 }
+}
 </style>
 </head>
 <body>
 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1196114"
   target="_blank">Mozilla Bug 1196114</a>
 <div id="log"></div>
 <script>
 'use strict';
@@ -36,17 +40,17 @@ function compare_property_state(a, b) {
   }
   if (a.runningOnCompositor != b.runningOnCompositor) {
     return a.runningOnCompositor ? 1 : -1;
   }
   return a.warning > b.warning ? -1 : 1;
 }
 
 function assert_animation_property_state_equals(actual, expected) {
-  assert_equals(actual.length, expected.length);
+  assert_equals(actual.length, expected.length, 'Number of properties');
 
   var sortedActual = actual.sort(compare_property_state);
   var sortedExpected = expected.sort(compare_property_state);
 
   for (var i = 0; i < sortedActual.length; i++) {
     assert_equals(sortedActual[i].property,
                   sortedExpected[i].property,
                   'CSS property name should match');
@@ -708,13 +712,28 @@ function start() {
       svg.removeAttribute('transform');
       return waitForFrame();
     })).then(t.step_func(function() {
       assert_animation_property_state_equals(
         animation.effect.getProperties(),
         [ { property: 'transform', runningOnCompositor: true } ]);
     }));
   }, 'transform of nsIFrame with SVG transform');
+
+  promise_test(function(t) {
+    var div = addDiv(t, { class: 'compositable',
+                          style: 'animation: fade 100s' });
+    var cssAnimation = div.getAnimations()[0];
+    var scriptAnimation = div.animate({ opacity: [ 1, 0 ] }, 1000);
+    return scriptAnimation.ready.then(function() {
+      assert_animation_property_state_equals(
+        cssAnimation.effect.getProperties(),
+        [ { property: 'opacity', runningOnCompositor: false } ]);
+      assert_animation_property_state_equals(
+        scriptAnimation.effect.getProperties(),
+        [ { property: 'opacity', runningOnCompositor: true } ]);
+    });
+  }, 'overridden animation');
 }
 
 </script>
 
 </body>