OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/CSSBasicShapeInterpolationType.h" | 5 #include "core/animation/CSSBasicShapeInterpolationType.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/animation/BasicShapeInterpolationFunctions.h" | 8 #include "core/animation/BasicShapeInterpolationFunctions.h" |
9 #include "core/animation/BasicShapePropertyFunctions.h" | 9 #include "core/animation/BasicShapePropertyFunctions.h" |
10 #include "core/css/CSSValueList.h" | 10 #include "core/css/CSSValueList.h" |
11 #include "core/css/resolver/StyleResolverState.h" | 11 #include "core/css/resolver/StyleResolverState.h" |
12 #include "core/style/BasicShapes.h" | 12 #include "core/style/BasicShapes.h" |
13 #include "core/style/DataEquivalency.h" | 13 #include "core/style/DataEquivalency.h" |
14 #include "platform/wtf/PtrUtil.h" | 14 #include "platform/wtf/PtrUtil.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 class UnderlyingCompatibilityChecker | 20 class UnderlyingCompatibilityChecker |
21 : public InterpolationType::ConversionChecker { | 21 : public CSSInterpolationType::CSSConversionChecker { |
22 public: | 22 public: |
23 static std::unique_ptr<UnderlyingCompatibilityChecker> Create( | 23 static std::unique_ptr<UnderlyingCompatibilityChecker> Create( |
24 PassRefPtr<NonInterpolableValue> underlying_non_interpolable_value) { | 24 PassRefPtr<NonInterpolableValue> underlying_non_interpolable_value) { |
25 return WTF::WrapUnique(new UnderlyingCompatibilityChecker( | 25 return WTF::WrapUnique(new UnderlyingCompatibilityChecker( |
26 std::move(underlying_non_interpolable_value))); | 26 std::move(underlying_non_interpolable_value))); |
27 } | 27 } |
28 | 28 |
29 private: | 29 private: |
30 UnderlyingCompatibilityChecker( | 30 UnderlyingCompatibilityChecker( |
31 PassRefPtr<NonInterpolableValue> underlying_non_interpolable_value) | 31 PassRefPtr<NonInterpolableValue> underlying_non_interpolable_value) |
32 : underlying_non_interpolable_value_( | 32 : underlying_non_interpolable_value_( |
33 std::move(underlying_non_interpolable_value)) {} | 33 std::move(underlying_non_interpolable_value)) {} |
34 | 34 |
35 bool IsValid(const InterpolationEnvironment&, | 35 bool IsValid(const StyleResolverState&, |
36 const InterpolationValue& underlying) const final { | 36 const InterpolationValue& underlying) const final { |
37 return BasicShapeInterpolationFunctions::ShapesAreCompatible( | 37 return BasicShapeInterpolationFunctions::ShapesAreCompatible( |
38 *underlying_non_interpolable_value_, | 38 *underlying_non_interpolable_value_, |
39 *underlying.non_interpolable_value); | 39 *underlying.non_interpolable_value); |
40 } | 40 } |
41 | 41 |
42 RefPtr<NonInterpolableValue> underlying_non_interpolable_value_; | 42 RefPtr<NonInterpolableValue> underlying_non_interpolable_value_; |
43 }; | 43 }; |
44 | 44 |
45 class InheritedShapeChecker : public InterpolationType::ConversionChecker { | 45 class InheritedShapeChecker |
| 46 : public CSSInterpolationType::CSSConversionChecker { |
46 public: | 47 public: |
47 static std::unique_ptr<InheritedShapeChecker> Create( | 48 static std::unique_ptr<InheritedShapeChecker> Create( |
48 CSSPropertyID property, | 49 CSSPropertyID property, |
49 PassRefPtr<BasicShape> inherited_shape) { | 50 PassRefPtr<BasicShape> inherited_shape) { |
50 return WTF::WrapUnique( | 51 return WTF::WrapUnique( |
51 new InheritedShapeChecker(property, std::move(inherited_shape))); | 52 new InheritedShapeChecker(property, std::move(inherited_shape))); |
52 } | 53 } |
53 | 54 |
54 private: | 55 private: |
55 InheritedShapeChecker(CSSPropertyID property, | 56 InheritedShapeChecker(CSSPropertyID property, |
56 PassRefPtr<BasicShape> inherited_shape) | 57 PassRefPtr<BasicShape> inherited_shape) |
57 : property_(property), inherited_shape_(std::move(inherited_shape)) {} | 58 : property_(property), inherited_shape_(std::move(inherited_shape)) {} |
58 | 59 |
59 bool IsValid(const InterpolationEnvironment& environment, | 60 bool IsValid(const StyleResolverState& state, |
60 const InterpolationValue&) const final { | 61 const InterpolationValue&) const final { |
61 return DataEquivalent( | 62 return DataEquivalent(inherited_shape_.Get(), |
62 inherited_shape_.Get(), | 63 BasicShapePropertyFunctions::GetBasicShape( |
63 BasicShapePropertyFunctions::GetBasicShape( | 64 property_, *state.ParentStyle())); |
64 property_, *environment.GetState().ParentStyle())); | |
65 } | 65 } |
66 | 66 |
67 const CSSPropertyID property_; | 67 const CSSPropertyID property_; |
68 RefPtr<BasicShape> inherited_shape_; | 68 RefPtr<BasicShape> inherited_shape_; |
69 }; | 69 }; |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 InterpolationValue CSSBasicShapeInterpolationType::MaybeConvertNeutral( | 73 InterpolationValue CSSBasicShapeInterpolationType::MaybeConvertNeutral( |
74 const InterpolationValue& underlying, | 74 const InterpolationValue& underlying, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 const NonInterpolableValue* non_interpolable_value, | 157 const NonInterpolableValue* non_interpolable_value, |
158 StyleResolverState& state) const { | 158 StyleResolverState& state) const { |
159 BasicShapePropertyFunctions::SetBasicShape( | 159 BasicShapePropertyFunctions::SetBasicShape( |
160 CssProperty(), *state.Style(), | 160 CssProperty(), *state.Style(), |
161 BasicShapeInterpolationFunctions::CreateBasicShape( | 161 BasicShapeInterpolationFunctions::CreateBasicShape( |
162 interpolable_value, *non_interpolable_value, | 162 interpolable_value, *non_interpolable_value, |
163 state.CssToLengthConversionData())); | 163 state.CssToLengthConversionData())); |
164 } | 164 } |
165 | 165 |
166 } // namespace blink | 166 } // namespace blink |
OLD | NEW |