Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSFilterListInterpolationType.cpp

Issue 2812213002: Add CSSInterpolationType specific ConversionChecker (Closed)
Patch Set: rebased Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/CSSFilterListInterpolationType.h" 5 #include "core/animation/CSSFilterListInterpolationType.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/animation/FilterInterpolationFunctions.h" 8 #include "core/animation/FilterInterpolationFunctions.h"
9 #include "core/animation/FilterListPropertyFunctions.h" 9 #include "core/animation/FilterListPropertyFunctions.h"
10 #include "core/animation/ListInterpolationFunctions.h" 10 #include "core/animation/ListInterpolationFunctions.h"
11 #include "core/css/CSSIdentifierValue.h" 11 #include "core/css/CSSIdentifierValue.h"
12 #include "core/css/CSSValueList.h" 12 #include "core/css/CSSValueList.h"
13 #include "core/css/resolver/StyleResolverState.h" 13 #include "core/css/resolver/StyleResolverState.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 UnderlyingFilterListChecker 20 class UnderlyingFilterListChecker
21 : public InterpolationType::ConversionChecker { 21 : public CSSInterpolationType::CSSConversionChecker {
22 public: 22 public:
23 static std::unique_ptr<UnderlyingFilterListChecker> Create( 23 static std::unique_ptr<UnderlyingFilterListChecker> Create(
24 PassRefPtr<NonInterpolableList> non_interpolable_list) { 24 PassRefPtr<NonInterpolableList> non_interpolable_list) {
25 return WTF::WrapUnique( 25 return WTF::WrapUnique(
26 new UnderlyingFilterListChecker(std::move(non_interpolable_list))); 26 new UnderlyingFilterListChecker(std::move(non_interpolable_list)));
27 } 27 }
28 28
29 bool IsValid(const InterpolationEnvironment&, 29 bool IsValid(const StyleResolverState&,
30 const InterpolationValue& underlying) const final { 30 const InterpolationValue& underlying) const final {
31 const NonInterpolableList& underlying_non_interpolable_list = 31 const NonInterpolableList& underlying_non_interpolable_list =
32 ToNonInterpolableList(*underlying.non_interpolable_value); 32 ToNonInterpolableList(*underlying.non_interpolable_value);
33 if (non_interpolable_list_->length() != 33 if (non_interpolable_list_->length() !=
34 underlying_non_interpolable_list.length()) 34 underlying_non_interpolable_list.length())
35 return false; 35 return false;
36 for (size_t i = 0; i < non_interpolable_list_->length(); i++) { 36 for (size_t i = 0; i < non_interpolable_list_->length(); i++) {
37 if (!FilterInterpolationFunctions::FiltersAreCompatible( 37 if (!FilterInterpolationFunctions::FiltersAreCompatible(
38 *non_interpolable_list_->Get(i), 38 *non_interpolable_list_->Get(i),
39 *underlying_non_interpolable_list.Get(i))) 39 *underlying_non_interpolable_list.Get(i)))
40 return false; 40 return false;
41 } 41 }
42 return true; 42 return true;
43 } 43 }
44 44
45 private: 45 private:
46 UnderlyingFilterListChecker( 46 UnderlyingFilterListChecker(
47 PassRefPtr<NonInterpolableList> non_interpolable_list) 47 PassRefPtr<NonInterpolableList> non_interpolable_list)
48 : non_interpolable_list_(std::move(non_interpolable_list)) {} 48 : non_interpolable_list_(std::move(non_interpolable_list)) {}
49 49
50 RefPtr<NonInterpolableList> non_interpolable_list_; 50 RefPtr<NonInterpolableList> non_interpolable_list_;
51 }; 51 };
52 52
53 class InheritedFilterListChecker : public InterpolationType::ConversionChecker { 53 class InheritedFilterListChecker
54 : public CSSInterpolationType::CSSConversionChecker {
54 public: 55 public:
55 static std::unique_ptr<InheritedFilterListChecker> Create( 56 static std::unique_ptr<InheritedFilterListChecker> Create(
56 CSSPropertyID property, 57 CSSPropertyID property,
57 const FilterOperations& filter_operations) { 58 const FilterOperations& filter_operations) {
58 return WTF::WrapUnique( 59 return WTF::WrapUnique(
59 new InheritedFilterListChecker(property, filter_operations)); 60 new InheritedFilterListChecker(property, filter_operations));
60 } 61 }
61 62
62 bool IsValid(const InterpolationEnvironment& environment, 63 bool IsValid(const StyleResolverState& state,
63 const InterpolationValue&) const final { 64 const InterpolationValue&) const final {
64 const FilterOperations& filter_operations = 65 const FilterOperations& filter_operations =
65 filter_operations_wrapper_->Operations(); 66 filter_operations_wrapper_->Operations();
66 return filter_operations == 67 return filter_operations == FilterListPropertyFunctions::GetFilterList(
67 FilterListPropertyFunctions::GetFilterList( 68 property_, *state.ParentStyle());
68 property_, *environment.GetState().ParentStyle());
69 } 69 }
70 70
71 private: 71 private:
72 InheritedFilterListChecker(CSSPropertyID property, 72 InheritedFilterListChecker(CSSPropertyID property,
73 const FilterOperations& filter_operations) 73 const FilterOperations& filter_operations)
74 : property_(property), 74 : property_(property),
75 filter_operations_wrapper_( 75 filter_operations_wrapper_(
76 FilterOperationsWrapper::Create(filter_operations)) {} 76 FilterOperationsWrapper::Create(filter_operations)) {}
77 77
78 const CSSPropertyID property_; 78 const CSSPropertyID property_;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 for (size_t i = 0; i < length; i++) { 292 for (size_t i = 0; i < length; i++) {
293 filter_operations.Operations().push_back( 293 filter_operations.Operations().push_back(
294 FilterInterpolationFunctions::CreateFilter( 294 FilterInterpolationFunctions::CreateFilter(
295 *interpolable_list.Get(i), *non_interpolable_list.Get(i), state)); 295 *interpolable_list.Get(i), *non_interpolable_list.Get(i), state));
296 } 296 }
297 FilterListPropertyFunctions::SetFilterList(CssProperty(), *state.Style(), 297 FilterListPropertyFunctions::SetFilterList(CssProperty(), *state.Style(),
298 std::move(filter_operations)); 298 std::move(filter_operations));
299 } 299 }
300 300
301 } // namespace blink 301 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698