OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 AnimationValue_h | 5 #ifndef AnimationValue_h |
6 #define AnimationValue_h | 6 #define AnimationValue_h |
7 | 7 |
8 #include "core/animation/InterpolableValue.h" | 8 #include "core/animation/InterpolableValue.h" |
9 #include "core/animation/NonInterpolableValue.h" | 9 #include "core/animation/NonInterpolableValue.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class AnimationType; | 14 class AnimationType; |
15 | 15 |
16 struct AnimationValue { | 16 class AnimationValue : public NoBaseWillBeGarbageCollectedFinalized<AnimationVal
ue> { |
17 private: | |
18 DISALLOW_ALLOCATION(); | |
19 | |
20 public: | 17 public: |
21 const AnimationType* type; | 18 static PassOwnPtrWillBeRawPtr<AnimationValue> create(const AnimationType& ty
pe, PassOwnPtrWillBeRawPtr<InterpolableValue> interpolableValue, PassRefPtrWillB
eRawPtr<NonInterpolableValue> nonInterpolableValue = nullptr) |
22 OwnPtrWillBeMember<InterpolableValue> interpolableValue; | |
23 RefPtrWillBeMember<NonInterpolableValue> nonInterpolableValue; | |
24 | |
25 operator bool() const { return bool(type); } | |
26 | |
27 AnimationValue() | |
28 : type(nullptr) | |
29 , interpolableValue(nullptr) | |
30 , nonInterpolableValue(nullptr) | |
31 { } | |
32 | |
33 AnimationValue(const AnimationType* type, PassOwnPtrWillBeRawPtr<Interpolabl
eValue> interpolableValue, RefPtrWillBeRawPtr<NonInterpolableValue> nonInterpola
bleValue) | |
34 : type(type) | |
35 , interpolableValue(interpolableValue) | |
36 , nonInterpolableValue(nonInterpolableValue) | |
37 { } | |
38 | |
39 void copyFrom(const AnimationValue& other) | |
40 { | 19 { |
41 type = other.type; | 20 return adoptPtrWillBeNoop(new AnimationValue(type, interpolableValue, no
nInterpolableValue)); |
42 interpolableValue = other.interpolableValue ? other.interpolableValue->c
lone() : nullptr; | |
43 nonInterpolableValue = other.nonInterpolableValue; | |
44 } | 21 } |
45 | 22 |
46 void clear() | 23 PassOwnPtrWillBeRawPtr<AnimationValue> clone() const |
47 { | 24 { |
48 type = nullptr; | 25 return create(m_type, m_interpolableValue->clone(), m_nonInterpolableVal
ue); |
49 interpolableValue = nullptr; | |
50 nonInterpolableValue = nullptr; | |
51 } | 26 } |
52 | 27 |
| 28 const AnimationType& type() const { return m_type; } |
| 29 const InterpolableValue& interpolableValue() const { return *m_interpolableV
alue; } |
| 30 InterpolableValue& interpolableValue() { return *m_interpolableValue; } |
| 31 const NonInterpolableValue* nonInterpolableValue() const { return m_nonInter
polableValue.get(); } |
| 32 |
53 DEFINE_INLINE_TRACE() | 33 DEFINE_INLINE_TRACE() |
54 { | 34 { |
55 visitor->trace(interpolableValue); | 35 visitor->trace(m_interpolableValue); |
56 visitor->trace(nonInterpolableValue); | 36 visitor->trace(m_nonInterpolableValue); |
57 } | 37 } |
| 38 |
| 39 private: |
| 40 AnimationValue(const AnimationType& type, PassOwnPtrWillBeRawPtr<Interpolabl
eValue> interpolableValue, PassRefPtrWillBeRawPtr<NonInterpolableValue> nonInter
polableValue = nullptr) |
| 41 : m_type(type) |
| 42 , m_interpolableValue(interpolableValue) |
| 43 , m_nonInterpolableValue(nonInterpolableValue) |
| 44 { |
| 45 ASSERT(this->m_interpolableValue); |
| 46 } |
| 47 |
| 48 const AnimationType& m_type; |
| 49 OwnPtrWillBeMember<InterpolableValue> m_interpolableValue; |
| 50 RefPtrWillBeMember<NonInterpolableValue> m_nonInterpolableValue; |
| 51 |
| 52 friend class AnimationType; |
58 }; | 53 }; |
59 | 54 |
60 } // namespace blink | 55 } // namespace blink |
61 | 56 |
62 #endif // AnimationValue_h | 57 #endif // AnimationValue_h |
OLD | NEW |