Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: third_party/WebKit/Source/core/animation/LegacyStyleInterpolation.h

Issue 2617703004: Combine {Legacy,}StyleInterpolation (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 12 #include "core/css/resolver/AnimatedStyleBuilder.h"
13 #include <memory> 13 #include <memory>
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class StyleResolverState; 17 class StyleResolverState;
18 18
19 class CORE_EXPORT StyleInterpolation : public Interpolation { 19 class CORE_EXPORT LegacyStyleInterpolation : public Interpolation {
20 public:
21 // 1) convert m_cachedValue into an X
22 // 2) shove X into StyleResolverState
23 // X can be:
24 // (1) a CSSValue (and applied via StyleBuilder::applyProperty)
25 // (2) an AnimatableValue (and applied via
26 // AnimatedStyleBuilder::applyProperty)
27 // (3) a custom value that is inserted directly into the StyleResolverState.
28 virtual void apply(StyleResolverState&) const = 0;
29
30 bool isStyleInterpolation() const final { return true; }
31
32 CSSPropertyID id() const { return m_id; }
33
34 PropertyHandle getProperty() const final { return PropertyHandle(id()); }
35
36 protected:
37 CSSPropertyID m_id;
38
39 StyleInterpolation(std::unique_ptr<InterpolableValue> start,
40 std::unique_ptr<InterpolableValue> end,
41 CSSPropertyID id)
42 : Interpolation(std::move(start), std::move(end)), m_id(id) {}
43 };
44
45 DEFINE_TYPE_CASTS(StyleInterpolation,
46 Interpolation,
47 value,
48 value->isStyleInterpolation(),
49 value.isStyleInterpolation());
50
51 class LegacyStyleInterpolation : public StyleInterpolation {
52 public: 20 public:
53 static PassRefPtr<LegacyStyleInterpolation> create( 21 static PassRefPtr<LegacyStyleInterpolation> create(
54 PassRefPtr<AnimatableValue> start, 22 PassRefPtr<AnimatableValue> start,
55 PassRefPtr<AnimatableValue> end, 23 PassRefPtr<AnimatableValue> end,
56 CSSPropertyID id) { 24 CSSPropertyID id) {
57 return adoptRef(new LegacyStyleInterpolation( 25 return adoptRef(new LegacyStyleInterpolation(
58 InterpolableAnimatableValue::create(std::move(start)), 26 InterpolableAnimatableValue::create(std::move(start)),
59 InterpolableAnimatableValue::create(std::move(end)), id)); 27 InterpolableAnimatableValue::create(std::move(end)), id));
60 } 28 }
61 29
62 void apply(StyleResolverState& state) const override { 30 // 1) convert m_cachedValue into an X
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 {
63 AnimatedStyleBuilder::applyProperty(m_id, state, currentValue().get()); 38 AnimatedStyleBuilder::applyProperty(m_id, state, currentValue().get());
64 } 39 }
65 40
66 bool isLegacyStyleInterpolation() const final { return true; } 41 bool isLegacyStyleInterpolation() const final { return true; }
42
67 PassRefPtr<AnimatableValue> currentValue() const { 43 PassRefPtr<AnimatableValue> currentValue() const {
68 return toInterpolableAnimatableValue(m_cachedValue.get())->value(); 44 return toInterpolableAnimatableValue(m_cachedValue.get())->value();
69 } 45 }
70 46
47 CSSPropertyID id() const { return m_id; }
48
49 PropertyHandle getProperty() const final { return PropertyHandle(id()); }
50
71 private: 51 private:
52 CSSPropertyID m_id;
53
72 LegacyStyleInterpolation(std::unique_ptr<InterpolableValue> start, 54 LegacyStyleInterpolation(std::unique_ptr<InterpolableValue> start,
73 std::unique_ptr<InterpolableValue> end, 55 std::unique_ptr<InterpolableValue> end,
74 CSSPropertyID id) 56 CSSPropertyID id)
75 : StyleInterpolation(std::move(start), std::move(end), id) {} 57 : Interpolation(std::move(start), std::move(end)), m_id(id) {}
76 }; 58 };
77 59
78 DEFINE_TYPE_CASTS(LegacyStyleInterpolation, 60 DEFINE_TYPE_CASTS(LegacyStyleInterpolation,
79 Interpolation, 61 Interpolation,
80 value, 62 value,
81 value->isLegacyStyleInterpolation(), 63 value->isLegacyStyleInterpolation(),
82 value.isLegacyStyleInterpolation()); 64 value.isLegacyStyleInterpolation());
83 65
84 } // namespace blink 66 } // namespace blink
85 67
86 #endif 68 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698