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

Prune use of Animation::PlayStateInternal.

PlayStateInternal returns a value for the play state of an animation
that is not to spec. It includes a pending state that is not a valid
value for the play state. This CL is part of a series of patches to
bring the implementation of web animations in line with the spec.

Bug: 958433
Change-Id: Ifd189641e83972e63d474cd99db391aad3dff406
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715764
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681385}
parent a5c884c8
...@@ -708,13 +708,18 @@ Animation::AnimationPlayState Animation::CalculatePlayState() const { ...@@ -708,13 +708,18 @@ Animation::AnimationPlayState Animation::CalculatePlayState() const {
return kPaused; return kPaused;
if (internal_play_state_ == kIdle) if (internal_play_state_ == kIdle)
return kIdle; return kIdle;
if (current_time_pending_ || (!start_time_ && playback_rate_ != 0)) if (NeedsCompositorTimeSync())
return kPending; return kPending;
if (Limited()) if (Limited())
return kFinished; return kFinished;
return kRunning; return kRunning;
} }
Animation::AnimationPlayState Animation::GetPlayState() const {
DCHECK_NE(animation_play_state_, kUnset);
return animation_play_state_;
}
// https://drafts.csswg.org/web-animations/#play-states // https://drafts.csswg.org/web-animations/#play-states
Animation::AnimationPlayState Animation::CalculateAnimationPlayState() const { Animation::AnimationPlayState Animation::CalculateAnimationPlayState() const {
// 1. All of the following conditions are true: // 1. All of the following conditions are true:
......
...@@ -130,7 +130,7 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData, ...@@ -130,7 +130,7 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData,
bool Paused() const { return paused_ && !is_paused_for_testing_; } bool Paused() const { return paused_ && !is_paused_for_testing_; }
static const char* PlayStateString(AnimationPlayState); static const char* PlayStateString(AnimationPlayState);
String playState() const { return PlayStateString(animation_play_state_); } String playState() const { return PlayStateString(animation_play_state_); }
AnimationPlayState PlayStateInternal() const;
bool pending() const; bool pending() const;
void pause(ExceptionState& = ASSERT_NO_EXCEPTION); void pause(ExceptionState& = ASSERT_NO_EXCEPTION);
...@@ -147,6 +147,21 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData, ...@@ -147,6 +147,21 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData,
return !(PlayStateInternal() == kIdle || Limited() || paused_ || return !(PlayStateInternal() == kIdle || Limited() || paused_ ||
is_paused_for_testing_); is_paused_for_testing_);
} }
// TODO(crbug/960944): Deprecate. This version of the play state is not to
// spec due to the inclusion of a 'pending' state. Whether or not an animation
// is pending is separate from the actual play state.
AnimationPlayState PlayStateInternal() const;
// Indicates if the animation is out of sync with the compositor. A change to
// the play state (running/paused) requires synchronization with the
// compositor.
bool NeedsCompositorTimeSync() const {
return current_time_pending_ || (!start_time_ && playback_rate_ != 0);
}
AnimationPlayState GetPlayState() const;
bool Limited() const { return Limited(CurrentTimeInternal()); } bool Limited() const { return Limited(CurrentTimeInternal()); }
bool FinishedInternal() const { return finished_; } bool FinishedInternal() const { return finished_; }
......
...@@ -73,10 +73,12 @@ bool ConsiderAnimationAsIncompatible(const Animation& animation, ...@@ -73,10 +73,12 @@ bool ConsiderAnimationAsIncompatible(const Animation& animation,
if (&animation == &animation_to_add) if (&animation == &animation_to_add)
return false; return false;
switch (animation.PlayStateInternal()) { if (animation.NeedsCompositorTimeSync())
return true;
switch (animation.GetPlayState()) {
case Animation::kIdle: case Animation::kIdle:
return false; return false;
case Animation::kPending:
case Animation::kRunning: case Animation::kRunning:
return true; return true;
case Animation::kPaused: case Animation::kPaused:
......
...@@ -142,8 +142,7 @@ void PendingAnimations::NotifyCompositorAnimationStarted( ...@@ -142,8 +142,7 @@ void PendingAnimations::NotifyCompositorAnimationStarted(
animations.swap(waiting_for_compositor_animation_start_); animations.swap(waiting_for_compositor_animation_start_);
for (auto animation : animations) { for (auto animation : animations) {
if (animation->startTime() || if (animation->startTime() || !animation->NeedsCompositorTimeSync() ||
animation->PlayStateInternal() != Animation::kPending ||
!animation->timeline() || !animation->timeline()->IsActive()) { !animation->timeline() || !animation->timeline()->IsActive()) {
// Already started or no longer relevant. // Already started or no longer relevant.
continue; continue;
......
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