Chromium Code Reviews| Index: Source/core/animation/Interpolation.cpp |
| diff --git a/Source/core/animation/Interpolation.cpp b/Source/core/animation/Interpolation.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..46f8facd21367d0f5fd7e96b6c15eda46665b505 |
| --- /dev/null |
| +++ b/Source/core/animation/Interpolation.cpp |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "core/animation/Interpolation.h" |
| + |
| +namespace WebCore { |
| + |
| +void Interpolation::interpolate(double fraction) const |
| +{ |
| + if (m_cachedFraction != fraction) { |
| + m_cachedValue = m_start->interpolate(*m_end, fraction); |
| + m_cachedFraction = fraction; |
| + } |
| +} |
| + |
| +namespace { |
| + |
| +bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) |
| +{ |
| + if (start->isNumber()) |
| + return end->isNumber(); |
| + if (start->isBool()) |
| + return end->isBool(); |
| + const InterpolableList* startList = toInterpolableList(start); |
| + const InterpolableList* endList = toInterpolableList(end); |
|
Timothy Loh
2014/03/06 02:54:49
Probably need to explicitly check for end->isList(
shans
2014/03/06 04:42:57
Done.
|
| + if (startList->length() != endList->length()) |
| + return false; |
| + for (size_t i = 0; i < startList->length(); ++i) { |
| + if (!typesMatch(startList->get(i), endList->get(i))) |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| +} |
| + |
| +Interpolation::Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<InterpolableValue> end) |
|
alancutter (OOO until 2018)
2014/03/05 04:30:43
Constructors are usually at the top of source file
shans
2014/03/06 04:42:57
Done.
|
| + : m_start(start) |
| + , m_end(end) |
| + , m_cachedFraction(0) |
| + , m_cachedValue(m_start->clone()) |
| +{ |
| + ASSERT(typesMatch(m_start.get(), m_end.get())); |
|
dstockwell
2014/03/06 02:12:19
I thought this was going to be a release assert to
shans
2014/03/06 04:42:57
Done.
|
| +} |
| + |
| +} |