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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, const
AnimatableValue*, double fraction); | 45 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. | 46 // 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*); | 47 static PassRefPtr<AnimatableValue> add(const AnimatableValue*, const Animata
bleValue*); |
48 | 48 |
49 bool isColor() const { return type() == TypeColor; } | 49 bool isColor() const { return type() == TypeColor; } |
50 bool isImage() const { return type() == TypeImage; } | 50 bool isImage() const { return type() == TypeImage; } |
51 bool isLengthBox() const { return type() == TypeLengthBox; } | 51 bool isLengthBox() const { return type() == TypeLengthBox; } |
52 bool isLengthSize() const { return type() == TypeLengthSize; } | 52 bool isLengthSize() const { return type() == TypeLengthSize; } |
53 bool isNumber() const { return type() == TypeNumber; } | 53 bool isNumber() const { return type() == TypeNumber; } |
54 bool isNeutral() const { return type() == TypeNeutral; } | 54 bool isNeutral() const { return type() == TypeNeutral; } |
| 55 bool isSVGPaint() const { return type() == TypeSVGPaint; } |
55 bool isTransform() const { return type() == TypeTransform; } | 56 bool isTransform() const { return type() == TypeTransform; } |
56 bool isUnknown() const { return type() == TypeUnknown; } | 57 bool isUnknown() const { return type() == TypeUnknown; } |
57 bool isVisibility() const { return type() == TypeVisibility; } | 58 bool isVisibility() const { return type() == TypeVisibility; } |
58 | 59 |
59 protected: | 60 protected: |
60 enum AnimatableType { | 61 enum AnimatableType { |
61 TypeColor, | 62 TypeColor, |
62 TypeImage, | 63 TypeImage, |
63 TypeLengthBox, | 64 TypeLengthBox, |
64 TypeLengthSize, | 65 TypeLengthSize, |
65 TypeNeutral, | 66 TypeNeutral, |
66 TypeNumber, | 67 TypeNumber, |
| 68 TypeSVGPaint, |
67 TypeTransform, | 69 TypeTransform, |
68 TypeUnknown, | 70 TypeUnknown, |
69 TypeVisibility, | 71 TypeVisibility, |
70 }; | 72 }; |
71 | 73 |
72 bool isSameType(const AnimatableValue* value) const | 74 bool isSameType(const AnimatableValue* value) const |
73 { | 75 { |
74 ASSERT(value); | 76 ASSERT(value); |
75 return value->type() == type(); | 77 return value->type() == type(); |
76 } | 78 } |
77 | 79 |
78 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do
uble fraction) const = 0; | 80 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do
uble fraction) const = 0; |
79 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu
e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f
raction < 0.5) ? left : right); } | 81 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu
e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f
raction < 0.5) ? left : right); } |
80 | 82 |
81 // For noncommutative values read A->addWith(B) to mean the value A with B c
omposed onto it. | 83 // For noncommutative values read A->addWith(B) to mean the value A with B c
omposed onto it. |
82 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const; | 84 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const; |
83 static PassRefPtr<AnimatableValue> defaultAddWith(const AnimatableValue* lef
t, const AnimatableValue* right) { return takeConstRef(right); } | 85 static PassRefPtr<AnimatableValue> defaultAddWith(const AnimatableValue* lef
t, const AnimatableValue* right) { return takeConstRef(right); } |
84 | 86 |
85 template <class T> | 87 template <class T> |
86 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con
st_cast<T*>(value)); } | 88 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con
st_cast<T*>(value)); } |
87 | 89 |
88 private: | 90 private: |
89 virtual AnimatableType type() const = 0; | 91 virtual AnimatableType type() const = 0; |
90 }; | 92 }; |
91 | 93 |
92 } // namespace WebCore | 94 } // namespace WebCore |
93 | 95 |
94 #endif // AnimatableValue_h | 96 #endif // AnimatableValue_h |
OLD | NEW |