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

Mark animation outdated after changing playback rate.

Bug: 1052217
Change-Id: I9495cf7fb844083c88f796214561cbe0476b19c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072653Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744649}
parent 79095dfe
...@@ -1332,6 +1332,9 @@ void Animation::updatePlaybackRate(double playback_rate, ...@@ -1332,6 +1332,9 @@ void Animation::updatePlaybackRate(double playback_rate,
} }
ApplyPendingPlaybackRate(); ApplyPendingPlaybackRate();
UpdateFinishedState(UpdateType::kContinuous, NotificationType::kAsync); UpdateFinishedState(UpdateType::kContinuous, NotificationType::kAsync);
SetCompositorPending(false);
SetOutdated();
NotifyProbe();
break; break;
} }
...@@ -1451,6 +1454,8 @@ void Animation::setPlaybackRate(double playback_rate, ...@@ -1451,6 +1454,8 @@ void Animation::setPlaybackRate(double playback_rate,
} }
SetCompositorPending(false); SetCompositorPending(false);
SetOutdated();
NotifyProbe();
} }
void Animation::ClearOutdated() { void Animation::ClearOutdated() {
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "third_party/blink/renderer/core/animation/keyframe_effect_model.h" #include "third_party/blink/renderer/core/animation/keyframe_effect_model.h"
#include "third_party/blink/renderer/core/animation/pending_animations.h" #include "third_party/blink/renderer/core/animation/pending_animations.h"
#include "third_party/blink/renderer/core/animation/scroll_timeline.h" #include "third_party/blink/renderer/core/animation/scroll_timeline.h"
#include "third_party/blink/renderer/core/animation/timing.h"
#include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h" #include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/dom/events/event.h" #include "third_party/blink/renderer/core/dom/events/event.h"
...@@ -173,9 +174,12 @@ class AnimationAnimationTestNoCompositing : public RenderingTest { ...@@ -173,9 +174,12 @@ class AnimationAnimationTestNoCompositing : public RenderingTest {
StringKeyframeVector()); StringKeyframeVector());
} }
KeyframeEffect* MakeAnimation(double duration = 30) { KeyframeEffect* MakeAnimation(
double duration = 30,
Timing::FillMode fill_mode = Timing::FillMode::AUTO) {
Timing timing; Timing timing;
timing.iteration_duration = AnimationTimeDelta::FromSecondsD(duration); timing.iteration_duration = AnimationTimeDelta::FromSecondsD(duration);
timing.fill_mode = fill_mode;
return MakeGarbageCollected<KeyframeEffect>(nullptr, MakeEmptyEffectModel(), return MakeGarbageCollected<KeyframeEffect>(nullptr, MakeEmptyEffectModel(),
timing); timing);
} }
...@@ -1137,6 +1141,45 @@ TEST_F(AnimationAnimationTestNoCompositing, PauseAfterCancel) { ...@@ -1137,6 +1141,45 @@ TEST_F(AnimationAnimationTestNoCompositing, PauseAfterCancel) {
EXPECT_FALSE(animation->startTime()); EXPECT_FALSE(animation->startTime());
} }
// crbug.com/1052217
TEST_F(AnimationAnimationTestNoCompositing, SetPlaybackRateAfterFinish) {
animation->setEffect(MakeAnimation(30, Timing::FillMode::FORWARDS));
animation->finish();
animation->Update(kTimingUpdateOnDemand);
EXPECT_EQ("finished", animation->playState());
EXPECT_EQ(base::nullopt, animation->TimeToEffectChange());
// Reversing a finished animation marks the animation as outdated. Required
// to recompute the time to next interval.
animation->setPlaybackRate(-1);
EXPECT_EQ("running", animation->playState());
EXPECT_EQ(animation->playbackRate(), -1);
EXPECT_TRUE(animation->Outdated());
animation->Update(kTimingUpdateOnDemand);
EXPECT_EQ(0, animation->TimeToEffectChange()->InSecondsF());
EXPECT_FALSE(animation->Outdated());
}
TEST_F(AnimationAnimationTestNoCompositing, UpdatePlaybackRateAfterFinish) {
animation->setEffect(MakeAnimation(30, Timing::FillMode::FORWARDS));
animation->finish();
animation->Update(kTimingUpdateOnDemand);
EXPECT_EQ("finished", animation->playState());
EXPECT_EQ(base::nullopt, animation->TimeToEffectChange());
// Reversing a finished animation marks the animation as outdated. Required
// to recompute the time to next interval. The pending playback rate is
// immediately applied when updatePlaybackRate is called on a non-running
// animation.
animation->updatePlaybackRate(-1);
EXPECT_EQ("running", animation->playState());
EXPECT_EQ(animation->playbackRate(), -1);
EXPECT_TRUE(animation->Outdated());
animation->Update(kTimingUpdateOnDemand);
EXPECT_EQ(0, animation->TimeToEffectChange()->InSecondsF());
EXPECT_FALSE(animation->Outdated());
}
TEST_F(AnimationAnimationTestCompositeAfterPaint, TEST_F(AnimationAnimationTestCompositeAfterPaint,
NoCompositeWithoutCompositedElementId) { NoCompositeWithoutCompositedElementId) {
SetBodyInnerHTML( SetBodyInnerHTML(
......
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