From dcc8cf2e65d1aa555cce12431a16547e66b469ee Mon Sep 17 00:00:00 2001 From: Steve Block Date: Tue, 27 Apr 2010 16:31:00 +0100 Subject: Merge webkit.org at r58033 : Initial merge by git Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1 --- WebCore/page/animation/KeyframeAnimation.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'WebCore/page/animation/KeyframeAnimation.cpp') diff --git a/WebCore/page/animation/KeyframeAnimation.cpp b/WebCore/page/animation/KeyframeAnimation.cpp index c5e3660..4c2cbc8 100644 --- a/WebCore/page/animation/KeyframeAnimation.cpp +++ b/WebCore/page/animation/KeyframeAnimation.cpp @@ -68,6 +68,11 @@ void KeyframeAnimation::getKeyframeAnimationInterval(const RenderStyle*& fromSty double elapsedTime = getElapsedTime(); double t = m_animation->duration() ? (elapsedTime / m_animation->duration()) : 1; + + ASSERT(t >= 0); + if (t < 0) + t = 0; + int i = static_cast(t); t -= i; if (m_animation->direction() && (i & 1)) @@ -120,9 +125,11 @@ void KeyframeAnimation::animate(CompositeAnimation*, RenderObject*, const Render } // If we are waiting for the start timer, we don't want to change the style yet. - // Special case - if the delay time is 0, then we do want to set the first frame of the + // Special case 1 - if the delay time is 0, then we do want to set the first frame of the // animation right away. This avoids a flash when the animation starts. - if (waitingToStart() && m_animation->delay() > 0) + // Special case 2 - if there is a backwards fill mode, then we want to continue + // through to the style blend so that we get the fromStyle. + if (waitingToStart() && m_animation->delay() > 0 && !m_animation->fillsBackwards()) return; // FIXME: we need to be more efficient about determining which keyframes we are animating between. @@ -163,6 +170,11 @@ void KeyframeAnimation::animate(CompositeAnimation*, RenderObject*, const Render void KeyframeAnimation::getAnimatedStyle(RefPtr& animatedStyle) { + // If we're in the delay phase and we're not backwards filling, tell the caller + // to use the current style. + if (waitingToStart() && m_animation->delay() > 0 && !m_animation->fillsBackwards()) + return; + // Get the from/to styles and progress between const RenderStyle* fromStyle = 0; const RenderStyle* toStyle = 0; @@ -260,7 +272,10 @@ void KeyframeAnimation::onAnimationIteration(double elapsedTime) void KeyframeAnimation::onAnimationEnd(double elapsedTime) { sendAnimationEvent(eventNames().webkitAnimationEndEvent, elapsedTime); - endAnimation(); + // End the animation if we don't fill forwards. Forward filling + // animations are ended properly in the class destructor. + if (!m_animation->fillsForwards()) + endAnimation(); } bool KeyframeAnimation::sendAnimationEvent(const AtomicString& eventType, double elapsedTime) -- cgit v1.1