OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "core/animation/Interpolation.h" | 5 #include "core/animation/LegacyStyleInterpolation.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) { | 13 bool typesMatch(const InterpolableValue* start, const InterpolableValue* end) { |
14 if (start == end) | 14 if (start == end) |
15 return true; | 15 return true; |
(...skipping 11 matching lines...) Expand all Loading... |
27 return false; | 27 return false; |
28 for (size_t i = 0; i < startList->length(); ++i) { | 28 for (size_t i = 0; i < startList->length(); ++i) { |
29 if (!typesMatch(startList->get(i), endList->get(i))) | 29 if (!typesMatch(startList->get(i), endList->get(i))) |
30 return false; | 30 return false; |
31 } | 31 } |
32 return true; | 32 return true; |
33 } | 33 } |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 Interpolation::Interpolation(std::unique_ptr<InterpolableValue> start, | 37 LegacyStyleInterpolation::LegacyStyleInterpolation( |
38 std::unique_ptr<InterpolableValue> end) | 38 std::unique_ptr<InterpolableValue> start, |
39 : m_start(std::move(start)), | 39 std::unique_ptr<InterpolableValue> end, |
| 40 CSSPropertyID id) |
| 41 : Interpolation(), |
| 42 m_start(std::move(start)), |
40 m_end(std::move(end)), | 43 m_end(std::move(end)), |
| 44 m_id(id), |
41 m_cachedFraction(0), | 45 m_cachedFraction(0), |
42 m_cachedIteration(0), | 46 m_cachedIteration(0), |
43 m_cachedValue(m_start ? m_start->clone() : nullptr) { | 47 m_cachedValue(m_start ? m_start->clone() : nullptr) { |
44 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); | 48 RELEASE_ASSERT(typesMatch(m_start.get(), m_end.get())); |
45 } | 49 } |
46 | 50 |
47 Interpolation::~Interpolation() {} | 51 void LegacyStyleInterpolation::interpolate(int iteration, double fraction) { |
48 | |
49 void Interpolation::interpolate(int iteration, double fraction) { | |
50 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { | 52 if (m_cachedFraction != fraction || m_cachedIteration != iteration) { |
51 m_start->interpolate(*m_end, fraction, *m_cachedValue); | 53 m_start->interpolate(*m_end, fraction, *m_cachedValue); |
52 m_cachedIteration = iteration; | 54 m_cachedIteration = iteration; |
53 m_cachedFraction = fraction; | 55 m_cachedFraction = fraction; |
54 } | 56 } |
55 } | 57 } |
56 | 58 |
57 } // namespace blink | 59 } // namespace blink |
OLD | NEW |