| Index: Source/platform/animation/TimingFunction.h
|
| diff --git a/Source/platform/animation/TimingFunction.h b/Source/platform/animation/TimingFunction.h
|
| index 400f89101ed99c2c1ecd0d78dc4bd7cd427e68c2..0f6996549fc1a9ef3c2a22ede3b9d1fcfb807e68 100644
|
| --- a/Source/platform/animation/TimingFunction.h
|
| +++ b/Source/platform/animation/TimingFunction.h
|
| @@ -34,6 +34,8 @@
|
| #include "wtf/RefCounted.h"
|
| #include "wtf/StdLibExtras.h"
|
| #include "wtf/Vector.h"
|
| +#include "wtf/text/StringBuilder.h"
|
| +#include "wtf/text/WTFString.h"
|
| #include <algorithm>
|
|
|
|
|
| @@ -50,9 +52,11 @@ public:
|
|
|
| Type type() const { return m_type; }
|
|
|
| + virtual String toString() const;
|
| +
|
| // Evaluates the timing function at the given fraction. The accuracy parameter provides a hint as to the required
|
| // accuracy and is not guaranteed.
|
| - virtual double evaluate(double fraction, double accuracy) const = 0;
|
| + virtual double evaluate(double fraction, double accuracy) const =0;
|
|
|
| protected:
|
| TimingFunction(Type type)
|
| @@ -73,11 +77,9 @@ public:
|
|
|
| virtual ~LinearTimingFunction() { }
|
|
|
| - virtual double evaluate(double fraction, double) const OVERRIDE
|
| - {
|
| - ASSERT_WITH_MESSAGE(fraction >= 0 && fraction <= 1, "Web Animations not yet implemented: Timing function behavior outside the range [0, 1] is not yet specified");
|
| - return fraction;
|
| - }
|
| + virtual String toString() const OVERRIDE;
|
| +
|
| + virtual double evaluate(double fraction, double) const OVERRIDE;
|
|
|
| private:
|
| LinearTimingFunction()
|
| @@ -86,7 +88,6 @@ private:
|
| }
|
| };
|
|
|
| -
|
| // Forward declare so we can friend it below. Don't use in production code!
|
| class ChainedTimingFunctionTestHelper;
|
|
|
| @@ -136,13 +137,9 @@ public:
|
|
|
| virtual ~CubicBezierTimingFunction() { }
|
|
|
| - virtual double evaluate(double fraction, double accuracy) const OVERRIDE
|
| - {
|
| - ASSERT_WITH_MESSAGE(fraction >= 0 && fraction <= 1, "Web Animations not yet implemented: Timing function behavior outside the range [0, 1] is not yet specified");
|
| - if (!m_bezier)
|
| - m_bezier = adoptPtr(new UnitBezier(m_x1, m_y1, m_x2, m_y2));
|
| - return m_bezier->solve(fraction, accuracy);
|
| - }
|
| + virtual String toString() const OVERRIDE;
|
| +
|
| + virtual double evaluate(double fraction, double accuracy) const OVERRIDE;
|
|
|
| double x1() const { return m_x1; }
|
| double y1() const { return m_y1; }
|
| @@ -205,11 +202,9 @@ public:
|
|
|
| virtual ~StepsTimingFunction() { }
|
|
|
| - virtual double evaluate(double fraction, double) const OVERRIDE
|
| - {
|
| - ASSERT_WITH_MESSAGE(fraction >= 0 && fraction <= 1, "Web Animations not yet implemented: Timing function behavior outside the range [0, 1] is not yet specified");
|
| - return std::min(1.0, (floor(m_steps * fraction) + m_stepAtStart) / m_steps);
|
| - }
|
| + virtual String toString() const OVERRIDE;
|
| +
|
| + virtual double evaluate(double fraction, double) const OVERRIDE;
|
|
|
| int numberOfSteps() const { return m_steps; }
|
| bool stepAtStart() const { return m_stepAtStart; }
|
| @@ -243,18 +238,10 @@ public:
|
| ASSERT(upperBound > max);
|
| m_segments.append(Segment(max, upperBound, timingFunction));
|
| }
|
| - virtual double evaluate(double fraction, double accuracy) const OVERRIDE
|
| - {
|
| - ASSERT_WITH_MESSAGE(fraction >= 0 && fraction <= 1, "Web Animations not yet implemented: Timing function behavior outside the range [0, 1] is not yet specified");
|
| - ASSERT(!m_segments.isEmpty());
|
| - ASSERT(m_segments.last().max() == 1);
|
| - size_t i = 0;
|
| - const Segment* segment = &m_segments[i++];
|
| - while (fraction >= segment->max() && i < m_segments.size()) {
|
| - segment = &m_segments[i++];
|
| - }
|
| - return segment->evaluate(fraction, accuracy);
|
| - }
|
| +
|
| + virtual String toString() const OVERRIDE;
|
| +
|
| + virtual double evaluate(double fraction, double accuracy) const OVERRIDE;
|
|
|
| private:
|
| class Segment {
|
| @@ -289,6 +276,7 @@ private:
|
| // Allow PrintTo/operator== of the segments. Can be removed once
|
| // ChainedTimingFunction has a public API for segments.
|
| friend class ChainedTimingFunctionTestHelper;
|
| + friend class ChainedTimingFunction;
|
| };
|
|
|
| ChainedTimingFunction()
|
|
|