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

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

Issue 2651553004: Add TransitionKeyframe class for CSS Transition refactor (Closed)
Patch Set: Header Created 3 years, 10 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 const 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 : Keyframe(copyFrom.m_offset, copyFrom.m_composite, copyFrom.m_easing),
83 m_property(copyFrom.m_property),
84 m_value(copyFrom.m_value->clone()),
85 m_compositorValue(copyFrom.m_compositorValue) {}
86
87 bool isTransitionKeyframe() const final { return true; }
88
89 PassRefPtr<Keyframe> clone() const final {
90 return adoptRef(new TransitionKeyframe(*this));
91 }
92
93 PassRefPtr<Keyframe::PropertySpecificKeyframe> createPropertySpecificKeyframe(
94 const PropertyHandle&) const final;
95
96 PropertyHandle m_property;
97 std::unique_ptr<TypedInterpolationValue> m_value;
98 RefPtr<AnimatableValue> m_compositorValue;
99 };
100
101 using TransitionPropertySpecificKeyframe =
102 TransitionKeyframe::PropertySpecificKeyframe;
103
104 DEFINE_TYPE_CASTS(TransitionKeyframe,
105 Keyframe,
106 value,
107 value->isTransitionKeyframe(),
108 value.isTransitionKeyframe());
109 DEFINE_TYPE_CASTS(TransitionPropertySpecificKeyframe,
110 Keyframe::PropertySpecificKeyframe,
111 value,
112 value->isTransitionPropertySpecificKeyframe(),
113 value.isTransitionPropertySpecificKeyframe());
114
115 } // namespace blink
116
117 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/Keyframe.h ('k') | third_party/WebKit/Source/core/animation/TransitionKeyframe.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698