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

--HG--
extra : rebase_source : 14e5412015b6c2c7ec6b7e105d414a89fc746c77
This commit is contained in:
Brian Birtles 2016-03-13 19:22:35 +08:00
parent 0c018e05f5
commit eeca04ee3b
2 changed files with 20 additions and 6 deletions

View File

@ -1804,11 +1804,6 @@ 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)));

View File

@ -13,6 +13,10 @@
height: 100px;
background-color: white;
}
@keyframes fade {
from { opacity: 1 }
to { opacity: 0 }
}
</style>
</head>
<body>
@ -41,7 +45,7 @@ function compare_property_state(a, b) {
}
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);
@ -713,6 +717,21 @@ function start() {
[ { 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>