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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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/animation/AnimationEffect.h" |
34 #include "core/css/CSSValue.h" | 35 #include "core/css/CSSValue.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 AnimationEffect::CompositableValue { |
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 PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, 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 PassRefPtr<AnimatableValue> add(const AnimatableValue*, const Animata
bleValue*); |
48 static bool usesDefaultInterpolation(const AnimatableValue* from, const Anim
atableValue* to) | 49 static bool usesDefaultInterpolation(const AnimatableValue* from, const Anim
atableValue* to) |
49 { | 50 { |
50 return !from->isSameType(to) || from->usesDefaultInterpolationWith(to); | 51 return !from->isSameType(to) || from->usesDefaultInterpolationWith(to); |
51 } | 52 } |
52 | 53 |
53 bool equals(const AnimatableValue* value) const | 54 bool equals(const AnimatableValue* value) const |
54 { | 55 { |
55 return isSameType(value) && equalTo(value); | 56 return isSameType(value) && equalTo(value); |
56 } | 57 } |
57 bool equals(const AnimatableValue& value) const | 58 bool equals(const AnimatableValue& value) const |
58 { | 59 { |
59 return equals(&value); | 60 return equals(&value); |
60 } | 61 } |
61 | 62 |
| 63 virtual bool dependsOnUnderlyingValue() const OVERRIDE FINAL { return false;
} |
| 64 virtual PassRefPtr<AnimatableValue> compositeOnto(const AnimatableValue*) co
nst OVERRIDE FINAL { return takeConstRef(this); } |
| 65 virtual bool isAnimatableValue() const { return true; } |
| 66 |
62 bool isClipPathOperation() const { return type() == TypeClipPathOperation; } | 67 bool isClipPathOperation() const { return type() == TypeClipPathOperation; } |
63 bool isColor() const { return type() == TypeColor; } | 68 bool isColor() const { return type() == TypeColor; } |
64 bool isDouble() const { return type() == TypeDouble; } | 69 bool isDouble() const { return type() == TypeDouble; } |
65 bool isFilterOperations() const { return type() == TypeFilterOperations; } | 70 bool isFilterOperations() const { return type() == TypeFilterOperations; } |
66 bool isImage() const { return type() == TypeImage; } | 71 bool isImage() const { return type() == TypeImage; } |
67 bool isLength() const { return type() == TypeLength; } | 72 bool isLength() const { return type() == TypeLength; } |
68 bool isLengthBox() const { return type() == TypeLengthBox; } | 73 bool isLengthBox() const { return type() == TypeLengthBox; } |
69 bool isLengthBoxAndBool() const { return type() == TypeLengthBoxAndBool; } | 74 bool isLengthBoxAndBool() const { return type() == TypeLengthBoxAndBool; } |
70 bool isLengthPoint() const { return type() == TypeLengthPoint; } | 75 bool isLengthPoint() const { return type() == TypeLengthPoint; } |
71 bool isLengthSize() const { return type() == TypeLengthSize; } | 76 bool isLengthSize() const { return type() == TypeLengthSize; } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 125 |
121 | 126 |
122 | 127 |
123 template <class T> | 128 template <class T> |
124 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con
st_cast<T*>(value)); } | 129 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con
st_cast<T*>(value)); } |
125 | 130 |
126 private: | 131 private: |
127 virtual AnimatableType type() const = 0; | 132 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 | 133 // 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; | 134 virtual bool equalTo(const AnimatableValue*) const = 0; |
| 135 |
| 136 friend class KeyframeEffectModel; |
130 }; | 137 }; |
131 | 138 |
132 #define DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(thisType, predicate) \ | 139 #define DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(thisType, predicate) \ |
133 DEFINE_TYPE_CASTS(thisType, AnimatableValue, value, value->predicate, value.
predicate) | 140 DEFINE_TYPE_CASTS(thisType, AnimatableValue, value, value->predicate, value.
predicate) |
134 | 141 |
| 142 DEFINE_TYPE_CASTS(AnimatableValue, AnimationEffect::CompositableValue, value, va
lue->isAnimatableValue(), value.isAnimatableValue()); |
| 143 |
135 } // namespace WebCore | 144 } // namespace WebCore |
136 | 145 |
137 #endif // AnimatableValue_h | 146 #endif // AnimatableValue_h |
OLD | NEW |