Bug 1518403 - Make "is current" depend on the direction of the associated animation's playback rate; r=hiro

As per the following spec change:

  4ec1deb76a

Spec issue:

  https://github.com/w3c/csswg-drafts/issues/3193

Of the added test cases, only the last one, "Returns reversed animations yet to
reach their active phase" fails without this code change. The others pass
because the animation is finished at that point but I added them for consistency
with the previous tests.

Differential Revision: https://phabricator.services.mozilla.com/D16001

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Birtles 2019-01-10 00:31:54 +00:00
parent 3e70bf3ff1
commit 1ec94901a9
2 changed files with 33 additions and 3 deletions

View File

@ -47,8 +47,13 @@ bool AnimationEffect::IsCurrent() const {
}
ComputedTiming computedTiming = GetComputedTiming();
return computedTiming.mPhase == ComputedTiming::AnimationPhase::Before ||
computedTiming.mPhase == ComputedTiming::AnimationPhase::Active;
if (computedTiming.mPhase == ComputedTiming::AnimationPhase::Active) {
return true;
}
return mAnimation->PlaybackRate() >= 0
? computedTiming.mPhase == ComputedTiming::AnimationPhase::Before
: computedTiming.mPhase == ComputedTiming::AnimationPhase::After;
}
// https://drafts.csswg.org/web-animations/#in-effect

View File

@ -65,7 +65,32 @@ test(t => {
delay: 100 * MS_PER_SEC,
});
assert_array_equals(div.getAnimations(), [animation]);
}, 'Returns animations in their delay phase');
}, 'Returns animations yet to reach their active phase');
test(t => {
const div = createDiv(t);
const animation = div.animate(null, 100 * MS_PER_SEC);
animation.playbackRate = -1;
assert_array_equals(div.getAnimations(), []);
}, 'Does not return reversed finished animations that do not fill backwards');
test(t => {
const div = createDiv(t);
const animation = div.animate(null, {
duration: 100 * MS_PER_SEC,
fill: 'backwards',
});
animation.playbackRate = -1;
assert_array_equals(div.getAnimations(), [animation]);
}, 'Returns reversed finished animations that fill backwards');
test(t => {
const div = createDiv(t);
const animation = div.animate(null, 100 * MS_PER_SEC);
animation.playbackRate = -1;
animation.currentTime = 200 * MS_PER_SEC;
assert_array_equals(div.getAnimations(), [animation]);
}, 'Returns reversed animations yet to reach their active phase');
test(t => {
const div = createDiv(t);