Chromium Code Reviews| Index: Source/platform/animation/TimingFunction.cpp |
| diff --git a/Source/platform/animation/TimingFunction.cpp b/Source/platform/animation/TimingFunction.cpp |
| index f196dab07a1270fabd7cc1599bd541351438e967..adde4002bb4560dfe76e0af741e5414510995939 100644 |
| --- a/Source/platform/animation/TimingFunction.cpp |
| +++ b/Source/platform/animation/TimingFunction.cpp |
| @@ -47,17 +47,29 @@ double CubicBezierTimingFunction::evaluate(double fraction, double accuracy) con |
| return m_bezier->solve(fraction, accuracy); |
| } |
| +// FIXME: Unit test this thoroughly |
|
dstockwell
2014/02/24 04:58:40
Not a good fixme.
rjwright
2014/02/24 11:17:46
Done.
|
| String StepsTimingFunction::toString() const |
| { |
| StringBuilder builder; |
| switch (this->subType()) { |
| case StepsTimingFunction::Start: |
| return "step-start"; |
| + case StepsTimingFunction::Middle: |
| + return "step-middle"; |
| case StepsTimingFunction::End: |
| return "step-end"; |
| case StepsTimingFunction::Custom: |
| builder.append("steps(" + String::numberToStringECMAScript(this->numberOfSteps()) + ", "); |
| - builder.append(this->stepAtStart() ? "start" : "end"); |
| + |
| + if (this->stepAtPosition() == StepsTimingFunction::StepAtStart) |
| + builder.append("start"); |
| + else if (this->stepAtPosition() == StepsTimingFunction::StepAtMiddle) |
| + builder.append("middle"); |
| + else if (this->stepAtPosition() == StepsTimingFunction::StepAtEnd) |
| + builder.append("end"); |
| + else |
| + ASSERT_NOT_REACHED(); |
| + |
| builder.append(")"); |
| break; |
| default: |
| @@ -69,7 +81,22 @@ String StepsTimingFunction::toString() const |
| double StepsTimingFunction::evaluate(double fraction, double) const |
| { |
| 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); |
| + double startOffset = 0; |
| + switch (m_stepAtPosition) { |
| + case StepAtStart: |
| + startOffset = 1; |
| + break; |
| + case StepAtMiddle: |
| + startOffset = 0.5; |
| + break; |
| + case StepAtEnd: |
| + startOffset = 0; |
| + break; |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + break; |
| + } |
| + return std::min(1.0, floor((m_steps * fraction) + startOffset) / m_steps); |
| } |
| String ChainedTimingFunction::toString() const |