| 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 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef AnimatableValue_h | 31 #ifndef AnimatableValue_h |
| 32 #define AnimatableValue_h | 32 #define AnimatableValue_h |
| 33 | 33 |
| 34 #include "core/css/CSSValue.h" | 34 #include "core/css/CSSValue.h" |
| 35 #include "heap/Handle.h" |
| 35 #include "wtf/RefCounted.h" | 36 #include "wtf/RefCounted.h" |
| 36 | 37 |
| 37 namespace WebCore { | 38 namespace WebCore { |
| 38 | 39 |
| 39 class AnimatableValue : public RefCounted<AnimatableValue> { | 40 class AnimatableValue : public RefCountedWillBeGarbageCollectedFinalized<Animata
bleValue> { |
| 40 public: | 41 public: |
| 41 virtual ~AnimatableValue() { } | 42 virtual ~AnimatableValue() { } |
| 42 | 43 |
| 43 static const AnimatableValue* neutralValue(); | 44 static const AnimatableValue* neutralValue(); |
| 44 | 45 |
| 45 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, const
AnimatableValue*, double fraction); | 46 static PassRefPtrWillBeRawPtr<AnimatableValue> interpolate(const AnimatableV
alue*, const AnimatableValue*, double fraction); |
| 46 // For noncommutative values read add(A, B) to mean the value A with B compo
sed onto it. | 47 // For noncommutative values read add(A, B) to mean the value A with B compo
sed onto it. |
| 47 static PassRefPtr<AnimatableValue> add(const AnimatableValue*, const Animata
bleValue*); | 48 static PassRefPtrWillBeRawPtr<AnimatableValue> add(const AnimatableValue*, c
onst AnimatableValue*); |
| 48 static double distance(const AnimatableValue* from, const AnimatableValue* t
o); | 49 static double distance(const AnimatableValue* from, const AnimatableValue* t
o); |
| 49 static bool usesDefaultInterpolation(const AnimatableValue* from, const Anim
atableValue* to) | 50 static bool usesDefaultInterpolation(const AnimatableValue* from, const Anim
atableValue* to) |
| 50 { | 51 { |
| 51 return !from->isSameType(to) || from->usesDefaultInterpolationWith(to); | 52 return !from->isSameType(to) || from->usesDefaultInterpolationWith(to); |
| 52 } | 53 } |
| 53 | 54 |
| 54 bool equals(const AnimatableValue* value) const | 55 bool equals(const AnimatableValue* value) const |
| 55 { | 56 { |
| 56 return isSameType(value) && equalTo(value); | 57 return isSameType(value) && equalTo(value); |
| 57 } | 58 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 80 bool isTransform() const { return type() == TypeTransform; } | 81 bool isTransform() const { return type() == TypeTransform; } |
| 81 bool isUnknown() const { return type() == TypeUnknown; } | 82 bool isUnknown() const { return type() == TypeUnknown; } |
| 82 bool isVisibility() const { return type() == TypeVisibility; } | 83 bool isVisibility() const { return type() == TypeVisibility; } |
| 83 | 84 |
| 84 bool isSameType(const AnimatableValue* value) const | 85 bool isSameType(const AnimatableValue* value) const |
| 85 { | 86 { |
| 86 ASSERT(value); | 87 ASSERT(value); |
| 87 return value->type() == type(); | 88 return value->type() == type(); |
| 88 } | 89 } |
| 89 | 90 |
| 91 virtual void trace(Visitor*) { } |
| 92 |
| 90 protected: | 93 protected: |
| 91 enum AnimatableType { | 94 enum AnimatableType { |
| 92 TypeClipPathOperation, | 95 TypeClipPathOperation, |
| 93 TypeColor, | 96 TypeColor, |
| 94 TypeDouble, | 97 TypeDouble, |
| 95 TypeFilterOperations, | 98 TypeFilterOperations, |
| 96 TypeImage, | 99 TypeImage, |
| 97 TypeLength, | 100 TypeLength, |
| 98 TypeLengthBox, | 101 TypeLengthBox, |
| 99 TypeLengthBoxAndBool, | 102 TypeLengthBoxAndBool, |
| 100 TypeLengthPoint, | 103 TypeLengthPoint, |
| 101 TypeLengthSize, | 104 TypeLengthSize, |
| 102 TypeNeutral, | 105 TypeNeutral, |
| 103 TypeRepeatable, | 106 TypeRepeatable, |
| 104 TypeSVGLength, | 107 TypeSVGLength, |
| 105 TypeSVGPaint, | 108 TypeSVGPaint, |
| 106 TypeShadow, | 109 TypeShadow, |
| 107 TypeShapeValue, | 110 TypeShapeValue, |
| 108 TypeStrokeDasharrayList, | 111 TypeStrokeDasharrayList, |
| 109 TypeTransform, | 112 TypeTransform, |
| 110 TypeUnknown, | 113 TypeUnknown, |
| 111 TypeVisibility, | 114 TypeVisibility, |
| 112 }; | 115 }; |
| 113 | 116 |
| 114 virtual bool usesDefaultInterpolationWith(const AnimatableValue* value) cons
t { return false; } | 117 virtual bool usesDefaultInterpolationWith(const AnimatableValue* value) cons
t { return false; } |
| 115 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do
uble fraction) const = 0; | 118 virtual PassRefPtrWillBeRawPtr<AnimatableValue> interpolateTo(const Animatab
leValue*, double fraction) const = 0; |
| 116 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu
e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f
raction < 0.5) ? left : right); } | 119 static PassRefPtrWillBeRawPtr<AnimatableValue> defaultInterpolateTo(const An
imatableValue* left, const AnimatableValue* right, double fraction) { return tak
eConstRef((fraction < 0.5) ? left : right); } |
| 117 | 120 |
| 118 // For noncommutative values read A->addWith(B) to mean the value A with B c
omposed onto it. | 121 // For noncommutative values read A->addWith(B) to mean the value A with B c
omposed onto it. |
| 119 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const; | 122 virtual PassRefPtrWillBeRawPtr<AnimatableValue> addWith(const AnimatableValu
e*) const; |
| 120 static PassRefPtr<AnimatableValue> defaultAddWith(const AnimatableValue* lef
t, const AnimatableValue* right) { return takeConstRef(right); } | 123 static PassRefPtrWillBeRawPtr<AnimatableValue> defaultAddWith(const Animatab
leValue* left, const AnimatableValue* right) { return takeConstRef(right); } |
| 121 | 124 |
| 122 | 125 |
| 123 | 126 |
| 124 template <class T> | 127 template <class T> |
| 125 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con
st_cast<T*>(value)); } | 128 static PassRefPtrWillBeRawPtr<T> takeConstRef(const T* value) { return PassR
efPtrWillBeRawPtr<T>(const_cast<T*>(value)); } |
| 126 | 129 |
| 127 private: | 130 private: |
| 128 virtual AnimatableType type() const = 0; | 131 virtual AnimatableType type() const = 0; |
| 129 // Implementations can assume that the object being compared has the same ty
pe as the object this is called on | 132 // Implementations can assume that the object being compared has the same ty
pe as the object this is called on |
| 130 virtual bool equalTo(const AnimatableValue*) const = 0; | 133 virtual bool equalTo(const AnimatableValue*) const = 0; |
| 131 | 134 |
| 132 virtual double distanceTo(const AnimatableValue*) const; | 135 virtual double distanceTo(const AnimatableValue*) const; |
| 133 | 136 |
| 134 friend class KeyframeEffectModel; | 137 friend class KeyframeEffectModel; |
| 135 }; | 138 }; |
| 136 | 139 |
| 137 #define DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(thisType, predicate) \ | 140 #define DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(thisType, predicate) \ |
| 138 DEFINE_TYPE_CASTS(thisType, AnimatableValue, value, value->predicate, value.
predicate) | 141 DEFINE_TYPE_CASTS(thisType, AnimatableValue, value, value->predicate, value.
predicate) |
| 139 | 142 |
| 140 } // namespace WebCore | 143 } // namespace WebCore |
| 141 | 144 |
| 142 #endif // AnimatableValue_h | 145 #endif // AnimatableValue_h |
| OLD | NEW |