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 #ifndef LegacyStyleInterpolation_h | 5 #ifndef LegacyStyleInterpolation_h |
6 #define LegacyStyleInterpolation_h | 6 #define LegacyStyleInterpolation_h |
7 | 7 |
8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
10 #include "core/animation/Interpolation.h" | 10 #include "core/animation/Interpolation.h" |
11 #include "core/animation/PropertyHandle.h" | 11 #include "core/animation/PropertyHandle.h" |
12 #include "core/css/resolver/AnimatedStyleBuilder.h" | |
13 #include <memory> | 12 #include <memory> |
14 | 13 |
15 namespace blink { | 14 namespace blink { |
16 | 15 |
17 class StyleResolverState; | 16 class StyleResolverState; |
18 | 17 |
19 class CORE_EXPORT LegacyStyleInterpolation : public Interpolation { | 18 class CORE_EXPORT LegacyStyleInterpolation : public Interpolation { |
20 public: | 19 public: |
21 static PassRefPtr<LegacyStyleInterpolation> create( | 20 static PassRefPtr<LegacyStyleInterpolation> create( |
22 PassRefPtr<AnimatableValue> start, | 21 PassRefPtr<AnimatableValue> start, |
23 PassRefPtr<AnimatableValue> end, | 22 PassRefPtr<AnimatableValue> end, |
24 CSSPropertyID id) { | 23 CSSPropertyID id) { |
25 return adoptRef(new LegacyStyleInterpolation( | 24 return adoptRef(new LegacyStyleInterpolation( |
26 InterpolableAnimatableValue::create(std::move(start)), | 25 InterpolableAnimatableValue::create(std::move(start)), |
27 InterpolableAnimatableValue::create(std::move(end)), id)); | 26 InterpolableAnimatableValue::create(std::move(end)), id)); |
28 } | 27 } |
29 | 28 |
30 // 1) convert m_cachedValue into an X | 29 void apply(StyleResolverState&) const; |
31 // 2) shove X into StyleResolverState | |
32 // X can be: | |
33 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) | |
34 // (2) an AnimatableValue (and applied via | |
35 // AnimatedStyleBuilder::applyProperty) | |
36 // (3) a custom value that is inserted directly into the StyleResolverState. | |
37 void apply(StyleResolverState& state) const { | |
38 AnimatedStyleBuilder::applyProperty(id(), state, currentValue().get()); | |
39 } | |
40 | 30 |
41 bool isLegacyStyleInterpolation() const final { return true; } | 31 bool isLegacyStyleInterpolation() const final { return true; } |
42 | 32 |
43 PassRefPtr<AnimatableValue> currentValue() const { | 33 PassRefPtr<AnimatableValue> currentValue() const { |
44 return toInterpolableAnimatableValue(m_cachedValue.get())->value(); | 34 return toInterpolableAnimatableValue(m_cachedValue.get())->value(); |
45 } | 35 } |
46 | 36 |
47 CSSPropertyID id() const { return m_property.cssProperty(); } | 37 CSSPropertyID id() const { return m_property.cssProperty(); } |
48 | 38 |
49 const PropertyHandle& getProperty() const final { return m_property; } | 39 const PropertyHandle& getProperty() const final { return m_property; } |
(...skipping 24 matching lines...) Expand all Loading... |
74 | 64 |
75 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, | 65 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, |
76 Interpolation, | 66 Interpolation, |
77 value, | 67 value, |
78 value->isLegacyStyleInterpolation(), | 68 value->isLegacyStyleInterpolation(), |
79 value.isLegacyStyleInterpolation()); | 69 value.isLegacyStyleInterpolation()); |
80 | 70 |
81 } // namespace blink | 71 } // namespace blink |
82 | 72 |
83 #endif | 73 #endif |
OLD | NEW |