OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "core/animation/CSSNumberInterpolationType.h" | 5 #include "core/animation/CSSNumberInterpolationType.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/animation/NumberPropertyFunctions.h" | 8 #include "core/animation/NumberPropertyFunctions.h" |
9 #include "core/css/resolver/StyleBuilder.h" | 9 #include "core/css/resolver/StyleBuilder.h" |
10 #include "core/css/resolver/StyleResolverState.h" | 10 #include "core/css/resolver/StyleResolverState.h" |
11 #include "platform/wtf/PtrUtil.h" | 11 #include "platform/wtf/PtrUtil.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class InheritedNumberChecker : public InterpolationType::ConversionChecker { | 15 class InheritedNumberChecker |
| 16 : public CSSInterpolationType::CSSConversionChecker { |
16 public: | 17 public: |
17 static std::unique_ptr<InheritedNumberChecker> Create(CSSPropertyID property, | 18 static std::unique_ptr<InheritedNumberChecker> Create(CSSPropertyID property, |
18 double number) { | 19 double number) { |
19 return WTF::WrapUnique(new InheritedNumberChecker(property, number)); | 20 return WTF::WrapUnique(new InheritedNumberChecker(property, number)); |
20 } | 21 } |
21 | 22 |
22 private: | 23 private: |
23 InheritedNumberChecker(CSSPropertyID property, double number) | 24 InheritedNumberChecker(CSSPropertyID property, double number) |
24 : property_(property), number_(number) {} | 25 : property_(property), number_(number) {} |
25 | 26 |
26 bool IsValid(const InterpolationEnvironment& environment, | 27 bool IsValid(const StyleResolverState& state, |
27 const InterpolationValue& underlying) const final { | 28 const InterpolationValue& underlying) const final { |
28 double parent_number; | 29 double parent_number; |
29 if (!NumberPropertyFunctions::GetNumber( | 30 if (!NumberPropertyFunctions::GetNumber(property_, *state.ParentStyle(), |
30 property_, *environment.GetState().ParentStyle(), parent_number)) | 31 parent_number)) |
31 return false; | 32 return false; |
32 return parent_number == number_; | 33 return parent_number == number_; |
33 } | 34 } |
34 | 35 |
35 const CSSPropertyID property_; | 36 const CSSPropertyID property_; |
36 const double number_; | 37 const double number_; |
37 }; | 38 }; |
38 | 39 |
39 const CSSValue* CSSNumberInterpolationType::CreateCSSValue( | 40 const CSSValue* CSSNumberInterpolationType::CreateCSSValue( |
40 const InterpolableValue& value, | 41 const InterpolableValue& value, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 CssProperty(), ToInterpolableNumber(interpolable_value).Value()); | 106 CssProperty(), ToInterpolableNumber(interpolable_value).Value()); |
106 if (!NumberPropertyFunctions::SetNumber(CssProperty(), *state.Style(), | 107 if (!NumberPropertyFunctions::SetNumber(CssProperty(), *state.Style(), |
107 clamped_number)) | 108 clamped_number)) |
108 StyleBuilder::ApplyProperty( | 109 StyleBuilder::ApplyProperty( |
109 CssProperty(), state, | 110 CssProperty(), state, |
110 *CSSPrimitiveValue::Create(clamped_number, | 111 *CSSPrimitiveValue::Create(clamped_number, |
111 CSSPrimitiveValue::UnitType::kNumber)); | 112 CSSPrimitiveValue::UnitType::kNumber)); |
112 } | 113 } |
113 | 114 |
114 } // namespace blink | 115 } // namespace blink |
OLD | NEW |