diff options
author | Iain Merrick <husky@google.com> | 2010-09-13 16:35:48 +0100 |
---|---|---|
committer | Iain Merrick <husky@google.com> | 2010-09-16 12:10:42 +0100 |
commit | 5abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306 (patch) | |
tree | ddce1aa5e3b6967a69691892e500897558ff8ab6 /WebCore/page/animation/AnimationBase.cpp | |
parent | 12bec63ec71e46baba27f0bd9bd9d8067683690a (diff) | |
download | external_webkit-5abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306.zip external_webkit-5abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306.tar.gz external_webkit-5abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306.tar.bz2 |
Merge WebKit at r67178 : Initial merge by git.
Change-Id: I57e01163b6866cb029cdadf405a0394a3918bc18
Diffstat (limited to 'WebCore/page/animation/AnimationBase.cpp')
-rw-r--r-- | WebCore/page/animation/AnimationBase.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/WebCore/page/animation/AnimationBase.cpp b/WebCore/page/animation/AnimationBase.cpp index d4926ea..6efed8e 100644 --- a/WebCore/page/animation/AnimationBase.cpp +++ b/WebCore/page/animation/AnimationBase.cpp @@ -70,6 +70,13 @@ static inline double solveCubicBezierFunction(double p1x, double p1y, double p2x return bezier.solve(t, solveEpsilon(duration)); } +static inline double solveStepsFunction(int numSteps, bool stepAtStart, double t) +{ + if (stepAtStart) + return min(1.0, (floor(numSteps * t) + 1) / numSteps); + return floor(numSteps * t) / numSteps; +} + static inline int blendFunc(const AnimationBase*, int from, int to, double progress) { return int(from + (to - from) * progress); @@ -1249,18 +1256,20 @@ double AnimationBase::progress(double scale, double offset, const TimingFunction fractionalTime = (fractionalTime - offset) * scale; if (!tf) - tf = &m_animation->timingFunction(); - - if (tf->type() == LinearTimingFunction) + tf = m_animation->timingFunction().get(); + + if (tf->isCubicBezierTimingFunction()) { + const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(tf); + return solveCubicBezierFunction(ctf->x1(), + ctf->y1(), + ctf->x2(), + ctf->y2(), + fractionalTime, m_animation->duration()); + } else if (tf->isStepsTimingFunction()) { + const StepsTimingFunction* stf = static_cast<const StepsTimingFunction*>(tf); + return solveStepsFunction(stf->numberOfSteps(), stf->stepAtStart(), fractionalTime); + } else return fractionalTime; - - // Cubic bezier. - double result = solveCubicBezierFunction(tf->x1(), - tf->y1(), - tf->x2(), - tf->y2(), - fractionalTime, m_animation->duration()); - return result; } void AnimationBase::getTimeToNextEvent(double& time, bool& isLooping) const |