| 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 StyleInterpolation_h | 5 #ifndef StyleInterpolation_h |
| 6 #define StyleInterpolation_h | 6 #define StyleInterpolation_h |
| 7 | 7 |
| 8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
| 9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
| 10 #include "core/animation/Interpolation.h" | 10 #include "core/animation/Interpolation.h" |
| 11 #include "core/animation/PropertyHandle.h" | 11 #include "core/animation/PropertyHandle.h" |
| 12 #include <memory> | 12 #include <memory> |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class StyleResolverState; | 16 class StyleResolverState; |
| 17 | 17 |
| 18 enum InterpolationRange { | |
| 19 RangeAll, | |
| 20 RangeFloor, | |
| 21 RangeGreaterThanOrEqualToOne, | |
| 22 RangeNonNegative, | |
| 23 RangeRound, | |
| 24 RangeRoundGreaterThanOrEqualToOne, | |
| 25 RangeOpacityFIXME, | |
| 26 RangeZeroToOne | |
| 27 }; | |
| 28 | |
| 29 class CORE_EXPORT StyleInterpolation : public Interpolation { | 18 class CORE_EXPORT StyleInterpolation : public Interpolation { |
| 30 public: | 19 public: |
| 31 // 1) convert m_cachedValue into an X | 20 // 1) convert m_cachedValue into an X |
| 32 // 2) shove X into StyleResolverState | 21 // 2) shove X into StyleResolverState |
| 33 // X can be: | 22 // X can be: |
| 34 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) | 23 // (1) a CSSValue (and applied via StyleBuilder::applyProperty) |
| 35 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro
perty) | 24 // (2) an AnimatableValue (and applied via // AnimatedStyleBuilder::applyPro
perty) |
| 36 // (3) a custom value that is inserted directly into the StyleResolverState. | 25 // (3) a custom value that is inserted directly into the StyleResolverState. |
| 37 virtual void apply(StyleResolverState&) const = 0; | 26 virtual void apply(StyleResolverState&) const = 0; |
| 38 | 27 |
| 39 bool isStyleInterpolation() const final { return true; } | 28 bool isStyleInterpolation() const final { return true; } |
| 40 | 29 |
| 41 CSSPropertyID id() const { return m_id; } | 30 CSSPropertyID id() const { return m_id; } |
| 42 | 31 |
| 43 PropertyHandle getProperty() const final | 32 PropertyHandle getProperty() const final |
| 44 { | 33 { |
| 45 return PropertyHandle(id()); | 34 return PropertyHandle(id()); |
| 46 } | 35 } |
| 47 | 36 |
| 48 protected: | 37 protected: |
| 49 CSSPropertyID m_id; | 38 StyleInterpolation(std::unique_ptr<InterpolableValue> start, std::unique_ptr
<InterpolableValue> end, CSSPropertyID); |
| 50 | 39 |
| 51 StyleInterpolation(std::unique_ptr<InterpolableValue> start, std::unique_ptr
<InterpolableValue> end, CSSPropertyID id) | 40 void interpolateImpl() final; |
| 52 : Interpolation(std::move(start), std::move(end)) | 41 |
| 53 , m_id(id) | 42 const std::unique_ptr<InterpolableValue> m_start; |
| 54 { | 43 const std::unique_ptr<InterpolableValue> m_end; |
| 55 } | 44 const CSSPropertyID m_id; |
| 45 |
| 46 mutable std::unique_ptr<InterpolableValue> m_cachedValue; |
| 47 |
| 48 private: |
| 49 InterpolableValue* getCachedValueForTesting() const { return m_cachedValue.g
et(); } |
| 50 |
| 51 friend class AnimationInterpolableValueTest; |
| 52 friend class AnimationInterpolationEffectTest; |
| 56 }; | 53 }; |
| 57 | 54 |
| 58 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp
olation(), value.isStyleInterpolation()); | 55 DEFINE_TYPE_CASTS(StyleInterpolation, Interpolation, value, value->isStyleInterp
olation(), value.isStyleInterpolation()); |
| 59 | 56 |
| 60 } // namespace blink | 57 } // namespace blink |
| 61 | 58 |
| 62 #endif | 59 #endif |
| OLD | NEW |