summaryrefslogtreecommitdiffstats
path: root/WebCore/page/animation/AnimationBase.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:31:00 +0100
committerSteve Block <steveblock@google.com>2010-05-11 14:42:12 +0100
commitdcc8cf2e65d1aa555cce12431a16547e66b469ee (patch)
tree92a8d65cd5383bca9749f5327fb5e440563926e6 /WebCore/page/animation/AnimationBase.cpp
parentccac38a6b48843126402088a309597e682f40fe6 (diff)
downloadexternal_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebCore/page/animation/AnimationBase.cpp')
-rw-r--r--WebCore/page/animation/AnimationBase.cpp60
1 files changed, 34 insertions, 26 deletions
diff --git a/WebCore/page/animation/AnimationBase.cpp b/WebCore/page/animation/AnimationBase.cpp
index 2a2ab4b..d9282cb 100644
--- a/WebCore/page/animation/AnimationBase.cpp
+++ b/WebCore/page/animation/AnimationBase.cpp
@@ -33,7 +33,6 @@
#include "CSSMutableStyleDeclaration.h"
#include "CSSPropertyLonghand.h"
#include "CSSPropertyNames.h"
-#include "CString.h"
#include "CompositeAnimation.h"
#include "Document.h"
#include "EventNames.h"
@@ -136,9 +135,9 @@ static inline ShadowStyle blendFunc(const AnimationBase* anim, ShadowStyle from,
static inline ShadowData* blendFunc(const AnimationBase* anim, const ShadowData* from, const ShadowData* to, double progress)
{
ASSERT(from && to);
- return new ShadowData(blendFunc(anim, from->x, to->x, progress), blendFunc(anim, from->y, to->y, progress),
- blendFunc(anim, from->blur, to->blur, progress), blendFunc(anim, from->spread, to->spread, progress),
- blendFunc(anim, from->style, to->style, progress), blendFunc(anim, from->color, to->color, progress));
+ return new ShadowData(blendFunc(anim, from->x(), to->x(), progress), blendFunc(anim, from->y(), to->y(), progress),
+ blendFunc(anim, from->blur(), to->blur(), progress), blendFunc(anim, from->spread(), to->spread(), progress),
+ blendFunc(anim, from->style(), to->style(), progress), blendFunc(anim, from->color(), to->color(), progress));
}
static inline TransformOperations blendFunc(const AnimationBase* anim, const TransformOperations& from, const TransformOperations& to, double progress)
@@ -297,18 +296,19 @@ public:
};
#endif // USE(ACCELERATED_COMPOSITING)
-class PropertyWrapperShadow : public PropertyWrapperGetter<ShadowData*> {
+class PropertyWrapperShadow : public PropertyWrapperBase {
public:
- PropertyWrapperShadow(int prop, ShadowData* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(ShadowData*, bool))
- : PropertyWrapperGetter<ShadowData*>(prop, getter)
+ PropertyWrapperShadow(int prop, const ShadowData* (RenderStyle::*getter)() const, void (RenderStyle::*setter)(ShadowData*, bool))
+ : PropertyWrapperBase(prop)
+ , m_getter(getter)
, m_setter(setter)
{
}
virtual bool equals(const RenderStyle* a, const RenderStyle* b) const
{
- ShadowData* shadowA = (a->*m_getter)();
- ShadowData* shadowB = (b->*m_getter)();
+ const ShadowData* shadowA = (a->*m_getter)();
+ const ShadowData* shadowB = (b->*m_getter)();
while (true) {
if (!shadowA && !shadowB) // end of both lists
@@ -320,8 +320,8 @@ public:
if (*shadowA != *shadowB)
return false;
- shadowA = shadowA->next;
- shadowB = shadowB->next;
+ shadowA = shadowA->next();
+ shadowB = shadowB->next();
}
return true;
@@ -329,29 +329,30 @@ public:
virtual void blend(const AnimationBase* anim, RenderStyle* dst, const RenderStyle* a, const RenderStyle* b, double progress) const
{
- ShadowData* shadowA = (a->*m_getter)();
- ShadowData* shadowB = (b->*m_getter)();
+ const ShadowData* shadowA = (a->*m_getter)();
+ const ShadowData* shadowB = (b->*m_getter)();
ShadowData defaultShadowData(0, 0, 0, 0, Normal, Color::transparent);
ShadowData* newShadowData = 0;
while (shadowA || shadowB) {
- ShadowData* srcShadow = shadowA ? shadowA : &defaultShadowData;
- ShadowData* dstShadow = shadowB ? shadowB : &defaultShadowData;
+ const ShadowData* srcShadow = shadowA ? shadowA : &defaultShadowData;
+ const ShadowData* dstShadow = shadowB ? shadowB : &defaultShadowData;
if (!newShadowData)
newShadowData = blendFunc(anim, srcShadow, dstShadow, progress);
else
- newShadowData->next = blendFunc(anim, srcShadow, dstShadow, progress);
+ newShadowData->setNext(blendFunc(anim, srcShadow, dstShadow, progress));
- shadowA = shadowA ? shadowA->next : 0;
- shadowB = shadowB ? shadowB->next : 0;
+ shadowA = shadowA ? shadowA->next() : 0;
+ shadowB = shadowB ? shadowB->next() : 0;
}
(dst->*m_setter)(newShadowData, false);
}
private:
+ const ShadowData* (RenderStyle::*m_getter)() const;
void (RenderStyle::*m_setter)(ShadowData*, bool);
};
@@ -918,8 +919,8 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param)
// Execute state machine
switch (m_animState) {
case AnimationStateNew:
- ASSERT(input == AnimationStateInputStartAnimation || input == AnimationStateInputPlayStateRunnning || input == AnimationStateInputPlayStatePaused);
- if (input == AnimationStateInputStartAnimation || input == AnimationStateInputPlayStateRunnning) {
+ ASSERT(input == AnimationStateInputStartAnimation || input == AnimationStateInputPlayStateRunning || input == AnimationStateInputPlayStatePaused);
+ if (input == AnimationStateInputStartAnimation || input == AnimationStateInputPlayStateRunning) {
m_requestedStartTime = beginAnimationUpdateTime();
m_animState = AnimationStateStartWaitTimer;
}
@@ -1021,6 +1022,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param)
ASSERT(input == AnimationStateInputEndTimerFired || input == AnimationStateInputPlayStatePaused);
if (input == AnimationStateInputEndTimerFired) {
+
ASSERT(param >= 0);
// End timer fired, finish up
onAnimationEnd(param);
@@ -1028,7 +1030,10 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param)
m_animState = AnimationStateDone;
if (m_object) {
- resumeOverriddenAnimations();
+ if (m_animation->fillsForwards())
+ m_animState = AnimationStateFillingForwards;
+ else
+ resumeOverriddenAnimations();
// Fire off another style change so we can set the final value
m_compAnim->animationController()->addNodeChangeToDispatch(m_object->node());
@@ -1042,7 +1047,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param)
// |this| may be deleted here
break;
case AnimationStatePausedWaitTimer:
- ASSERT(input == AnimationStateInputPlayStateRunnning);
+ ASSERT(input == AnimationStateInputPlayStateRunning);
ASSERT(paused());
// Update the times
m_startTime += beginAnimationUpdateTime() - m_pauseTime;
@@ -1058,7 +1063,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param)
// AnimationStatePausedWaitResponse, we don't yet have a valid startTime, so we send 0 to startAnimation.
// When the AnimationStateInputStartTimeSet comes in and we were in AnimationStatePausedRun, we will notice
// that we have already set the startTime and will ignore it.
- ASSERT(input == AnimationStateInputPlayStateRunnning || input == AnimationStateInputStartTimeSet);
+ ASSERT(input == AnimationStateInputPlayStateRunning || input == AnimationStateInputStartTimeSet);
ASSERT(paused());
// If we are paused, but we get the callback that notifies us that an accelerated animation started,
@@ -1093,6 +1098,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param)
m_fallbackAnimating = !started;
}
break;
+ case AnimationStateFillingForwards:
case AnimationStateDone:
// We're done. Stay in this state until we are deleted
break;
@@ -1152,14 +1158,14 @@ void AnimationBase::fireAnimationEventsIfNeeded()
void AnimationBase::updatePlayState(bool run)
{
if (paused() == run || isNew())
- updateStateMachine(run ? AnimationStateInputPlayStateRunnning : AnimationStateInputPlayStatePaused, -1);
+ updateStateMachine(run ? AnimationStateInputPlayStateRunning : AnimationStateInputPlayStatePaused, -1);
}
double AnimationBase::timeToNextService()
{
// Returns the time at which next service is required. -1 means no service is required. 0 means
// service is required now, and > 0 means service is required that many seconds in the future.
- if (paused() || isNew())
+ if (paused() || isNew() || m_animState == AnimationStateFillingForwards)
return -1;
if (m_animState == AnimationStateStartWaitTimer) {
@@ -1184,8 +1190,10 @@ double AnimationBase::progress(double scale, double offset, const TimingFunction
if (m_animation->iterationCount() > 0)
dur *= m_animation->iterationCount();
- if (postActive() || !m_animation->duration() || (m_animation->iterationCount() > 0 && elapsedTime >= dur))
+ if (postActive() || !m_animation->duration())
return 1.0;
+ if (m_animation->iterationCount() > 0 && elapsedTime >= dur)
+ return (m_animation->iterationCount() % 2) ? 1.0 : 0.0;
// Compute the fractional time, taking into account direction.
// There is no need to worry about iterations, we assume that we would have