Bug 1283387 part 2 - Implement updated calculation of active time in after phase with negative end delay
This implements the changes to the specified behavior from the following
changeset:
https://github.com/w3c/web-animations/commit/a9ba51338ed09170d16c47317f8e4e2eef122a82
It also updates test expectations based on the tests updated in part 1 of this
patch series.
MozReview-Commit-ID: HyJC8tHXLYc
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -266,17 +266,19 @@ KeyframeEffectReadOnly::GetComputedTimin
if (localTime >=
std::min(StickyTimeDuration(aTiming.mDelay + result.mActiveDuration),
result.mEndTime)) {
result.mPhase = ComputedTiming::AnimationPhase::After;
if (!result.FillsForwards()) {
// The animation isn't active or filling at this time.
return result;
}
- activeTime = result.mActiveDuration;
+ activeTime = std::max(std::min(result.mActiveDuration,
+ result.mActiveDuration + aTiming.mEndDelay),
+ zeroDuration);
} else if (localTime <
std::min(StickyTimeDuration(aTiming.mDelay), result.mEndTime)) {
result.mPhase = ComputedTiming::AnimationPhase::Before;
if (!result.FillsBackwards()) {
// The animation isn't active or filling at this time.
return result;
}
// activeTime is zero
@@ -316,19 +318,29 @@ KeyframeEffectReadOnly::GetComputedTimin
// simply iteration progress.
// https://w3c.github.io/web-animations/#simple-iteration-progress
double progress = IsFinite(overallProgress)
? fmod(overallProgress, 1.0)
: fmod(result.mIterationStart, 1.0);
// When we finish exactly at the end of an iteration we need to report
// the end of the final iteration and not the start of the next iteration.
+ // We *don't* want to do this when we have a zero-iteration animation or
+ // when the animation has been effectively made into a zero-duration animation
+ // using a negative end-delay, however.
if (result.mPhase == ComputedTiming::AnimationPhase::After &&
progress == 0.0 &&
- result.mIterations != 0.0) {
+ result.mIterations != 0.0 &&
+ (activeTime != zeroDuration || result.mDuration == zeroDuration)) {
+ // The only way we can be in the after phase with a progress of zero and
+ // a current iteration of zero, is if we have a zero iteration count or
+ // were clipped using a negative end delay--both of which we should have
+ // detected above.
+ MOZ_ASSERT(result.mCurrentIteration != 0,
+ "Should not have zero current iteration");
progress = 1.0;
if (result.mCurrentIteration != UINT64_MAX) {
result.mCurrentIteration--;
}
}
// Factor in the direction.
bool thisIterationReverse = false;
--- a/layout/style/test/file_animations_effect_timing_enddelay.html
+++ b/layout/style/test/file_animations_effect_timing_enddelay.html
@@ -117,29 +117,29 @@ addAsyncAnimTest(function *() {
advance_clock(400);
yield waitForPaints();
omta_is(div, "transform", { tx: 40 }, RunningOn.Compositor,
"Animation is updated on compositor " +
"duration 1000, endDelay -500, fill forwards, current time 400");
advance_clock(100);
yield waitForPaints();
- omta_todo_is(div, "transform", { tx: 50 }, RunningOn.MainThread,
+ omta_is(div, "transform", { tx: 50 }, RunningOn.MainThread,
"Animation is updated on main thread " +
"duration 1000, endDelay -500, fill forwards, current time 500");
advance_clock(400);
yield waitForPaints();
- omta_todo_is(div, "transform", { tx: 50 }, RunningOn.MainThread,
+ omta_is(div, "transform", { tx: 50 }, RunningOn.MainThread,
"Animation is updated on main thread " +
"duration 1000, endDelay -500, fill forwards, current time 900");
advance_clock(100);
yield waitForPaints();
- omta_todo_is(div, "transform", { tx: 50 }, RunningOn.MainThread,
+ omta_is(div, "transform", { tx: 50 }, RunningOn.MainThread,
"Animation is updated on main thread " +
"duration 1000, endDelay -500, fill forwards, current time 1000");
done_div();
});
</script>
</body>
deleted file mode 100644
--- a/testing/web-platform/meta/web-animations/interfaces/AnimationEffectTiming/getComputedStyle.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[getComputedStyle.html]
- type: testharness
- [change currentTime when fill forwards and endDelay is negative]
- expected: FAIL
- bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1283387
deleted file mode 100644
--- a/testing/web-platform/meta/web-animations/timing-model/animation-effects/active-time.html.ini
+++ /dev/null
@@ -1,13 +0,0 @@
-[active-time.html]
- type: testharness
- [Active time in after phase with forwards fill and negative end delay is the active duration + end delay]
- expected: FAIL
- bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1283387
-
- [Active time in after phase with forwards fill and negative end delay greater in magnitude than the active duration is zero]
- expected: FAIL
- bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1283387
-
- [Active time in after phase with forwards fill and negative end delay greater in magnitude than the sum of the active duration and start delay is zero]
- expected: FAIL
- bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1283387