| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef InterpolableValue_h | 5 #ifndef InterpolableValue_h |
| 6 #define InterpolableValue_h | 6 #define InterpolableValue_h |
| 7 | 7 |
| 8 #include "core/animation/animatable/AnimatableValue.h" | 8 #include "core/animation/animatable/AnimatableValue.h" |
| 9 #include "platform/heap/Handle.h" |
| 9 #include "wtf/OwnPtr.h" | 10 #include "wtf/OwnPtr.h" |
| 10 #include "wtf/PassOwnPtr.h" | 11 #include "wtf/PassOwnPtr.h" |
| 11 #include "wtf/Vector.h" | 12 #include "wtf/Vector.h" |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 class InterpolableValue : public NoBaseWillBeGarbageCollected<InterpolableValue>
{ | 16 class InterpolableValue : public NoBaseWillBeGarbageCollected<InterpolableValue>
{ |
| 16 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue); | 17 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(InterpolableValue); |
| 17 public: | 18 public: |
| 18 virtual bool isNumber() const { return false; } | 19 virtual bool isNumber() const { return false; } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 friend class Interpolation; | 31 friend class Interpolation; |
| 31 | 32 |
| 32 // Keep interpolate private, but allow calls within the hierarchy without | 33 // Keep interpolate private, but allow calls within the hierarchy without |
| 33 // knowledge of type. | 34 // knowledge of type. |
| 34 friend class DeferredLegacyStyleInterpolation; | 35 friend class DeferredLegacyStyleInterpolation; |
| 35 friend class InterpolableNumber; | 36 friend class InterpolableNumber; |
| 36 friend class InterpolableBool; | 37 friend class InterpolableBool; |
| 37 friend class InterpolableList; | 38 friend class InterpolableList; |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 class InterpolableNumber : public InterpolableValue { | 41 WILL_BE_EAGERLY_TRACED(InterpolableValue); |
| 42 |
| 43 class InterpolableNumber final : public InterpolableValue { |
| 41 public: | 44 public: |
| 42 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value) | 45 static PassOwnPtrWillBeRawPtr<InterpolableNumber> create(double value) |
| 43 { | 46 { |
| 44 return adoptPtrWillBeNoop(new InterpolableNumber(value)); | 47 return adoptPtrWillBeNoop(new InterpolableNumber(value)); |
| 45 } | 48 } |
| 46 | 49 |
| 47 virtual bool isNumber() const override final { return true; } | 50 virtual bool isNumber() const override final { return true; } |
| 48 double value() const { return m_value; } | 51 double value() const { return m_value; } |
| 49 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(m_value); } | 52 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(m_value); } |
| 50 | 53 |
| 51 virtual void trace(Visitor* visitor) override { InterpolableValue::trace(vis
itor); } | |
| 52 | |
| 53 private: | 54 private: |
| 54 virtual void interpolate(const InterpolableValue& to, const double progress,
InterpolableValue& result) const override final; | 55 virtual void interpolate(const InterpolableValue& to, const double progress,
InterpolableValue& result) const override final; |
| 55 double m_value; | 56 double m_value; |
| 56 | 57 |
| 57 explicit InterpolableNumber(double value) | 58 explicit InterpolableNumber(double value) |
| 58 : m_value(value) | 59 : m_value(value) |
| 59 { | 60 { |
| 60 } | 61 } |
| 61 | 62 |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 class InterpolableBool : public InterpolableValue { | 65 class InterpolableBool final : public InterpolableValue { |
| 65 public: | 66 public: |
| 66 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value) | 67 static PassOwnPtrWillBeRawPtr<InterpolableBool> create(bool value) |
| 67 { | 68 { |
| 68 return adoptPtrWillBeNoop(new InterpolableBool(value)); | 69 return adoptPtrWillBeNoop(new InterpolableBool(value)); |
| 69 } | 70 } |
| 70 | 71 |
| 71 virtual bool isBool() const override final { return true; } | 72 virtual bool isBool() const override final { return true; } |
| 72 bool value() const { return m_value; } | 73 bool value() const { return m_value; } |
| 73 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(m_value); } | 74 virtual PassOwnPtrWillBeRawPtr<InterpolableValue> clone() const override fin
al { return create(m_value); } |
| 74 | 75 |
| 75 virtual void trace(Visitor* visitor) override { InterpolableValue::trace(vis
itor); } | |
| 76 | |
| 77 private: | 76 private: |
| 78 virtual void interpolate(const InterpolableValue& to, const double progress,
InterpolableValue& result) const override final; | 77 virtual void interpolate(const InterpolableValue& to, const double progress,
InterpolableValue& result) const override final; |
| 79 bool m_value; | 78 bool m_value; |
| 80 | 79 |
| 81 explicit InterpolableBool(bool value) | 80 explicit InterpolableBool(bool value) |
| 82 : m_value(value) | 81 : m_value(value) |
| 83 { | 82 { |
| 84 } | 83 } |
| 85 | 84 |
| 86 }; | 85 }; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 }; | 157 }; |
| 159 | 158 |
| 160 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber(
), value.isNumber()); | 159 DEFINE_TYPE_CASTS(InterpolableNumber, InterpolableValue, value, value->isNumber(
), value.isNumber()); |
| 161 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v
alue.isBool()); | 160 DEFINE_TYPE_CASTS(InterpolableBool, InterpolableValue, value, value->isBool(), v
alue.isBool()); |
| 162 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v
alue.isList()); | 161 DEFINE_TYPE_CASTS(InterpolableList, InterpolableValue, value, value->isList(), v
alue.isList()); |
| 163 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value->
isAnimatableValue(), value.isAnimatableValue()); | 162 DEFINE_TYPE_CASTS(InterpolableAnimatableValue, InterpolableValue, value, value->
isAnimatableValue(), value.isAnimatableValue()); |
| 164 | 163 |
| 165 } | 164 } |
| 166 | 165 |
| 167 #endif | 166 #endif |
| OLD | NEW |