| 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/CSSBorderImageLengthBoxInterpolationType.h" | 5 #include "core/animation/CSSBorderImageLengthBoxInterpolationType.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "core/animation/BorderImageLengthBoxPropertyFunctions.h" | 8 #include "core/animation/BorderImageLengthBoxPropertyFunctions.h" |
| 9 #include "core/animation/LengthInterpolationFunctions.h" | 9 #include "core/animation/LengthInterpolationFunctions.h" |
| 10 #include "core/animation/SideIndex.h" | 10 #include "core/animation/SideIndex.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 const SideTypes side_types_; | 112 const SideTypes side_types_; |
| 113 Vector<RefPtr<NonInterpolableValue>> side_non_interpolable_values_; | 113 Vector<RefPtr<NonInterpolableValue>> side_non_interpolable_values_; |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSBorderImageLengthBoxNonInterpolableValue); | 116 DEFINE_NON_INTERPOLABLE_VALUE_TYPE(CSSBorderImageLengthBoxNonInterpolableValue); |
| 117 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS( | 117 DEFINE_NON_INTERPOLABLE_VALUE_TYPE_CASTS( |
| 118 CSSBorderImageLengthBoxNonInterpolableValue); | 118 CSSBorderImageLengthBoxNonInterpolableValue); |
| 119 | 119 |
| 120 namespace { | 120 namespace { |
| 121 | 121 |
| 122 class UnderlyingSideTypesChecker : public InterpolationType::ConversionChecker { | 122 class UnderlyingSideTypesChecker |
| 123 : public CSSInterpolationType::CSSConversionChecker { |
| 123 public: | 124 public: |
| 124 static std::unique_ptr<UnderlyingSideTypesChecker> Create( | 125 static std::unique_ptr<UnderlyingSideTypesChecker> Create( |
| 125 const SideTypes& underlying_side_types) { | 126 const SideTypes& underlying_side_types) { |
| 126 return WTF::WrapUnique( | 127 return WTF::WrapUnique( |
| 127 new UnderlyingSideTypesChecker(underlying_side_types)); | 128 new UnderlyingSideTypesChecker(underlying_side_types)); |
| 128 } | 129 } |
| 129 | 130 |
| 130 static SideTypes GetUnderlyingSideTypes( | 131 static SideTypes GetUnderlyingSideTypes( |
| 131 const InterpolationValue& underlying) { | 132 const InterpolationValue& underlying) { |
| 132 return ToCSSBorderImageLengthBoxNonInterpolableValue( | 133 return ToCSSBorderImageLengthBoxNonInterpolableValue( |
| 133 *underlying.non_interpolable_value) | 134 *underlying.non_interpolable_value) |
| 134 .GetSideTypes(); | 135 .GetSideTypes(); |
| 135 } | 136 } |
| 136 | 137 |
| 137 private: | 138 private: |
| 138 UnderlyingSideTypesChecker(const SideTypes& underlying_side_types) | 139 UnderlyingSideTypesChecker(const SideTypes& underlying_side_types) |
| 139 : underlying_side_types_(underlying_side_types) {} | 140 : underlying_side_types_(underlying_side_types) {} |
| 140 | 141 |
| 141 bool IsValid(const InterpolationEnvironment&, | 142 bool IsValid(const StyleResolverState&, |
| 142 const InterpolationValue& underlying) const final { | 143 const InterpolationValue& underlying) const final { |
| 143 return underlying_side_types_ == GetUnderlyingSideTypes(underlying); | 144 return underlying_side_types_ == GetUnderlyingSideTypes(underlying); |
| 144 } | 145 } |
| 145 | 146 |
| 146 const SideTypes underlying_side_types_; | 147 const SideTypes underlying_side_types_; |
| 147 }; | 148 }; |
| 148 | 149 |
| 149 class InheritedSideTypesChecker : public InterpolationType::ConversionChecker { | 150 class InheritedSideTypesChecker |
| 151 : public CSSInterpolationType::CSSConversionChecker { |
| 150 public: | 152 public: |
| 151 static std::unique_ptr<InheritedSideTypesChecker> Create( | 153 static std::unique_ptr<InheritedSideTypesChecker> Create( |
| 152 CSSPropertyID property, | 154 CSSPropertyID property, |
| 153 const SideTypes& inherited_side_types) { | 155 const SideTypes& inherited_side_types) { |
| 154 return WTF::WrapUnique( | 156 return WTF::WrapUnique( |
| 155 new InheritedSideTypesChecker(property, inherited_side_types)); | 157 new InheritedSideTypesChecker(property, inherited_side_types)); |
| 156 } | 158 } |
| 157 | 159 |
| 158 private: | 160 private: |
| 159 InheritedSideTypesChecker(CSSPropertyID property, | 161 InheritedSideTypesChecker(CSSPropertyID property, |
| 160 const SideTypes& inherited_side_types) | 162 const SideTypes& inherited_side_types) |
| 161 : property_(property), inherited_side_types_(inherited_side_types) {} | 163 : property_(property), inherited_side_types_(inherited_side_types) {} |
| 162 | 164 |
| 163 bool IsValid(const InterpolationEnvironment& environment, | 165 bool IsValid(const StyleResolverState& state, |
| 164 const InterpolationValue& underlying) const final { | 166 const InterpolationValue& underlying) const final { |
| 165 return inherited_side_types_ == | 167 return inherited_side_types_ == |
| 166 SideTypes( | 168 SideTypes( |
| 167 BorderImageLengthBoxPropertyFunctions::GetBorderImageLengthBox( | 169 BorderImageLengthBoxPropertyFunctions::GetBorderImageLengthBox( |
| 168 property_, *environment.GetState().ParentStyle())); | 170 property_, *state.ParentStyle())); |
| 169 } | 171 } |
| 170 | 172 |
| 171 const CSSPropertyID property_; | 173 const CSSPropertyID property_; |
| 172 const SideTypes inherited_side_types_; | 174 const SideTypes inherited_side_types_; |
| 173 }; | 175 }; |
| 174 | 176 |
| 175 InterpolationValue ConvertBorderImageLengthBox(const BorderImageLengthBox& box, | 177 InterpolationValue ConvertBorderImageLengthBox(const BorderImageLengthBox& box, |
| 176 double zoom) { | 178 double zoom) { |
| 177 std::unique_ptr<InterpolableList> list = | 179 std::unique_ptr<InterpolableList> list = |
| 178 InterpolableList::Create(kSideIndexCount); | 180 InterpolableList::Create(kSideIndexCount); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 return Length(kAuto); | 397 return Length(kAuto); |
| 396 } | 398 } |
| 397 }; | 399 }; |
| 398 BorderImageLengthBox box(convert_side(kSideTop), convert_side(kSideRight), | 400 BorderImageLengthBox box(convert_side(kSideTop), convert_side(kSideRight), |
| 399 convert_side(kSideBottom), convert_side(kSideLeft)); | 401 convert_side(kSideBottom), convert_side(kSideLeft)); |
| 400 BorderImageLengthBoxPropertyFunctions::SetBorderImageLengthBox( | 402 BorderImageLengthBoxPropertyFunctions::SetBorderImageLengthBox( |
| 401 CssProperty(), *state.Style(), box); | 403 CssProperty(), *state.Style(), box); |
| 402 } | 404 } |
| 403 | 405 |
| 404 } // namespace blink | 406 } // namespace blink |
| OLD | NEW |