Commit 5ab0f9ca authored by Kevin Ellis's avatar Kevin Ellis Committed by Commit Bot

Code cleanup of blink animation.

This patch makes several of the internal methods in animation.cc
private. Specifically, the now private methods are:

   SetCurrentTimeInternal
   CurrentTimeInternal
   PlayStateInternal

This CL is part of a series of patches aimed at transitioning to the
use of methods that are well documented in web specifications.  In
particular, PlayStateInternal is not spec compliant as it introduces
an extra play state (pending).

Bug: 960944
Change-Id: I22d59fc37a9f48863e7b52ab32b9d74e164bcfeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1716964Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682272}
parent 20b653eb
......@@ -121,13 +121,8 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData,
void setCurrentTime(double new_current_time,
bool is_null,
ExceptionState& = ASSERT_NO_EXCEPTION);
double CurrentTimeInternal() const;
double UnlimitedCurrentTimeInternal() const;
void SetCurrentTimeInternal(double new_current_time,
TimingUpdateReason = kTimingUpdateOnDemand);
bool Paused() const { return paused_ && !is_paused_for_testing_; }
static const char* PlayStateString(AnimationPlayState);
String playState() const { return PlayStateString(animation_play_state_); }
......@@ -143,15 +138,13 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData,
ScriptPromise finished(ScriptState*);
ScriptPromise ready(ScriptState*);
bool Playing() const override {
return !(PlayStateInternal() == kIdle || Limited() || paused_ ||
is_paused_for_testing_);
bool Paused() const {
return GetPlayState() == kPaused && !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;
bool Playing() const override {
return GetPlayState() == kRunning && !Limited() && !is_paused_for_testing_;
}
// Indicates if the animation is out of sync with the compositor. A change to
// the play state (running/paused) requires synchronization with the
......@@ -252,6 +245,15 @@ class CORE_EXPORT Animation final : public EventTargetWithInlineData,
RegisteredEventListener&) override;
private:
// 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;
double CurrentTimeInternal() const;
void SetCurrentTimeInternal(double new_current_time,
TimingUpdateReason = kTimingUpdateOnDemand);
void ClearOutdated();
void ForceServiceOnNextFrame();
......
......@@ -224,7 +224,7 @@ TEST_F(AnimationAnimationTestNoCompositing, InitialState) {
StartTimeline();
EXPECT_EQ("finished", animation->playState());
EXPECT_EQ(0, timeline->CurrentTimeInternal()->InSecondsF());
EXPECT_EQ(0, timeline->currentTime());
EXPECT_EQ(0, animation->currentTime());
EXPECT_FALSE(animation->Paused());
EXPECT_FALSE(animation->pending());
......
......@@ -376,22 +376,22 @@ TEST_F(KeyframeEffectTest, TimeToEffectChange) {
EXPECT_EQ(inf, keyframe_effect->TimeToReverseEffectChange());
// End of the before phase.
animation->SetCurrentTimeInternal(100);
animation->setCurrentTime(100000, false);
EXPECT_EQ(100, keyframe_effect->TimeToForwardsEffectChange());
EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange());
// Nearing the end of the active phase.
animation->SetCurrentTimeInternal(199);
animation->setCurrentTime(199000, false);
EXPECT_EQ(1, keyframe_effect->TimeToForwardsEffectChange());
EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange());
// End of the active phase.
animation->SetCurrentTimeInternal(200);
animation->setCurrentTime(200000, false);
EXPECT_EQ(100, keyframe_effect->TimeToForwardsEffectChange());
EXPECT_EQ(0, keyframe_effect->TimeToReverseEffectChange());
// End of the animation.
animation->SetCurrentTimeInternal(300);
animation->setCurrentTime(300000, false);
EXPECT_EQ(inf, keyframe_effect->TimeToForwardsEffectChange());
EXPECT_EQ(100, keyframe_effect->TimeToReverseEffectChange());
}
......
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