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

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

Issue 2651553004: Add TransitionKeyframe class for CSS Transition refactor (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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef TransitionKeyframe_h
6 #define TransitionKeyframe_h
7
8 #include "core/CoreExport.h"
9 #include "core/animation/Keyframe.h"
10 #include "core/animation/TypedInterpolationValue.h"
11 #include "core/animation/animatable/AnimatableValue.h"
12
13 namespace blink {
14
15 class CORE_EXPORT TransitionKeyframe : public Keyframe {
16 public:
17 static PassRefPtr<TransitionKeyframe> create(const PropertyHandle& property) {
18 return adoptRef(new TransitionKeyframe(property));
19 }
20 void setValue(std::unique_ptr<TypedInterpolationValue> value) {
21 m_value = std::move(value);
22 }
23 void setCompositorValue(RefPtr<AnimatableValue>);
24 PropertyHandleSet properties() const final;
25
26 class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
27 public:
28 static PassRefPtr<PropertySpecificKeyframe> create(
29 double offset,
30 PassRefPtr<TimingFunction> easing,
31 EffectModel::CompositeOperation composite,
32 std::unique_ptr<TypedInterpolationValue> value,
33 RefPtr<AnimatableValue> compositorValue) {
34 return adoptRef(new PropertySpecificKeyframe(offset, std::move(easing),
35 composite, std::move(value),
36 std::move(compositorValue)));
37 }
38
39 PassRefPtr<AnimatableValue> getAnimatableValue() const final {
40 return m_compositorValue;
41 }
42
43 bool isNeutral() const final { return false; }
44 PassRefPtr<Keyframe::PropertySpecificKeyframe> neutralKeyframe(
45 double offset,
46 PassRefPtr<TimingFunction> easing) const final {
47 NOTREACHED();
48 return nullptr;
49 }
50 PassRefPtr<Interpolation> createInterpolation(
51 PropertyHandle,
52 const Keyframe::PropertySpecificKeyframe& other) const final;
53
54 bool isTransitionPropertySpecificKeyframe() const final { return true; }
55
56 private:
57 PropertySpecificKeyframe(double offset,
58 PassRefPtr<TimingFunction> easing,
59 EffectModel::CompositeOperation composite,
60 std::unique_ptr<TypedInterpolationValue> value,
61 RefPtr<AnimatableValue> compositorValue)
62 : Keyframe::PropertySpecificKeyframe(offset,
63 std::move(easing),
64 composite),
65 m_value(std::move(value)),
66 m_compositorValue(std::move(compositorValue)) {}
67
68 PassRefPtr<Keyframe::PropertySpecificKeyframe> cloneWithOffset(
69 double offset) const final {
70 return create(offset, m_easing, m_composite, m_value->clone(),
71 m_compositorValue);
72 }
73
74 std::unique_ptr<TypedInterpolationValue> m_value;
75 RefPtr<AnimatableValue> m_compositorValue;
76 };
77
78 private:
79 TransitionKeyframe(const PropertyHandle& property) : m_property(property) {}
80
81 TransitionKeyframe(const TransitionKeyframe& copyFrom)
82 : m_property(copyFrom.m_property),
83 m_value(copyFrom.m_value->clone()),
84 m_compositorValue(copyFrom.m_compositorValue) {}
85
86 bool isTransitionKeyframe() const final { return true; }
87
88 PassRefPtr<Keyframe> clone() const final {
89 return adoptRef(new TransitionKeyframe(*this));
90 }
91
92 PassRefPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecificKeyframe(
93 PropertyHandle) const final;
94
95 PropertyHandle m_property;
96 std::unique_ptr<TypedInterpolationValue> m_value;
97 RefPtr<AnimatableValue> m_compositorValue;
98 };
99
100 using TransitionPropertySpecificKeyframe =
101 TransitionKeyframe::PropertySpecificKeyframe;
102
103 DEFINE_TYPE_CASTS(TransitionKeyframe,
104 Keyframe,
105 value,
106 value->isTransitionKeyframe(),
107 value.isTransitionKeyframe());
108 DEFINE_TYPE_CASTS(TransitionPropertySpecificKeyframe,
109 Keyframe::PropertySpecificKeyframe,
110 value,
111 value->isTransitionPropertySpecificKeyframe(),
112 value.isTransitionPropertySpecificKeyframe());
113
114 } // namespace blink
115
116 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698