| 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/CSSSizeListInterpolationType.h" | 5 #include "core/animation/CSSSizeListInterpolationType.h" |
| 6 | 6 |
| 7 #include "core/animation/ListInterpolationFunctions.h" | 7 #include "core/animation/ListInterpolationFunctions.h" |
| 8 #include "core/animation/SizeInterpolationFunctions.h" | 8 #include "core/animation/SizeInterpolationFunctions.h" |
| 9 #include "core/animation/SizeListPropertyFunctions.h" | 9 #include "core/animation/SizeListPropertyFunctions.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 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class UnderlyingSizeListChecker : public InterpolationType::ConversionChecker { | 15 class UnderlyingSizeListChecker |
| 16 : public CSSInterpolationType::CSSConversionChecker { |
| 16 public: | 17 public: |
| 17 ~UnderlyingSizeListChecker() final {} | 18 ~UnderlyingSizeListChecker() final {} |
| 18 | 19 |
| 19 static std::unique_ptr<UnderlyingSizeListChecker> Create( | 20 static std::unique_ptr<UnderlyingSizeListChecker> Create( |
| 20 const NonInterpolableList& underlying_list) { | 21 const NonInterpolableList& underlying_list) { |
| 21 return WTF::WrapUnique(new UnderlyingSizeListChecker(underlying_list)); | 22 return WTF::WrapUnique(new UnderlyingSizeListChecker(underlying_list)); |
| 22 } | 23 } |
| 23 | 24 |
| 24 private: | 25 private: |
| 25 UnderlyingSizeListChecker(const NonInterpolableList& underlying_list) | 26 UnderlyingSizeListChecker(const NonInterpolableList& underlying_list) |
| 26 : underlying_list_(&underlying_list) {} | 27 : underlying_list_(&underlying_list) {} |
| 27 | 28 |
| 28 bool IsValid(const InterpolationEnvironment&, | 29 bool IsValid(const StyleResolverState&, |
| 29 const InterpolationValue& underlying) const final { | 30 const InterpolationValue& underlying) const final { |
| 30 const auto& underlying_list = | 31 const auto& underlying_list = |
| 31 ToNonInterpolableList(*underlying.non_interpolable_value); | 32 ToNonInterpolableList(*underlying.non_interpolable_value); |
| 32 size_t underlying_length = underlying_list.length(); | 33 size_t underlying_length = underlying_list.length(); |
| 33 if (underlying_length != underlying_list_->length()) | 34 if (underlying_length != underlying_list_->length()) |
| 34 return false; | 35 return false; |
| 35 for (size_t i = 0; i < underlying_length; i++) { | 36 for (size_t i = 0; i < underlying_length; i++) { |
| 36 bool compatible = | 37 bool compatible = |
| 37 SizeInterpolationFunctions::NonInterpolableValuesAreCompatible( | 38 SizeInterpolationFunctions::NonInterpolableValuesAreCompatible( |
| 38 underlying_list.Get(i), underlying_list_->Get(i)); | 39 underlying_list.Get(i), underlying_list_->Get(i)); |
| 39 if (!compatible) | 40 if (!compatible) |
| 40 return false; | 41 return false; |
| 41 } | 42 } |
| 42 return true; | 43 return true; |
| 43 } | 44 } |
| 44 | 45 |
| 45 RefPtr<const NonInterpolableList> underlying_list_; | 46 RefPtr<const NonInterpolableList> underlying_list_; |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 class InheritedSizeListChecker : public InterpolationType::ConversionChecker { | 49 class InheritedSizeListChecker |
| 50 : public CSSInterpolationType::CSSConversionChecker { |
| 49 public: | 51 public: |
| 50 ~InheritedSizeListChecker() final {} | 52 ~InheritedSizeListChecker() final {} |
| 51 | 53 |
| 52 static std::unique_ptr<InheritedSizeListChecker> Create( | 54 static std::unique_ptr<InheritedSizeListChecker> Create( |
| 53 CSSPropertyID property, | 55 CSSPropertyID property, |
| 54 const SizeList& inherited_size_list) { | 56 const SizeList& inherited_size_list) { |
| 55 return WTF::WrapUnique( | 57 return WTF::WrapUnique( |
| 56 new InheritedSizeListChecker(property, inherited_size_list)); | 58 new InheritedSizeListChecker(property, inherited_size_list)); |
| 57 } | 59 } |
| 58 | 60 |
| 59 private: | 61 private: |
| 60 InheritedSizeListChecker(CSSPropertyID property, | 62 InheritedSizeListChecker(CSSPropertyID property, |
| 61 const SizeList& inherited_size_list) | 63 const SizeList& inherited_size_list) |
| 62 : property_(property), inherited_size_list_(inherited_size_list) {} | 64 : property_(property), inherited_size_list_(inherited_size_list) {} |
| 63 | 65 |
| 64 bool IsValid(const InterpolationEnvironment& environment, | 66 bool IsValid(const StyleResolverState& state, |
| 65 const InterpolationValue&) const final { | 67 const InterpolationValue&) const final { |
| 66 return inherited_size_list_ == | 68 return inherited_size_list_ == SizeListPropertyFunctions::GetSizeList( |
| 67 SizeListPropertyFunctions::GetSizeList( | 69 property_, *state.ParentStyle()); |
| 68 property_, *environment.GetState().ParentStyle()); | |
| 69 } | 70 } |
| 70 | 71 |
| 71 CSSPropertyID property_; | 72 CSSPropertyID property_; |
| 72 SizeList inherited_size_list_; | 73 SizeList inherited_size_list_; |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 InterpolationValue ConvertSizeList(const SizeList& size_list, float zoom) { | 76 InterpolationValue ConvertSizeList(const SizeList& size_list, float zoom) { |
| 76 // Flatten pairs of width/height into individual items, even for contain and | 77 // Flatten pairs of width/height into individual items, even for contain and |
| 77 // cover keywords. | 78 // cover keywords. |
| 78 return ListInterpolationFunctions::CreateList( | 79 return ListInterpolationFunctions::CreateList( |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 size_list[i] = SizeInterpolationFunctions::CreateFillSize( | 192 size_list[i] = SizeInterpolationFunctions::CreateFillSize( |
| 192 *interpolable_list.Get(i * 2), non_interpolable_list.Get(i * 2), | 193 *interpolable_list.Get(i * 2), non_interpolable_list.Get(i * 2), |
| 193 *interpolable_list.Get(i * 2 + 1), non_interpolable_list.Get(i * 2 + 1), | 194 *interpolable_list.Get(i * 2 + 1), non_interpolable_list.Get(i * 2 + 1), |
| 194 state.CssToLengthConversionData()); | 195 state.CssToLengthConversionData()); |
| 195 } | 196 } |
| 196 SizeListPropertyFunctions::SetSizeList(CssProperty(), *state.Style(), | 197 SizeListPropertyFunctions::SetSizeList(CssProperty(), *state.Style(), |
| 197 size_list); | 198 size_list); |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace blink | 201 } // namespace blink |
| OLD | NEW |