- Revision
- 200042
- Author
- [email protected]
- Date
- 2016-04-25 13:06:04 -0700 (Mon, 25 Apr 2016)
Log Message
Negative animation-delay is treated as 0s
https://bugs.webkit.org/show_bug.cgi?id=141008
Reviewed by Daniel Bates.
Source/WebCore:
Fix keyframe animations which start in the paused state.
Explicitly move such animations from the new to the paused state, and
set m_pauseTime to 0, rather than leaving it at -1. Fix getElapsedTime()
to compute a correct time elapsed time for such animations, which takes
negative delay into account correctly.
Fix assertions which need to account for the new transition of New -> PlayStatePaused.
Test: animations/play-state-start-paused.html
* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::updateStateMachine):
(WebCore::AnimationBase::getElapsedTime):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::animate):
LayoutTests:
Ref test that has an initially-paused animation on 'left' and with a
3d transform.
* animations/play-state-start-paused-expected.html: Added.
* animations/play-state-start-paused.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (200041 => 200042)
--- trunk/LayoutTests/ChangeLog 2016-04-25 19:49:23 UTC (rev 200041)
+++ trunk/LayoutTests/ChangeLog 2016-04-25 20:06:04 UTC (rev 200042)
@@ -1,3 +1,16 @@
+2016-04-25 Simon Fraser <[email protected]>
+
+ Negative animation-delay is treated as 0s
+ https://bugs.webkit.org/show_bug.cgi?id=141008
+
+ Reviewed by Daniel Bates.
+
+ Ref test that has an initially-paused animation on 'left' and with a
+ 3d transform.
+
+ * animations/play-state-start-paused-expected.html: Added.
+ * animations/play-state-start-paused.html: Added.
+
2016-04-25 Brady Eidson <[email protected]>
Implement latest File object spec (including its constructor).
Added: trunk/LayoutTests/animations/play-state-start-paused-expected.html (0 => 200042)
--- trunk/LayoutTests/animations/play-state-start-paused-expected.html (rev 0)
+++ trunk/LayoutTests/animations/play-state-start-paused-expected.html 2016-04-25 20:06:04 UTC (rev 200042)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ .container {
+ height: 100px;
+ width: 500px;
+ margin: 4px;
+ border: 1px solid black;
+ }
+ .box {
+ position: relative;
+ width: 100px;
+ height: 100px;
+ background-color: green;
+ }
+
+ .mover {
+ left: 200px;
+ }
+
+ .slider {
+ transform: translate3d(200px, 0, 0);
+ }
+ </style>
+</head>
+<body>
+ <div class="container">
+ <div class="mover box"></div>
+ </div>
+ <div class="container">
+ <div class="slider box"></div>
+ </div>
+</body>
+</html>
Added: trunk/LayoutTests/animations/play-state-start-paused.html (0 => 200042)
--- trunk/LayoutTests/animations/play-state-start-paused.html (rev 0)
+++ trunk/LayoutTests/animations/play-state-start-paused.html 2016-04-25 20:06:04 UTC (rev 200042)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style>
+ .container {
+ height: 100px;
+ width: 500px;
+ margin: 4px;
+ border: 1px solid black;
+ }
+ .box {
+ position: relative;
+ width: 100px;
+ height: 100px;
+ background-color: green;
+ animation-delay: -0.5s;
+ animation-play-state: paused;
+ }
+
+ /* For manual testing. */
+ .container:hover .box {
+ animation-play-state: running;
+ }
+
+ .mover {
+ animation: move 1s linear;
+ }
+
+ .slider {
+ animation: slide 1s linear;
+ }
+
+ @keyframes move {
+ from { left: 0; }
+ to { left: 400px; }
+ }
+
+ @keyframes slide {
+ from { transform: translate3d(0, 0, 0); }
+ to { transform: translate3d(400px, 0, 0); }
+ }
+ </style>
+</head>
+<body>
+ <div class="container">
+ <div class="mover box"></div>
+ </div>
+ <div class="container">
+ <div class="slider box"></div>
+ </div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (200041 => 200042)
--- trunk/Source/WebCore/ChangeLog 2016-04-25 19:49:23 UTC (rev 200041)
+++ trunk/Source/WebCore/ChangeLog 2016-04-25 20:06:04 UTC (rev 200042)
@@ -1,3 +1,27 @@
+2016-04-25 Simon Fraser <[email protected]>
+
+ Negative animation-delay is treated as 0s
+ https://bugs.webkit.org/show_bug.cgi?id=141008
+
+ Reviewed by Daniel Bates.
+
+ Fix keyframe animations which start in the paused state.
+
+ Explicitly move such animations from the new to the paused state, and
+ set m_pauseTime to 0, rather than leaving it at -1. Fix getElapsedTime()
+ to compute a correct time elapsed time for such animations, which takes
+ negative delay into account correctly.
+
+ Fix assertions which need to account for the new transition of New -> PlayStatePaused.
+
+ Test: animations/play-state-start-paused.html
+
+ * page/animation/AnimationBase.cpp:
+ (WebCore::AnimationBase::updateStateMachine):
+ (WebCore::AnimationBase::getElapsedTime):
+ * page/animation/KeyframeAnimation.cpp:
+ (WebCore::KeyframeAnimation::animate):
+
2016-04-25 Antti Koivisto <[email protected]>
Inline RenderStyle into RenderElement
Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (200041 => 200042)
--- trunk/Source/WebCore/page/animation/AnimationBase.cpp 2016-04-25 19:49:23 UTC (rev 200041)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp 2016-04-25 20:06:04 UTC (rev 200042)
@@ -219,6 +219,7 @@
// We are pausing before we even started.
LOG(Animations, "%p AnimationState %s -> AnimationState::PausedNew", this, nameForState(m_animationState));
m_animationState = AnimationState::PausedNew;
+ m_pauseTime = 0;
}
#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
@@ -388,7 +389,7 @@
// AnimationState::PausedWaitResponse, we don't yet have a valid startTime, so we send 0 to startAnimation.
// When the AnimationStateInput::StartTimeSet comes in and we were in AnimationState::PausedRun, we will notice
// that we have already set the startTime and will ignore it.
- ASSERT(input == AnimationStateInput::PlayStateRunning || input == AnimationStateInput::StartTimeSet || input == AnimationStateInput::StyleAvailable || input == AnimationStateInput::StartAnimation);
+ ASSERT(input == AnimationStateInput::PlayStatePaused || input == AnimationStateInput::PlayStateRunning || input == AnimationStateInput::StartTimeSet || input == AnimationStateInput::StyleAvailable || input == AnimationStateInput::StartAnimation);
ASSERT(paused());
if (input == AnimationStateInput::PlayStateRunning) {
@@ -397,6 +398,7 @@
// to start, so jump back to the New state and reset.
LOG(Animations, "%p AnimationState %s -> AnimationState::New", this, nameForState(m_animationState));
m_animationState = AnimationState::New;
+ m_pauseTime = -1;
updateStateMachine(input, param);
break;
}
@@ -406,6 +408,7 @@
m_startTime += beginAnimationUpdateTime() - m_pauseTime;
else
m_startTime = 0;
+
m_pauseTime = -1;
if (m_animationState == AnimationState::PausedWaitStyleAvailable) {
@@ -446,7 +449,7 @@
break;
}
- ASSERT(m_animationState == AnimationState::PausedWaitStyleAvailable);
+ ASSERT(m_animationState == AnimationState::PausedNew || m_animationState == AnimationState::PausedWaitStyleAvailable);
// We are paused but we got the callback that notifies us that style has been updated.
// We move to the AnimationState::PausedWaitResponse state
LOG(Animations, "%p AnimationState %s -> PausedWaitResponse", this, nameForState(m_animationState));
@@ -741,10 +744,14 @@
}
#endif
- if (paused())
- return m_pauseTime - m_startTime;
+ if (paused()) {
+ double delayOffset = (!m_startTime && m_animation->delay() < 0) ? m_animation->delay() : 0;
+ return m_pauseTime - m_startTime - delayOffset;
+ }
+
if (m_startTime <= 0)
return 0;
+
if (postActive() || fillingForwards())
return m_totalDuration;
Modified: trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp (200041 => 200042)
--- trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp 2016-04-25 19:49:23 UTC (rev 200041)
+++ trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp 2016-04-25 20:06:04 UTC (rev 200042)
@@ -131,8 +131,12 @@
fireAnimationEventsIfNeeded();
// If we have not yet started, we will not have a valid start time, so just start the animation if needed.
- if (isNew() && m_animation->playState() == AnimPlayStatePlaying && !compositeAnimation->isSuspended())
- updateStateMachine(AnimationStateInput::StartAnimation, -1);
+ if (isNew()) {
+ if (m_animation->playState() == AnimPlayStatePlaying && !compositeAnimation->isSuspended())
+ updateStateMachine(AnimationStateInput::StartAnimation, -1);
+ else if (m_animation->playState() == AnimPlayStatePaused)
+ updateStateMachine(AnimationStateInput::PlayStatePaused, -1);
+ }
// If we get this far and the animation is done, it means we are cleaning up a just finished animation.
// If so, we need to send back the targetStyle.