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