Commit 5c438726 authored by suzyh's avatar suzyh Committed by Commit Bot

Make AnimationTimeline.currentTime readonly

To bring in line with spec
https://w3c.github.io/web-animations/#the-animationtimeline-interface

BUG=624639

Review-Url: https://codereview.chromium.org/2952783002
Cr-Commit-Position: refs/heads/master@{#481800}
parent f7e27224
...@@ -25,7 +25,7 @@ interface DocumentTimeline : AnimationTimeline { ...@@ -25,7 +25,7 @@ interface DocumentTimeline : AnimationTimeline {
var idlArray; var idlArray;
test(function() { test(function() {
idlArray = new IdlArray(); idlArray = new IdlArray();
idlArray.add_untested_idls( idlArray.add_idls(
document.getElementById('AnimationTimeline-IDL').textContent); document.getElementById('AnimationTimeline-IDL').textContent);
idlArray.add_idls( idlArray.add_idls(
document.getElementById('DocumentTimeline-IDL').textContent); document.getElementById('DocumentTimeline-IDL').textContent);
......
...@@ -195,7 +195,6 @@ interface AnimationTimeline ...@@ -195,7 +195,6 @@ interface AnimationTimeline
getter currentTime getter currentTime
method constructor method constructor
method getAnimations method getAnimations
setter currentTime
interface AppBannerPromptResult interface AppBannerPromptResult
attribute @@toStringTag attribute @@toStringTag
getter outcome getter outcome
......
...@@ -195,7 +195,6 @@ interface AnimationTimeline ...@@ -195,7 +195,6 @@ interface AnimationTimeline
getter currentTime getter currentTime
method constructor method constructor
method getAnimations method getAnimations
setter currentTime
interface AppBannerPromptResult interface AppBannerPromptResult
attribute @@toStringTag attribute @@toStringTag
getter outcome getter outcome
......
...@@ -222,29 +222,6 @@ double AnimationTimeline::CurrentTimeInternal() { ...@@ -222,29 +222,6 @@ double AnimationTimeline::CurrentTimeInternal() {
return CurrentTimeInternal(is_null); return CurrentTimeInternal(is_null);
} }
void AnimationTimeline::setCurrentTime(double current_time, bool is_null) {
SetCurrentTimeInternal(current_time / 1000);
}
void AnimationTimeline::SetCurrentTimeInternal(double current_time) {
if (!IsActive())
return;
zero_time_ = playback_rate_ == 0
? current_time
: GetDocument()->GetAnimationClock().CurrentTime() -
current_time / playback_rate_;
zero_time_initialized_ = true;
for (const auto& animation : animations_) {
// The Player needs a timing update to pick up a new time.
animation->SetOutdated();
}
// Any corresponding compositor animation will need to be restarted. Marking
// the effect changed forces this.
SetAllCompositorPending(true);
}
double AnimationTimeline::EffectiveTime() { double AnimationTimeline::EffectiveTime() {
double time = CurrentTimeInternal(); double time = CurrentTimeInternal();
return std::isnan(time) ? 0 : time; return std::isnan(time) ? 0 : time;
......
...@@ -87,8 +87,6 @@ class CORE_EXPORT AnimationTimeline ...@@ -87,8 +87,6 @@ class CORE_EXPORT AnimationTimeline
double currentTime(); double currentTime();
double CurrentTimeInternal(bool& is_null); double CurrentTimeInternal(bool& is_null);
double CurrentTimeInternal(); double CurrentTimeInternal();
void setCurrentTime(double, bool is_null);
void SetCurrentTimeInternal(double);
double EffectiveTime(); double EffectiveTime();
void PauseAnimationsForTesting(double); void PauseAnimationsForTesting(double);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
[ [
RuntimeEnabled=WebAnimationsAPI RuntimeEnabled=WebAnimationsAPI
] interface AnimationTimeline { ] interface AnimationTimeline {
attribute double? currentTime; readonly attribute double? currentTime;
// TODO(crbug.com/624639): Move getAnimations() to DocumentAnimatable // TODO(crbug.com/624639): Move getAnimations() to DocumentAnimatable
sequence<Animation> getAnimations(); sequence<Animation> getAnimations();
......
...@@ -240,54 +240,6 @@ TEST_F(AnimationAnimationTimelineTest, PlaybackRateFast) { ...@@ -240,54 +240,6 @@ TEST_F(AnimationAnimationTimelineTest, PlaybackRateFast) {
EXPECT_FALSE(is_null); EXPECT_FALSE(is_null);
} }
TEST_F(AnimationAnimationTimelineTest, SetCurrentTime) {
double zero_time = timeline->ZeroTime();
document->GetAnimationClock().UpdateTime(100);
EXPECT_EQ(zero_time, timeline->ZeroTime());
EXPECT_EQ(100, timeline->CurrentTimeInternal());
timeline->SetCurrentTimeInternal(0);
EXPECT_EQ(0, timeline->CurrentTimeInternal());
EXPECT_EQ(zero_time + 100, timeline->ZeroTime());
timeline->SetCurrentTimeInternal(100);
EXPECT_EQ(100, timeline->CurrentTimeInternal());
EXPECT_EQ(zero_time, timeline->ZeroTime());
timeline->SetCurrentTimeInternal(200);
EXPECT_EQ(200, timeline->CurrentTimeInternal());
EXPECT_EQ(zero_time - 100, timeline->ZeroTime());
document->GetAnimationClock().UpdateTime(200);
EXPECT_EQ(300, timeline->CurrentTimeInternal());
EXPECT_EQ(zero_time - 100, timeline->ZeroTime());
timeline->SetCurrentTimeInternal(0);
EXPECT_EQ(0, timeline->CurrentTimeInternal());
EXPECT_EQ(zero_time + 200, timeline->ZeroTime());
timeline->SetCurrentTimeInternal(100);
EXPECT_EQ(100, timeline->CurrentTimeInternal());
EXPECT_EQ(zero_time + 100, timeline->ZeroTime());
timeline->SetCurrentTimeInternal(200);
EXPECT_EQ(200, timeline->CurrentTimeInternal());
EXPECT_EQ(zero_time, timeline->ZeroTime());
timeline->setCurrentTime(0, false);
EXPECT_EQ(0, timeline->currentTime());
EXPECT_EQ(zero_time + 200, timeline->ZeroTime());
timeline->setCurrentTime(1000, false);
EXPECT_EQ(1000, timeline->currentTime());
EXPECT_EQ(zero_time + 199, timeline->ZeroTime());
timeline->setCurrentTime(2000, false);
EXPECT_EQ(2000, timeline->currentTime());
EXPECT_EQ(zero_time + 198, timeline->ZeroTime());
}
TEST_F(AnimationAnimationTimelineTest, PauseForTesting) { TEST_F(AnimationAnimationTimelineTest, PauseForTesting) {
float seek_time = 1; float seek_time = 1;
timing.fill_mode = Timing::FillMode::FORWARDS; timing.fill_mode = Timing::FillMode::FORWARDS;
......
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