OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "core/animation/Interpolation.h" |
| 7 |
| 8 namespace WebCore { |
| 9 |
| 10 namespace { |
| 11 |
| 12 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) |
| 13 { |
| 14 if (start->isNumber()) |
| 15 return end->isNumber(); |
| 16 if (start->isBool()) |
| 17 return end->isBool(); |
| 18 if (!(start->isList() && end->isList())) |
| 19 return false; |
| 20 const InterpolableList* startList = toInterpolableList(start); |
| 21 const InterpolableList* endList = toInterpolableList(end); |
| 22 if (startList->length() != endList->length()) |
| 23 return false; |
| 24 for (size_t i = 0; i < startList->length(); ++i) { |
| 25 if (!typesMatch(startList->get(i), endList->get(i))) |
| 26 return false; |
| 27 } |
| 28 return true; |
| 29 } |
| 30 |
| 31 } |
| 32 |
| 33 Interpolation::Interpolation(PassOwnPtr<InterpolableValue> start, PassOwnPtr<Int
erpolableValue> end) |
| 34 : m_start(start) |
| 35 , m_end(end) |
| 36 , m_cachedFraction(0) |
| 37 , m_cachedValue(m_start->clone()) |
| 38 { |
| 39 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); |
| 40 } |
| 41 |
| 42 void Interpolation::interpolate(double fraction) const |
| 43 { |
| 44 if (m_cachedFraction != fraction) { |
| 45 m_cachedValue = m_start->interpolate(*m_end, fraction); |
| 46 m_cachedFraction = fraction; |
| 47 } |
| 48 } |
| 49 |
| 50 } |
OLD | NEW |