| Index: Source/platform/animation/TimingFunction.h
|
| diff --git a/Source/platform/animation/TimingFunction.h b/Source/platform/animation/TimingFunction.h
|
| index 1187ea92f69b811496dbed32c149117ef8fe0f16..dc1bd98465d493b6e2632f451d6da087de3f4c31 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,6 +52,8 @@ public:
|
|
|
| Type type() const { return m_type; }
|
|
|
| + virtual String toString() const { return ""; }
|
| +
|
| // 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;
|
| @@ -73,6 +77,8 @@ public:
|
|
|
| virtual ~LinearTimingFunction() { }
|
|
|
| + virtual String toString() const OVERRIDE { return "linear"; }
|
| +
|
| virtual double evaluate(double fraction, double) const OVERRIDE
|
| {
|
| ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >= 0 && fraction <= 1));
|
| @@ -87,7 +93,6 @@ private:
|
| }
|
| };
|
|
|
| -
|
| // Forward declare so we can friend it below. Don't use in production code!
|
| class ChainedTimingFunctionTestHelper;
|
|
|
| @@ -137,6 +142,32 @@ public:
|
|
|
| virtual ~CubicBezierTimingFunction() { }
|
|
|
| + virtual String toString() const OVERRIDE
|
| + {
|
| + switch (this->subType()) {
|
| + case CubicBezierTimingFunction::Ease:
|
| + return "ease";
|
| + break;
|
| + case CubicBezierTimingFunction::EaseIn:
|
| + return "ease-in";
|
| + break;
|
| + case CubicBezierTimingFunction::EaseOut:
|
| + return "ease-out";
|
| + break;
|
| + case CubicBezierTimingFunction::EaseInOut:
|
| + return "ease-in-out";
|
| + break;
|
| + case CubicBezierTimingFunction::Custom:
|
| + return "cubic-bezier(" + String::numberToStringECMAScript(this->x1()) + ", " +
|
| + String::numberToStringECMAScript(this->y1()) + ", " + String::numberToStringECMAScript(this->x2()) +
|
| + ", " + String::numberToStringECMAScript(this->y2()) + ")";
|
| + break;
|
| + default:
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| + return "";
|
| + }
|
| +
|
| virtual double evaluate(double fraction, double accuracy) const OVERRIDE
|
| {
|
| ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >= 0 && fraction <= 1));
|
| @@ -207,6 +238,27 @@ public:
|
|
|
| virtual ~StepsTimingFunction() { }
|
|
|
| + virtual String toString() const OVERRIDE
|
| + {
|
| + StringBuilder builder;
|
| + switch (this->subType()) {
|
| + case StepsTimingFunction::Start:
|
| + return "step-start";
|
| + break;
|
| + case StepsTimingFunction::End:
|
| + return "step-end";
|
| + break;
|
| + case StepsTimingFunction::Custom:
|
| + builder.append("steps(" + String::numberToStringECMAScript(this->numberOfSteps()) + ", ");
|
| + builder.append(this->stepAtStart() ? "start" : "end");
|
| + builder.append(")");
|
| + break;
|
| + default:
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| + return builder.toString();
|
| + }
|
| +
|
| virtual double evaluate(double fraction, double) const OVERRIDE
|
| {
|
| ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >= 0 && fraction <= 1));
|
| @@ -246,6 +298,23 @@ public:
|
| ASSERT(upperBound > max);
|
| m_segments.append(Segment(max, upperBound, timingFunction));
|
| }
|
| +
|
| + virtual String toString() const OVERRIDE
|
| + {
|
| + StringBuilder builder;
|
| + builder.append("chained(");
|
| + for (size_t i = 0; i < this->m_segments.size(); i++) {
|
| + ChainedTimingFunction::Segment segment = this->m_segments[i];
|
| + builder.append(segment.m_timingFunction->toString());
|
| + builder.append("[" + String::numberToStringECMAScript(segment.m_min) + " -> " + String::numberToStringECMAScript(segment.m_max) + "]");
|
| + if (i+1 != this->m_segments.size()) {
|
| + builder.append(", ");
|
| + }
|
| + }
|
| + builder.append(")");
|
| + return builder.toString();
|
| + }
|
| +
|
| 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");
|
| @@ -292,6 +361,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()
|
|
|