| 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 class AnimatableValue : public RefCounted<AnimatableValue> { | 41 class AnimatableValue : public RefCounted<AnimatableValue> { |
| 42 public: | 42 public: |
| 43 virtual ~AnimatableValue() { } | 43 virtual ~AnimatableValue() { } |
| 44 static PassRefPtr<AnimatableValue> create(CSSValue*); | 44 static PassRefPtr<AnimatableValue> create(CSSValue*); |
| 45 virtual PassRefPtr<CSSValue> toCSSValue() const = 0; | 45 virtual PassRefPtr<CSSValue> toCSSValue() const = 0; |
| 46 | 46 |
| 47 static const AnimatableValue* neutralValue(); | 47 static const AnimatableValue* neutralValue(); |
| 48 virtual bool isNeutral() const { return false; } | 48 virtual bool isNeutral() const { return false; } |
| 49 | 49 |
| 50 static const AnimatableValue* deferredSnapshotValue(); |
| 51 virtual bool isDeferredSnapshot() const { return false; } |
| 52 |
| 50 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, const
AnimatableValue*, double fraction); | 53 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, const
AnimatableValue*, double fraction); |
| 51 // For noncommutative values read add(A, B) to mean the value A with B compo
sed onto it. | 54 // For noncommutative values read add(A, B) to mean the value A with B compo
sed onto it. |
| 52 static PassRefPtr<AnimatableValue> add(const AnimatableValue*, const Animata
bleValue*); | 55 static PassRefPtr<AnimatableValue> add(const AnimatableValue*, const Animata
bleValue*); |
| 53 | 56 |
| 54 protected: | 57 protected: |
| 55 enum AnimatableType { | 58 enum AnimatableType { |
| 59 TypeDeferredSnapshot, |
| 56 TypeNeutral, | 60 TypeNeutral, |
| 57 TypeNumber, | 61 TypeNumber, |
| 58 TypeUnknown, | 62 TypeUnknown, |
| 59 }; | 63 }; |
| 60 | 64 |
| 61 AnimatableValue(AnimatableType type) : m_type(type) { } | 65 AnimatableValue(AnimatableType type) : m_type(type) { } |
| 62 | 66 |
| 63 bool isSameType(const AnimatableValue* value) const | 67 bool isSameType(const AnimatableValue* value) const |
| 64 { | 68 { |
| 65 ASSERT(value); | 69 ASSERT(value); |
| 66 return value->m_type == m_type; | 70 return value->m_type == m_type; |
| 67 } | 71 } |
| 68 | 72 |
| 69 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do
uble fraction) const = 0; | 73 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do
uble fraction) const = 0; |
| 70 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu
e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f
raction < 0.5) ? left : right); } | 74 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu
e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f
raction < 0.5) ? left : right); } |
| 71 | 75 |
| 72 // For noncommutative values read A->addWith(B) to mean the value A with B c
omposed onto it. | 76 // For noncommutative values read A->addWith(B) to mean the value A with B c
omposed onto it. |
| 73 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const =
0; | 77 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const =
0; |
| 74 static PassRefPtr<AnimatableValue> defaultAddWith(const AnimatableValue* lef
t, const AnimatableValue* right) { return takeConstRef(right); } | 78 static PassRefPtr<AnimatableValue> defaultAddWith(const AnimatableValue* lef
t, const AnimatableValue* right) { return takeConstRef(right); } |
| 75 | 79 |
| 76 template <class T> | 80 template <class T> |
| 77 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con
st_cast<T*>(value)); } | 81 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con
st_cast<T*>(value)); } |
| 78 | 82 |
| 79 AnimatableType m_type; | 83 AnimatableType m_type; |
| 80 }; | 84 }; |
| 81 | 85 |
| 82 } // namespace WebCore | 86 } // namespace WebCore |
| 83 | 87 |
| 84 #endif // AnimatableValue_h | 88 #endif // AnimatableValue_h |
| OLD | NEW |