Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 class CSSValue; | 39 class CSSValue; |
| 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 | 44 |
| 45 static const AnimatableValue* neutralValue(); | 45 static const AnimatableValue* neutralValue(); |
| 46 | 46 |
| 47 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, const AnimatableValue*, double fraction); | 47 static PassRefPtr<AnimatableValue> interpolate(const AnimatableValue*, const AnimatableValue*, double fraction); |
| 48 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f raction < 0.5) ? left : right); } | |
| 48 // For noncommutative values read add(A, B) to mean the value A with B compo sed onto it. | 49 // For noncommutative values read add(A, B) to mean the value A with B compo sed onto it. |
| 49 static PassRefPtr<AnimatableValue> add(const AnimatableValue*, const Animata bleValue*); | 50 static PassRefPtr<AnimatableValue> add(const AnimatableValue*, const Animata bleValue*); |
| 51 static PassRefPtr<AnimatableValue> defaultAddWith(const AnimatableValue* lef t, const AnimatableValue* right) { return takeConstRef(right); } | |
|
alancutter (OOO until 2018)
2013/08/27 02:37:45
Is there a use for exposing these methods publicly
dstockwell
2013/08/27 05:02:02
This was for AnimatableList, I'll revert it.
| |
| 50 | 52 |
| 53 bool isImage() const { return m_type == TypeImage; } | |
| 54 bool isLengthBox() const { return m_type == TypeLengthBox; } | |
| 51 bool isNumber() const { return m_type == TypeNumber; } | 55 bool isNumber() const { return m_type == TypeNumber; } |
| 52 bool isNeutral() const { return m_type == TypeNeutral; } | 56 bool isNeutral() const { return m_type == TypeNeutral; } |
| 53 bool isTransform() const { return m_type == TypeTransform; } | 57 bool isTransform() const { return m_type == TypeTransform; } |
| 54 bool isUnknown() const { return m_type == TypeUnknown; } | 58 bool isUnknown() const { return m_type == TypeUnknown; } |
| 55 | 59 |
| 56 protected: | 60 protected: |
| 57 enum AnimatableType { | 61 enum AnimatableType { |
| 62 TypeImage, | |
| 63 TypeLengthBox, | |
| 58 TypeNeutral, | 64 TypeNeutral, |
| 59 TypeNumber, | 65 TypeNumber, |
| 60 TypeTransform, | 66 TypeTransform, |
| 61 TypeUnknown, | 67 TypeUnknown, |
| 62 }; | 68 }; |
| 63 | 69 |
| 64 AnimatableValue(AnimatableType type) : m_type(type) { } | 70 AnimatableValue(AnimatableType type) : m_type(type) { } |
| 65 | 71 |
| 66 bool isSameType(const AnimatableValue* value) const | 72 bool isSameType(const AnimatableValue* value) const |
| 67 { | 73 { |
| 68 ASSERT(value); | 74 ASSERT(value); |
| 69 return value->m_type == m_type; | 75 return value->m_type == m_type; |
| 70 } | 76 } |
| 71 | 77 |
| 72 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do uble fraction) const = 0; | 78 virtual PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue*, do uble fraction) const = 0; |
| 73 static PassRefPtr<AnimatableValue> defaultInterpolateTo(const AnimatableValu e* left, const AnimatableValue* right, double fraction) { return takeConstRef((f raction < 0.5) ? left : right); } | |
| 74 | 79 |
| 75 // For noncommutative values read A->addWith(B) to mean the value A with B c omposed onto it. | 80 // For noncommutative values read A->addWith(B) to mean the value A with B c omposed onto it. |
| 76 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const = 0; | 81 virtual PassRefPtr<AnimatableValue> addWith(const AnimatableValue*) const = 0; |
| 77 static PassRefPtr<AnimatableValue> defaultAddWith(const AnimatableValue* lef t, const AnimatableValue* right) { return takeConstRef(right); } | |
| 78 | 82 |
| 79 template <class T> | 83 template <class T> |
| 80 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con st_cast<T*>(value)); } | 84 static PassRefPtr<T> takeConstRef(const T* value) { return PassRefPtr<T>(con st_cast<T*>(value)); } |
| 81 | 85 |
| 82 const AnimatableType m_type; | 86 const AnimatableType m_type; |
| 83 }; | 87 }; |
| 84 | 88 |
| 85 } // namespace WebCore | 89 } // namespace WebCore |
| 86 | 90 |
| 87 #endif // AnimatableValue_h | 91 #endif // AnimatableValue_h |
| OLD | NEW |