OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/animation/InterpolableValue.h" | 6 #include "core/animation/InterpolableValue.h" |
7 | 7 |
8 namespace blink { | 8 namespace blink { |
9 | 9 |
10 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue); | 10 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue); |
11 | 11 |
| 12 bool InterpolableValue::typesMatch(const InterpolableValue& other) const |
| 13 { |
| 14 if (isNumber()) |
| 15 return other.isNumber(); |
| 16 if (isBool()) |
| 17 return other.isBool(); |
| 18 if (isAnimatableValue()) |
| 19 return other.isAnimatableValue(); |
| 20 if (!(isList() && other.isList())) |
| 21 return false; |
| 22 const InterpolableList& listA = toInterpolableList(*this); |
| 23 const InterpolableList& listB = toInterpolableList(other); |
| 24 if (listA.length() != listB.length()) |
| 25 return false; |
| 26 for (size_t i = 0; i < listA.length(); ++i) { |
| 27 if (!listA.get(i)->typesMatch(*listB.get(i))) |
| 28 return false; |
| 29 } |
| 30 return true; |
| 31 } |
| 32 |
12 void InterpolableNumber::interpolate(const InterpolableValue &to, const double p
rogress, InterpolableValue& result) const | 33 void InterpolableNumber::interpolate(const InterpolableValue &to, const double p
rogress, InterpolableValue& result) const |
13 { | 34 { |
14 const InterpolableNumber& toNumber = toInterpolableNumber(to); | 35 const InterpolableNumber& toNumber = toInterpolableNumber(to); |
15 InterpolableNumber& resultNumber = toInterpolableNumber(result); | 36 InterpolableNumber& resultNumber = toInterpolableNumber(result); |
16 | 37 |
17 if (progress == 0) | 38 if (progress == 0) |
18 resultNumber.m_value = m_value; | 39 resultNumber.m_value = m_value; |
19 else if (progress == 1) | 40 else if (progress == 1) |
20 resultNumber.m_value = toNumber.m_value; | 41 resultNumber.m_value = toNumber.m_value; |
21 else | 42 else |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 resultValue.m_value = AnimatableValue::interpolate(m_value.get(), toValue.m_
value.get(), progress); | 138 resultValue.m_value = AnimatableValue::interpolate(m_value.get(), toValue.m_
value.get(), progress); |
118 } | 139 } |
119 | 140 |
120 void InterpolableAnimatableValue::trace(Visitor* visitor) | 141 void InterpolableAnimatableValue::trace(Visitor* visitor) |
121 { | 142 { |
122 visitor->trace(m_value); | 143 visitor->trace(m_value); |
123 InterpolableValue::trace(visitor); | 144 InterpolableValue::trace(visitor); |
124 } | 145 } |
125 | 146 |
126 } | 147 } |
OLD | NEW |