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/Interpolation.h" | 6 #include "core/animation/Interpolation.h" |
7 | 7 |
8 #include "core/css/CSSCalculationValue.h" | 8 #include "core/css/CSSCalculationValue.h" |
9 #include "core/css/resolver/AnimatedStyleBuilder.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
10 #include "core/css/resolver/StyleBuilder.h" | 10 #include "core/css/resolver/StyleBuilder.h" |
11 #include "core/css/resolver/StyleResolverState.h" | |
12 | 11 |
13 namespace WebCore { | 12 namespace WebCore { |
14 | 13 |
15 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Interpolation); | 14 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Interpolation); |
16 | 15 |
17 namespace { | 16 namespace { |
18 | 17 |
19 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) | 18 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) |
20 { | 19 { |
21 if (start->isNumber()) | 20 if (start->isNumber()) |
(...skipping 15 matching lines...) Expand all Loading... |
37 return true; | 36 return true; |
38 } | 37 } |
39 | 38 |
40 } | 39 } |
41 | 40 |
42 Interpolation::Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa
ssOwnPtrWillBeRawPtr<InterpolableValue> end) | 41 Interpolation::Interpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa
ssOwnPtrWillBeRawPtr<InterpolableValue> end) |
43 : m_start(start) | 42 : m_start(start) |
44 , m_end(end) | 43 , m_end(end) |
45 , m_cachedFraction(0) | 44 , m_cachedFraction(0) |
46 , m_cachedIteration(0) | 45 , m_cachedIteration(0) |
47 , m_cachedValue(m_start->clone()) | |
48 { | 46 { |
49 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); | 47 if (m_start) { |
| 48 m_cachedValue = m_start->clone(); |
| 49 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); |
| 50 } |
50 } | 51 } |
51 | 52 |
52 void Interpolation::interpolate(int iteration, double fraction) const | 53 void Interpolation::interpolate(int iteration, double fraction) const |
53 { | 54 { |
54 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { | 55 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { |
55 m_cachedValue = m_start->interpolate(*m_end, fraction); | 56 if (m_start) |
| 57 m_cachedValue = m_start->interpolate(*m_end, fraction); |
56 m_cachedIteration = iteration; | 58 m_cachedIteration = iteration; |
57 m_cachedFraction = fraction; | 59 m_cachedFraction = fraction; |
58 } | 60 } |
59 } | 61 } |
60 | 62 |
61 void Interpolation::trace(Visitor* visitor) | 63 void Interpolation::trace(Visitor* visitor) |
62 { | 64 { |
63 visitor->trace(m_start); | 65 visitor->trace(m_start); |
64 visitor->trace(m_end); | 66 visitor->trace(m_end); |
65 visitor->trace(m_cachedValue); | 67 visitor->trace(m_cachedValue); |
66 } | 68 } |
67 | 69 |
68 void StyleInterpolation::trace(Visitor* visitor) | 70 void StyleInterpolation::trace(Visitor* visitor) |
69 { | 71 { |
70 Interpolation::trace(visitor); | 72 Interpolation::trace(visitor); |
71 } | 73 } |
72 | 74 |
73 void LegacyStyleInterpolation::apply(StyleResolverState& state) const | |
74 { | |
75 AnimatedStyleBuilder::applyProperty(m_id, state, currentValue().get()); | |
76 } | |
77 | |
78 void LegacyStyleInterpolation::trace(Visitor* visitor) | |
79 { | |
80 StyleInterpolation::trace(visitor); | |
81 } | |
82 | |
83 bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value) | 75 bool LengthStyleInterpolation::canCreateFrom(const CSSValue& value) |
84 { | 76 { |
85 if (value.isPrimitiveValue()) { | 77 if (value.isPrimitiveValue()) { |
86 const CSSPrimitiveValue& primitiveValue = WebCore::toCSSPrimitiveValue(v
alue); | 78 const CSSPrimitiveValue& primitiveValue = WebCore::toCSSPrimitiveValue(v
alue); |
87 if (primitiveValue.cssCalcValue()) | 79 if (primitiveValue.cssCalcValue()) |
88 return true; | 80 return true; |
89 | 81 |
90 CSSPrimitiveValue::LengthUnitType type; | 82 CSSPrimitiveValue::LengthUnitType type; |
91 // Only returns true if the type is a primitive length unit. | 83 // Only returns true if the type is a primitive length unit. |
92 return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primit
iveType(), type); | 84 return CSSPrimitiveValue::unitTypeToLengthUnitType(primitiveValue.primit
iveType(), type); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 170 } |
179 | 171 |
180 void DefaultStyleInterpolation::trace(Visitor* visitor) | 172 void DefaultStyleInterpolation::trace(Visitor* visitor) |
181 { | 173 { |
182 StyleInterpolation::trace(visitor); | 174 StyleInterpolation::trace(visitor); |
183 visitor->trace(m_startCSSValue); | 175 visitor->trace(m_startCSSValue); |
184 visitor->trace(m_endCSSValue); | 176 visitor->trace(m_endCSSValue); |
185 } | 177 } |
186 | 178 |
187 } | 179 } |
OLD | NEW |