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

Side by Side Diff: Source/core/animation/InterpolableValue.h

Issue 1082293003: Componentization: make core/animation,clipboard,css,dom,editing,frame,html visible for blink_web. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WIP Created 5 years, 8 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 InterpolableValue_h 5 #ifndef InterpolableValue_h
6 #define InterpolableValue_h 6 #define InterpolableValue_h
7 7
8 #include "core/CoreExport.h"
8 #include "core/animation/animatable/AnimatableValue.h" 9 #include "core/animation/animatable/AnimatableValue.h"
9 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
10 #include "wtf/OwnPtr.h" 11 #include "wtf/OwnPtr.h"
11 #include "wtf/PassOwnPtr.h" 12 #include "wtf/PassOwnPtr.h"
12 #include "wtf/Vector.h" 13 #include "wtf/Vector.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class InterpolableValue : public NoBaseWillBeGarbageCollected<InterpolableValue> { 17 class CORE_EXPORT InterpolableValue : public NoBaseWillBeGarbageCollected<Interp olableValue> {
17 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue); 18 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue);
18 public: 19 public:
19 virtual bool isNumber() const { return false; } 20 virtual bool isNumber() const { return false; }
20 virtual bool isBool() const { return false; } 21 virtual bool isBool() const { return false; }
21 virtual bool isList() const { return false; } 22 virtual bool isList() const { return false; }
22 virtual bool isAnimatableValue() const { return false; } 23 virtual bool isAnimatableValue() const { return false; }
23 24
24 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0; 25 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const = 0;
25 26
26 DEFINE_INLINE_VIRTUAL_TRACE() { } 27 DEFINE_INLINE_VIRTUAL_TRACE() { }
27 28
28 private: 29 private:
29 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const = 0; 30 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const = 0;
30 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst = 0; 31 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst = 0;
31 virtual void multiply(double scalar, InterpolableValue& result) const = 0; 32 virtual void multiply(double scalar, InterpolableValue& result) const = 0;
32 33
33 friend class Interpolation; 34 friend class Interpolation;
34 35
35 // Keep interpolate private, but allow calls within the hierarchy without 36 // Keep interpolate private, but allow calls within the hierarchy without
36 // knowledge of type. 37 // knowledge of type.
37 friend class DeferredLegacyStyleInterpolation; 38 friend class DeferredLegacyStyleInterpolation;
38 friend class InterpolableNumber; 39 friend class InterpolableNumber;
39 friend class InterpolableBool; 40 friend class InterpolableBool;
40 friend class InterpolableList; 41 friend class InterpolableList;
41 42
42 friend class AnimationInterpolableValueTest; 43 friend class AnimationInterpolableValueTest;
43 }; 44 };
44 45
45 class InterpolableNumber final : public InterpolableValue { 46 class CORE_EXPORT InterpolableNumber final : public InterpolableValue {
46 public: 47 public:
47 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value) 48 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value)
48 { 49 {
49 return adoptPtrWillBeNoop(new InterpolableNumber(value)); 50 return adoptPtrWillBeNoop(new InterpolableNumber(value));
50 } 51 }
51 52
52 virtual bool isNumber() const override final { return true; } 53 virtual bool isNumber() const override final { return true; }
53 double value() const { return m_value; } 54 double value() const { return m_value; }
54 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin al { return create(m_value); } 55 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin al { return create(m_value); }
55 56
56 private: 57 private:
57 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const override final; 58 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const override final;
58 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst override final; 59 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst override final;
59 virtual void multiply(double scalar, InterpolableValue& result) const overri de final; 60 virtual void multiply(double scalar, InterpolableValue& result) const overri de final;
60 double m_value; 61 double m_value;
61 62
62 explicit InterpolableNumber(double value) 63 explicit InterpolableNumber(double value)
63 : m_value(value) 64 : m_value(value)
64 { 65 {
65 } 66 }
66 67
67 }; 68 };
68 69
69 class InterpolableBool final : public InterpolableValue { 70 class CORE_EXPORT InterpolableBool final : public InterpolableValue {
70 public: 71 public:
71 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value) 72 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value)
72 { 73 {
73 return adoptPtrWillBeNoop(new InterpolableBool(value)); 74 return adoptPtrWillBeNoop(new InterpolableBool(value));
74 } 75 }
75 76
76 virtual bool isBool() const override final { return true; } 77 virtual bool isBool() const override final { return true; }
77 bool value() const { return m_value; } 78 bool value() const { return m_value; }
78 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin al { return create(m_value); } 79 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin al { return create(m_value); }
79 80
80 private: 81 private:
81 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const override final; 82 virtual void interpolate(const InterpolableValue& to, const double progress, InterpolableValue& result) const override final;
82 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst override final; 83 virtual void add(const InterpolableValue& rhs, InterpolableValue& result) co nst override final;
83 virtual void multiply(double scalar, InterpolableValue& result) const overri de final { ASSERT_NOT_REACHED(); } 84 virtual void multiply(double scalar, InterpolableValue& result) const overri de final { ASSERT_NOT_REACHED(); }
84 bool m_value; 85 bool m_value;
85 86
86 explicit InterpolableBool(bool value) 87 explicit InterpolableBool(bool value)
87 : m_value(value) 88 : m_value(value)
88 { 89 {
89 } 90 }
90 91
91 }; 92 };
92 93
93 class InterpolableList : public InterpolableValue { 94 class CORE_EXPORT InterpolableList : public InterpolableValue {
tasak 2015/04/15 06:08:15 Need to delete operator=, because of error C2248:
94 public: 95 public:
95 static PassOwnPtrWillBeRawPtr<InterpolableList> create(const InterpolableLis t &other) 96 static PassOwnPtrWillBeRawPtr<InterpolableList> create(const InterpolableLis t &other)
96 { 97 {
97 return adoptPtrWillBeNoop(new InterpolableList(other)); 98 return adoptPtrWillBeNoop(new InterpolableList(other));
98 } 99 }
99 100
100 static PassOwnPtrWillBeRawPtr<InterpolableList> create(size_t size) 101 static PassOwnPtrWillBeRawPtr<InterpolableList> create(size_t size)
101 { 102 {
102 return adoptPtrWillBeNoop(new InterpolableList(size)); 103 return adoptPtrWillBeNoop(new InterpolableList(size));
103 } 104 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 }; 168 };
168 169
169 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber( ), value.isNumber()); 170 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber( ), value.isNumber());
170 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v alue.isBool()); 171 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v alue.isBool());
171 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v alue.isList()); 172 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v alue.isList());
172 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value-> isAnimatableValue(), value.isAnimatableValue()); 173 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value-> isAnimatableValue(), value.isAnimatableValue());
173 174
174 } 175 }
175 176
176 #endif 177 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698