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