OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 20 matching lines...) Expand all Loading... |
31 #ifndef AnimatableValue_h | 31 #ifndef AnimatableValue_h |
32 #define AnimatableValue_h | 32 #define AnimatableValue_h |
33 | 33 |
34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
35 #include "core/css/CSSValue.h" | 35 #include "core/css/CSSValue.h" |
36 #include "platform/heap/Handle.h" | 36 #include "platform/heap/Handle.h" |
37 #include "wtf/RefCounted.h" | 37 #include "wtf/RefCounted.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 class CORE_EXPORT AnimatableValue : public RefCountedWillBeGarbageCollectedFinal
ized<AnimatableValue> { | 41 class CORE_EXPORT AnimatableValue : public RefCounted<AnimatableValue> { |
42 public: | 42 public: |
43 virtual ~AnimatableValue() { } | 43 virtual ~AnimatableValue() { } |
44 | 44 |
45 static const AnimatableValue* neutralValue(); | 45 static const AnimatableValue* neutralValue(); |
46 | 46 |
47 static PassRefPtrWillBeRawPtr<AnimatableValue> interpolate(const AnimatableV
alue*, const AnimatableValue*, double fraction); | 47 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, const
AnimatableValue*, double fraction); |
48 static bool usesDefaultInterpolation(const AnimatableValue* from, const Anim
atableValue* to) | 48 static bool usesDefaultInterpolation(const AnimatableValue* from, const Anim
atableValue* to) |
49 { | 49 { |
50 return !from->isSameType(to) || from->usesDefaultInterpolationWith(to); | 50 return !from->isSameType(to) || from->usesDefaultInterpolationWith(to); |
51 } | 51 } |
52 | 52 |
53 bool equals(const AnimatableValue* value) const | 53 bool equals(const AnimatableValue* value) const |
54 { | 54 { |
55 return isSameType(value) && equalTo(value); | 55 return isSameType(value) && equalTo(value); |
56 } | 56 } |
57 bool equals(const AnimatableValue& value) const | 57 bool equals(const AnimatableValue& value) const |
(...skipping 23 matching lines...) Expand all Loading... |
81 bool isTransform() const { return type() == TypeTransform; } | 81 bool isTransform() const { return type() == TypeTransform; } |
82 bool isUnknown() const { return type() == TypeUnknown; } | 82 bool isUnknown() const { return type() == TypeUnknown; } |
83 bool isVisibility() const { return type() == TypeVisibility; } | 83 bool isVisibility() const { return type() == TypeVisibility; } |
84 | 84 |
85 bool isSameType(const AnimatableValue* value) const | 85 bool isSameType(const AnimatableValue* value) const |
86 { | 86 { |
87 ASSERT(value); | 87 ASSERT(value); |
88 return value->type() == type(); | 88 return value->type() == type(); |
89 } | 89 } |
90 | 90 |
91 DEFINE_INLINE_VIRTUAL_TRACE() { } | |
92 | |
93 protected: | 91 protected: |
94 enum AnimatableType { | 92 enum AnimatableType { |
95 TypeClipPathOperation, | 93 TypeClipPathOperation, |
96 TypeColor, | 94 TypeColor, |
97 TypeDouble, | 95 TypeDouble, |
98 TypeDoubleAndBool, | 96 TypeDoubleAndBool, |
99 TypeFilterOperations, | 97 TypeFilterOperations, |
100 TypeImage, | 98 TypeImage, |
101 TypeLength, | 99 TypeLength, |
102 TypeLengthBox, | 100 TypeLengthBox, |
103 TypeLengthBoxAndBool, | 101 TypeLengthBoxAndBool, |
104 TypeLengthPoint, | 102 TypeLengthPoint, |
105 TypeLengthPoint3D, | 103 TypeLengthPoint3D, |
106 TypeLengthSize, | 104 TypeLengthSize, |
107 TypeNeutral, | 105 TypeNeutral, |
108 TypeRepeatable, | 106 TypeRepeatable, |
109 TypeSVGLength, | 107 TypeSVGLength, |
110 TypeSVGPaint, | 108 TypeSVGPaint, |
111 TypeShadow, | 109 TypeShadow, |
112 TypeShapeValue, | 110 TypeShapeValue, |
113 TypeStrokeDasharrayList, | 111 TypeStrokeDasharrayList, |
114 TypeTransform, | 112 TypeTransform, |
115 TypeUnknown, | 113 TypeUnknown, |
116 TypeVisibility, | 114 TypeVisibility, |
117 }; | 115 }; |
118 | 116 |
119 virtual bool usesDefaultInterpolationWith(const AnimatableValue* value) cons
t { return false; } | 117 virtual bool usesDefaultInterpolationWith(const AnimatableValue* value) cons
t { return false; } |
120 virtual PassRefPtrWillBeRawPtr<AnimatableValue> interpolateTo(const Animatab
leValue*, double fraction) const = 0; | 118 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do
uble fraction) const = 0; |
121 static PassRefPtrWillBeRawPtr<AnimatableValue> defaultInterpolateTo(const An
imatableValue* left, const AnimatableValue* right, double fraction) { return tak
eConstRef((fraction < 0.5) ? left : right); } | 119 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu
e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f
raction < 0.5) ? left : right); } |
122 | 120 |
123 template <class T> | 121 template <class T> |
124 static PassRefPtrWillBeRawPtr<T> takeConstRef(const T* value) { return PassR
efPtrWillBeRawPtr<T>(const_cast<T*>(value)); } | 122 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con
st_cast<T*>(value)); } |
125 | 123 |
126 private: | 124 private: |
127 virtual AnimatableType type() const = 0; | 125 virtual AnimatableType type() const = 0; |
128 // Implementations can assume that the object being compared has the same ty
pe as the object this is called on | 126 // Implementations can assume that the object being compared has the same ty
pe as the object this is called on |
129 virtual bool equalTo(const AnimatableValue*) const = 0; | 127 virtual bool equalTo(const AnimatableValue*) const = 0; |
130 | 128 |
131 template <class Keyframe> friend class KeyframeEffectModel; | 129 template <class Keyframe> friend class KeyframeEffectModel; |
132 }; | 130 }; |
133 | 131 |
134 #define DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(thisType, predicate) \ | 132 #define DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(thisType, predicate) \ |
135 DEFINE_TYPE_CASTS(thisType, AnimatableValue, value, value->predicate, value.
predicate) | 133 DEFINE_TYPE_CASTS(thisType, AnimatableValue, value, value->predicate, value.
predicate) |
136 | 134 |
137 } // namespace blink | 135 } // namespace blink |
138 | 136 |
139 #endif // AnimatableValue_h | 137 #endif // AnimatableValue_h |
OLD | NEW |