Commit af74d157 authored by Kevin Ellis's avatar Kevin Ellis Committed by Commit Bot

Web-animation: Remove some uses of PlayStateUpdateScope.

PlayStateUpdateScope is problematic for handling timing of finished
promises in addition to not conforming with the algorithm outlined in
the web-animations spec. This patch removes several uses of
PlayStateUpdateScope and refines handling of pending flags.

Bug: 960944
Change-Id: I093a3aa86084adfbe128a5aedd36206d67dd12c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1851927
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705966}
parent d26e3fc0
...@@ -144,11 +144,12 @@ class CORE_EXPORT Animation : public EventTargetWithInlineData, ...@@ -144,11 +144,12 @@ class CORE_EXPORT Animation : public EventTargetWithInlineData,
ScriptPromise ready(ScriptState*); ScriptPromise ready(ScriptState*);
bool Paused() const { bool Paused() const {
return GetPlayState() == kPaused && !is_paused_for_testing_; return CalculateAnimationPlayState() == kPaused && !is_paused_for_testing_;
} }
bool Playing() const override { bool Playing() const override {
return GetPlayState() == kRunning && !Limited() && !is_paused_for_testing_; return CalculateAnimationPlayState() == kRunning && !Limited() &&
!is_paused_for_testing_;
} }
// Indicates if the animation is out of sync with the compositor. A change to // Indicates if the animation is out of sync with the compositor. A change to
...@@ -336,6 +337,9 @@ class CORE_EXPORT Animation : public EventTargetWithInlineData, ...@@ -336,6 +337,9 @@ class CORE_EXPORT Animation : public EventTargetWithInlineData,
void ScheduleAsyncFinish(); void ScheduleAsyncFinish();
void AsyncFinishMicrotask(); void AsyncFinishMicrotask();
void CommitFinishNotification(); void CommitFinishNotification();
void CommitPendingPause(double ready_time);
void CommitPendingPlay(double ready_time);
void ApplyUpdates(double ready_time);
// Tracking the state of animations in dev tools. // Tracking the state of animations in dev tools.
void NotifyProbe(); void NotifyProbe();
......
...@@ -167,6 +167,8 @@ class AnimationAnimationTestNoCompositing : public RenderingTest { ...@@ -167,6 +167,8 @@ class AnimationAnimationTestNoCompositing : public RenderingTest {
} }
bool SimulateFrame(double time_ms) { bool SimulateFrame(double time_ms) {
animation->CommitAllUpdatesForTesting();
last_frame_time = time_ms; last_frame_time = time_ms;
const auto* paint_artifact_compositor = const auto* paint_artifact_compositor =
GetDocument().GetFrame()->View()->GetPaintArtifactCompositor(); GetDocument().GetFrame()->View()->GetPaintArtifactCompositor();
......
...@@ -82,7 +82,7 @@ test(function() { ...@@ -82,7 +82,7 @@ test(function() {
test(function() { test(function() {
var animation = finishedAnimation(); var animation = finishedAnimation();
assert_equals(animation.startTime, document.timeline.currentTime - (animation.playbackRate * animation.currentTime)); assert_times_equal(animation.startTime, document.timeline.currentTime - (animation.playbackRate * animation.currentTime));
assert_equals(animation.currentTime, 0); assert_equals(animation.currentTime, 0);
assert_false(animation.pending); assert_false(animation.pending);
assert_equals(animation.playState, 'finished'); assert_equals(animation.playState, 'finished');
...@@ -118,7 +118,7 @@ test(function() { ...@@ -118,7 +118,7 @@ test(function() {
test(function() { test(function() {
var animation = idleAnimation(); var animation = idleAnimation();
animation.finish(); animation.finish();
assert_equals(animation.startTime, document.timeline.currentTime - (animation.playbackRate * animation.currentTime)); assert_times_equal(animation.startTime, document.timeline.currentTime - (animation.playbackRate * animation.currentTime));
assert_equals(animation.currentTime, 0); assert_equals(animation.currentTime, 0);
assert_false(animation.pending); assert_false(animation.pending);
assert_equals(animation.playState, 'finished'); assert_equals(animation.playState, 'finished');
...@@ -221,7 +221,7 @@ test(function() { ...@@ -221,7 +221,7 @@ test(function() {
animation.play(); animation.play();
assert_equals(animation.startTime, startTime); assert_equals(animation.startTime, startTime);
assert_equals(animation.currentTime, currentTime); assert_equals(animation.currentTime, currentTime);
assert_true(animation.pending); assert_false(animation.pending);
assert_equals(animation.playState, 'running'); assert_equals(animation.playState, 'running');
}, "Calling play() on a running animation"); }, "Calling play() on a running animation");
......
...@@ -212,7 +212,7 @@ test(function(t) { ...@@ -212,7 +212,7 @@ test(function(t) {
animation.play(); animation.play();
assert_equals(animation.startTime, startTime); assert_equals(animation.startTime, startTime);
assert_equals(animation.currentTime, currentTime); assert_equals(animation.currentTime, currentTime);
assert_true(animation.pending); assert_false(animation.pending);
assert_equals(animation.playState, 'running'); assert_equals(animation.playState, 'running');
}, "Setting play() on a running animation"); }, "Setting play() on a running animation");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment