| 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 LengthStyleInterpolation_h | 5 #ifndef LengthStyleInterpolation_h |
| 6 #define LengthStyleInterpolation_h | 6 #define LengthStyleInterpolation_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/animation/StyleInterpolation.h" | 9 #include "core/animation/StyleInterpolation.h" |
| 10 #include "core/css/CSSPrimitiveValue.h" | 10 #include "core/css/CSSPrimitiveValue.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class ComputedStyle; | 14 class ComputedStyle; |
| 15 class Length; | 15 class Length; |
| 16 | 16 |
| 17 class CORE_EXPORT LengthStyleInterpolation : public StyleInterpolation { | 17 class CORE_EXPORT LengthStyleInterpolation : public StyleInterpolation { |
| 18 public: | 18 public: |
| 19 typedef void (ComputedStyle::*LengthSetter)(const Length&); | |
| 20 typedef void NonInterpolableType; | 19 typedef void NonInterpolableType; |
| 21 | 20 |
| 22 static PassRefPtrWillBeRawPtr<LengthStyleInterpolation> create(const CSSValu
e& start, const CSSValue& end, CSSPropertyID id, InterpolationRange range) | 21 static PassRefPtrWillBeRawPtr<LengthStyleInterpolation> create(const CSSValu
e& start, const CSSValue& end, CSSPropertyID id, InterpolationRange range) |
| 23 { | 22 { |
| 24 return adoptRefWillBeNoop(new LengthStyleInterpolation(toInterpolableVal
ue(start, id), toInterpolableValue(end, id), id, range)); | 23 return adoptRefWillBeNoop(new LengthStyleInterpolation(toInterpolableVal
ue(start, id), toInterpolableValue(end, id), id, range)); |
| 25 } | 24 } |
| 26 | 25 |
| 27 static bool canCreateFrom(const CSSValue&, CSSPropertyID = CSSPropertyInvali
d); | 26 static bool canCreateFrom(const CSSValue&, CSSPropertyID = CSSPropertyInvali
d); |
| 28 | 27 |
| 29 void apply(StyleResolverState&) const override; | 28 void apply(StyleResolverState&) const override; |
| 30 | 29 |
| 31 DECLARE_VIRTUAL_TRACE(); | 30 DECLARE_VIRTUAL_TRACE(); |
| 32 | 31 |
| 33 static PassOwnPtrWillBeRawPtr<InterpolableValue> toInterpolableValue(const C
SSValue&, CSSPropertyID = CSSPropertyInvalid); | 32 static PassOwnPtrWillBeRawPtr<InterpolableValue> toInterpolableValue(const C
SSValue&, CSSPropertyID = CSSPropertyInvalid); |
| 34 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> fromInterpolableValue(const
InterpolableValue&, InterpolationRange); | 33 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> fromInterpolableValue(const
InterpolableValue&, InterpolationRange); |
| 35 static void applyInterpolableValue(CSSPropertyID, const InterpolableValue&,
InterpolationRange, StyleResolverState&, LengthSetter); | 34 static void applyInterpolableValue(CSSPropertyID, const InterpolableValue&,
InterpolationRange, StyleResolverState&); |
| 36 | 35 |
| 37 private: | 36 private: |
| 38 LengthStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa
ssOwnPtrWillBeRawPtr<InterpolableValue> end, CSSPropertyID id, InterpolationRang
e range) | 37 LengthStyleInterpolation(PassOwnPtrWillBeRawPtr<InterpolableValue> start, Pa
ssOwnPtrWillBeRawPtr<InterpolableValue> end, CSSPropertyID id, InterpolationRang
e range) |
| 39 : StyleInterpolation(start, end, id) | 38 : StyleInterpolation(start, end, id) |
| 40 , m_range(range) | 39 , m_range(range) |
| 41 , m_lengthSetter(nullptr) | |
| 42 { | 40 { |
| 43 if (isPixelsOrPercentOnly(*m_start) && isPixelsOrPercentOnly(*m_end)) | |
| 44 m_lengthSetter = lengthSetterForProperty(id); | |
| 45 } | 41 } |
| 46 | 42 |
| 47 static bool isPixelsOrPercentOnly(const InterpolableValue&); | |
| 48 static LengthSetter lengthSetterForProperty(CSSPropertyID); | |
| 49 | |
| 50 InterpolationRange m_range; | 43 InterpolationRange m_range; |
| 51 LengthSetter m_lengthSetter; | |
| 52 }; | 44 }; |
| 53 | 45 |
| 54 } | 46 } |
| 55 | 47 |
| 56 #endif | 48 #endif |
| OLD | NEW |