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 23 matching lines...) Expand all Loading... |
34 #include "core/CSSValueKeywords.h" | 34 #include "core/CSSValueKeywords.h" |
35 #include "core/animation/animatable/AnimatableValue.h" | 35 #include "core/animation/animatable/AnimatableValue.h" |
36 #include "core/css/CSSIdentifierValue.h" | 36 #include "core/css/CSSIdentifierValue.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 class AnimatableUnknown final : public AnimatableValue { | 40 class AnimatableUnknown final : public AnimatableValue { |
41 public: | 41 public: |
42 ~AnimatableUnknown() override {} | 42 ~AnimatableUnknown() override {} |
43 | 43 |
44 static PassRefPtr<AnimatableUnknown> create(CSSValue* value) { | 44 static PassRefPtr<AnimatableUnknown> create(const CSSValue* value) { |
45 return adoptRef(new AnimatableUnknown(value)); | 45 return adoptRef(new AnimatableUnknown(value)); |
46 } | 46 } |
47 static PassRefPtr<AnimatableUnknown> create(CSSValueID value) { | 47 static PassRefPtr<AnimatableUnknown> create(CSSValueID value) { |
48 return adoptRef(new AnimatableUnknown(CSSIdentifierValue::create(value))); | 48 return adoptRef(new AnimatableUnknown(CSSIdentifierValue::create(value))); |
49 } | 49 } |
50 | 50 |
51 CSSValue* toCSSValue() const { return m_value; } | 51 const CSSValue* toCSSValue() const { return m_value; } |
52 CSSValueID toCSSValueID() const { | 52 CSSValueID toCSSValueID() const { |
53 return toCSSIdentifierValue(m_value.get())->getValueID(); | 53 return toCSSIdentifierValue(m_value.get())->getValueID(); |
54 } | 54 } |
55 | 55 |
56 protected: | 56 protected: |
57 PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue* value, | 57 PassRefPtr<AnimatableValue> interpolateTo(const AnimatableValue* value, |
58 double fraction) const override { | 58 double fraction) const override { |
59 return defaultInterpolateTo(this, value, fraction); | 59 return defaultInterpolateTo(this, value, fraction); |
60 } | 60 } |
61 | 61 |
62 bool usesDefaultInterpolationWith(const AnimatableValue*) const override; | 62 bool usesDefaultInterpolationWith(const AnimatableValue*) const override; |
63 | 63 |
64 private: | 64 private: |
65 explicit AnimatableUnknown(CSSValue* value) : m_value(value) { | 65 explicit AnimatableUnknown(const CSSValue* value) : m_value(value) {} |
66 DCHECK(m_value); | |
67 } | |
68 AnimatableType type() const override { return TypeUnknown; } | 66 AnimatableType type() const override { return TypeUnknown; } |
69 bool equalTo(const AnimatableValue*) const override; | 67 bool equalTo(const AnimatableValue*) const override; |
70 | 68 |
71 const Persistent<CSSValue> m_value; | 69 const Persistent<const CSSValue> m_value; |
72 }; | 70 }; |
73 | 71 |
74 DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(AnimatableUnknown, isUnknown()); | 72 DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(AnimatableUnknown, isUnknown()); |
75 | 73 |
76 inline bool AnimatableUnknown::equalTo(const AnimatableValue* value) const { | 74 inline bool AnimatableUnknown::equalTo(const AnimatableValue* value) const { |
77 const AnimatableUnknown* unknown = toAnimatableUnknown(value); | 75 const AnimatableUnknown* unknown = toAnimatableUnknown(value); |
78 return dataEquivalent(m_value, unknown->m_value); | 76 return dataEquivalent(m_value, unknown->m_value); |
79 } | 77 } |
80 | 78 |
81 inline bool AnimatableUnknown::usesDefaultInterpolationWith( | 79 inline bool AnimatableUnknown::usesDefaultInterpolationWith( |
82 const AnimatableValue* value) const { | 80 const AnimatableValue* value) const { |
83 return !equalTo(value); | 81 return !equalTo(value); |
84 } | 82 } |
85 | 83 |
86 } // namespace blink | 84 } // namespace blink |
87 | 85 |
88 #endif // AnimatableUnknown_h | 86 #endif // AnimatableUnknown_h |
OLD | NEW |