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 24 matching lines...) Expand all Loading... |
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 RefCounted<AnimatableValue> { | 41 class CORE_EXPORT AnimatableValue : public RefCounted<AnimatableValue> { |
42 public: | 42 public: |
43 virtual ~AnimatableValue() {} | 43 virtual ~AnimatableValue() {} |
44 | 44 |
45 static PassRefPtr<AnimatableValue> neutralValue(); | |
46 | |
47 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, | 45 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, |
48 const AnimatableValue*, | 46 const AnimatableValue*, |
49 double fraction); | 47 double fraction); |
50 static bool usesDefaultInterpolation(const AnimatableValue* from, | 48 static bool usesDefaultInterpolation(const AnimatableValue* from, |
51 const AnimatableValue* to) { | 49 const AnimatableValue* to) { |
52 return !from->isSameType(to) || from->usesDefaultInterpolationWith(to); | 50 return !from->isSameType(to) || from->usesDefaultInterpolationWith(to); |
53 } | 51 } |
54 | 52 |
55 bool equals(const AnimatableValue* value) const { | 53 bool equals(const AnimatableValue* value) const { |
56 return isSameType(value) && equalTo(value); | 54 return isSameType(value) && equalTo(value); |
57 } | 55 } |
58 bool equals(const AnimatableValue& value) const { return equals(&value); } | 56 bool equals(const AnimatableValue& value) const { return equals(&value); } |
59 | 57 |
60 bool isClipPathOperation() const { return type() == TypeClipPathOperation; } | 58 bool isClipPathOperation() const { return type() == TypeClipPathOperation; } |
61 bool isColor() const { return type() == TypeColor; } | 59 bool isColor() const { return type() == TypeColor; } |
62 bool isDouble() const { return type() == TypeDouble; } | 60 bool isDouble() const { return type() == TypeDouble; } |
63 bool isDoubleAndBool() const { return type() == TypeDoubleAndBool; } | 61 bool isDoubleAndBool() const { return type() == TypeDoubleAndBool; } |
64 bool isFilterOperations() const { return type() == TypeFilterOperations; } | 62 bool isFilterOperations() const { return type() == TypeFilterOperations; } |
65 bool isImage() const { return type() == TypeImage; } | 63 bool isImage() const { return type() == TypeImage; } |
66 bool isLength() const { return type() == TypeLength; } | 64 bool isLength() const { return type() == TypeLength; } |
67 bool isLengthBox() const { return type() == TypeLengthBox; } | 65 bool isLengthBox() const { return type() == TypeLengthBox; } |
68 bool isLengthBoxAndBool() const { return type() == TypeLengthBoxAndBool; } | 66 bool isLengthBoxAndBool() const { return type() == TypeLengthBoxAndBool; } |
69 bool isLengthPoint() const { return type() == TypeLengthPoint; } | 67 bool isLengthPoint() const { return type() == TypeLengthPoint; } |
70 bool isLengthPoint3D() const { return type() == TypeLengthPoint3D; } | 68 bool isLengthPoint3D() const { return type() == TypeLengthPoint3D; } |
71 bool isLengthSize() const { return type() == TypeLengthSize; } | 69 bool isLengthSize() const { return type() == TypeLengthSize; } |
72 bool isNeutral() const { return type() == TypeNeutral; } | |
73 bool isPath() const { return type() == TypePath; } | 70 bool isPath() const { return type() == TypePath; } |
74 bool isRepeatable() const { return type() == TypeRepeatable; } | 71 bool isRepeatable() const { return type() == TypeRepeatable; } |
75 bool isSVGLength() const { return type() == TypeSVGLength; } | 72 bool isSVGLength() const { return type() == TypeSVGLength; } |
76 bool isSVGPaint() const { return type() == TypeSVGPaint; } | 73 bool isSVGPaint() const { return type() == TypeSVGPaint; } |
77 bool isShadow() const { return type() == TypeShadow; } | 74 bool isShadow() const { return type() == TypeShadow; } |
78 bool isShapeValue() const { return type() == TypeShapeValue; } | 75 bool isShapeValue() const { return type() == TypeShapeValue; } |
79 bool isStrokeDasharrayList() const { | 76 bool isStrokeDasharrayList() const { |
80 return type() == TypeStrokeDasharrayList; | 77 return type() == TypeStrokeDasharrayList; |
81 } | 78 } |
82 bool isTransform() const { return type() == TypeTransform; } | 79 bool isTransform() const { return type() == TypeTransform; } |
(...skipping 12 matching lines...) Expand all Loading... |
95 TypeDouble, | 92 TypeDouble, |
96 TypeDoubleAndBool, | 93 TypeDoubleAndBool, |
97 TypeFilterOperations, | 94 TypeFilterOperations, |
98 TypeImage, | 95 TypeImage, |
99 TypeLength, | 96 TypeLength, |
100 TypeLengthBox, | 97 TypeLengthBox, |
101 TypeLengthBoxAndBool, | 98 TypeLengthBoxAndBool, |
102 TypeLengthPoint, | 99 TypeLengthPoint, |
103 TypeLengthPoint3D, | 100 TypeLengthPoint3D, |
104 TypeLengthSize, | 101 TypeLengthSize, |
105 TypeNeutral, | |
106 TypePath, | 102 TypePath, |
107 TypeRepeatable, | 103 TypeRepeatable, |
108 TypeSVGLength, | 104 TypeSVGLength, |
109 TypeSVGPaint, | 105 TypeSVGPaint, |
110 TypeShadow, | 106 TypeShadow, |
111 TypeShapeValue, | 107 TypeShapeValue, |
112 TypeStrokeDasharrayList, | 108 TypeStrokeDasharrayList, |
113 TypeTransform, | 109 TypeTransform, |
114 TypeUnknown, | 110 TypeUnknown, |
115 TypeVisibility, | 111 TypeVisibility, |
116 }; | 112 }; |
117 | 113 |
118 virtual bool usesDefaultInterpolationWith( | 114 virtual bool usesDefaultInterpolationWith( |
119 const AnimatableValue* value) const { | 115 const AnimatableValue* value) const { |
| 116 NOTREACHED(); |
120 return false; | 117 return false; |
121 } | 118 } |
122 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, | 119 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, |
123 double fraction) const = 0; | 120 double fraction) const { |
| 121 NOTREACHED(); |
| 122 return nullptr; |
| 123 } |
124 static PassRefPtr<AnimatableValue> defaultInterpolateTo( | 124 static PassRefPtr<AnimatableValue> defaultInterpolateTo( |
125 const AnimatableValue* left, | 125 const AnimatableValue* left, |
126 const AnimatableValue* right, | 126 const AnimatableValue* right, |
127 double fraction) { | 127 double fraction) { |
128 return takeConstRef((fraction < 0.5) ? left : right); | 128 return takeConstRef((fraction < 0.5) ? left : right); |
129 } | 129 } |
130 | 130 |
131 template <class T> | 131 template <class T> |
132 static PassRefPtr<T> takeConstRef(const T* value) { | 132 static PassRefPtr<T> takeConstRef(const T* value) { |
133 return PassRefPtr<T>(const_cast<T*>(value)); | 133 return PassRefPtr<T>(const_cast<T*>(value)); |
134 } | 134 } |
135 | 135 |
136 private: | 136 private: |
137 virtual AnimatableType type() const = 0; | 137 virtual AnimatableType type() const = 0; |
138 // Implementations can assume that the object being compared has the same type | 138 // Implementations can assume that the object being compared has the same type |
139 // as the object this is called on | 139 // as the object this is called on |
140 virtual bool equalTo(const AnimatableValue*) const = 0; | 140 virtual bool equalTo(const AnimatableValue*) const = 0; |
141 | 141 |
142 template <class Keyframe> | 142 template <class Keyframe> |
143 friend class KeyframeEffectModel; | 143 friend class KeyframeEffectModel; |
144 }; | 144 }; |
145 | 145 |
146 #define DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(thisType, predicate) \ | 146 #define DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(thisType, predicate) \ |
147 DEFINE_TYPE_CASTS(thisType, AnimatableValue, value, value->predicate, \ | 147 DEFINE_TYPE_CASTS(thisType, AnimatableValue, value, value->predicate, \ |
148 value.predicate) | 148 value.predicate) |
149 | 149 |
150 } // namespace blink | 150 } // namespace blink |
151 | 151 |
152 #endif // AnimatableValue_h | 152 #endif // AnimatableValue_h |
OLD | NEW |