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

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSInterpolationType.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/CSSInterpolationType.h" 5 #include "core/animation/CSSInterpolationType.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/StylePropertyShorthand.h" 8 #include "core/StylePropertyShorthand.h"
9 #include "core/animation/StringKeyframe.h" 9 #include "core/animation/StringKeyframe.h"
10 #include "core/css/CSSCustomPropertyDeclaration.h" 10 #include "core/css/CSSCustomPropertyDeclaration.h"
11 #include "core/css/CSSValue.h" 11 #include "core/css/CSSValue.h"
12 #include "core/css/CSSVariableReferenceValue.h" 12 #include "core/css/CSSVariableReferenceValue.h"
13 #include "core/css/ComputedStyleCSSValueMapping.h" 13 #include "core/css/ComputedStyleCSSValueMapping.h"
14 #include "core/css/PropertyRegistration.h" 14 #include "core/css/PropertyRegistration.h"
15 #include "core/css/parser/CSSTokenizer.h" 15 #include "core/css/parser/CSSTokenizer.h"
16 #include "core/css/resolver/CSSVariableResolver.h" 16 #include "core/css/resolver/CSSVariableResolver.h"
17 #include "core/css/resolver/StyleBuilder.h" 17 #include "core/css/resolver/StyleBuilder.h"
18 #include "core/css/resolver/StyleResolverState.h" 18 #include "core/css/resolver/StyleResolverState.h"
19 #include "core/style/DataEquivalency.h" 19 #include "core/style/DataEquivalency.h"
20 #include "platform/RuntimeEnabledFeatures.h" 20 #include "platform/RuntimeEnabledFeatures.h"
21 #include "platform/wtf/PtrUtil.h" 21 #include "platform/wtf/PtrUtil.h"
22 22
23 namespace blink { 23 namespace blink {
24 24
25 class ResolvedVariableChecker : public InterpolationType::ConversionChecker { 25 class ResolvedVariableChecker
26 : public CSSInterpolationType::CSSConversionChecker {
26 public: 27 public:
27 static std::unique_ptr<ResolvedVariableChecker> Create( 28 static std::unique_ptr<ResolvedVariableChecker> Create(
28 CSSPropertyID property, 29 CSSPropertyID property,
29 const CSSValue* variable_reference, 30 const CSSValue* variable_reference,
30 const CSSValue* resolved_value) { 31 const CSSValue* resolved_value) {
31 return WTF::WrapUnique(new ResolvedVariableChecker( 32 return WTF::WrapUnique(new ResolvedVariableChecker(
32 property, variable_reference, resolved_value)); 33 property, variable_reference, resolved_value));
33 } 34 }
34 35
35 private: 36 private:
36 ResolvedVariableChecker(CSSPropertyID property, 37 ResolvedVariableChecker(CSSPropertyID property,
37 const CSSValue* variable_reference, 38 const CSSValue* variable_reference,
38 const CSSValue* resolved_value) 39 const CSSValue* resolved_value)
39 : property_(property), 40 : property_(property),
40 variable_reference_(variable_reference), 41 variable_reference_(variable_reference),
41 resolved_value_(resolved_value) {} 42 resolved_value_(resolved_value) {}
42 43
43 bool IsValid(const InterpolationEnvironment& environment, 44 bool IsValid(const StyleResolverState& state,
44 const InterpolationValue& underlying) const final { 45 const InterpolationValue& underlying) const final {
45 // TODO(alancutter): Just check the variables referenced instead of doing a 46 // TODO(alancutter): Just check the variables referenced instead of doing a
46 // full CSSValue resolve. 47 // full CSSValue resolve.
47 bool omit_animation_tainted = false; 48 bool omit_animation_tainted = false;
48 const CSSValue* resolved_value = 49 const CSSValue* resolved_value =
49 CSSVariableResolver::ResolveVariableReferences( 50 CSSVariableResolver::ResolveVariableReferences(
50 environment.GetState(), property_, *variable_reference_, 51 state, property_, *variable_reference_, omit_animation_tainted);
51 omit_animation_tainted);
52 return DataEquivalent(resolved_value_.Get(), resolved_value); 52 return DataEquivalent(resolved_value_.Get(), resolved_value);
53 } 53 }
54 54
55 CSSPropertyID property_; 55 CSSPropertyID property_;
56 Persistent<const CSSValue> variable_reference_; 56 Persistent<const CSSValue> variable_reference_;
57 Persistent<const CSSValue> resolved_value_; 57 Persistent<const CSSValue> resolved_value_;
58 }; 58 };
59 59
60 class InheritedCustomPropertyChecker 60 class InheritedCustomPropertyChecker
61 : public InterpolationType::ConversionChecker { 61 : public CSSInterpolationType::CSSConversionChecker {
62 public: 62 public:
63 static std::unique_ptr<InheritedCustomPropertyChecker> Create( 63 static std::unique_ptr<InheritedCustomPropertyChecker> Create(
64 const AtomicString& property, 64 const AtomicString& property,
65 bool is_inherited_property, 65 bool is_inherited_property,
66 const CSSValue* inherited_value, 66 const CSSValue* inherited_value,
67 const CSSValue* initial_value) { 67 const CSSValue* initial_value) {
68 return WTF::WrapUnique(new InheritedCustomPropertyChecker( 68 return WTF::WrapUnique(new InheritedCustomPropertyChecker(
69 property, is_inherited_property, inherited_value, initial_value)); 69 property, is_inherited_property, inherited_value, initial_value));
70 } 70 }
71 71
72 private: 72 private:
73 InheritedCustomPropertyChecker(const AtomicString& name, 73 InheritedCustomPropertyChecker(const AtomicString& name,
74 bool is_inherited_property, 74 bool is_inherited_property,
75 const CSSValue* inherited_value, 75 const CSSValue* inherited_value,
76 const CSSValue* initial_value) 76 const CSSValue* initial_value)
77 : name_(name), 77 : name_(name),
78 is_inherited_property_(is_inherited_property), 78 is_inherited_property_(is_inherited_property),
79 inherited_value_(inherited_value), 79 inherited_value_(inherited_value),
80 initial_value_(initial_value) {} 80 initial_value_(initial_value) {}
81 81
82 bool IsValid(const InterpolationEnvironment& environment, 82 bool IsValid(const StyleResolverState& state,
83 const InterpolationValue&) const final { 83 const InterpolationValue&) const final {
84 const CSSValue* inherited_value = 84 const CSSValue* inherited_value =
85 environment.GetState().ParentStyle()->GetRegisteredVariable( 85 state.ParentStyle()->GetRegisteredVariable(name_,
86 name_, is_inherited_property_); 86 is_inherited_property_);
87 if (!inherited_value) { 87 if (!inherited_value) {
88 inherited_value = initial_value_.Get(); 88 inherited_value = initial_value_.Get();
89 } 89 }
90 return DataEquivalent(inherited_value_.Get(), inherited_value); 90 return DataEquivalent(inherited_value_.Get(), inherited_value);
91 } 91 }
92 92
93 const AtomicString& name_; 93 const AtomicString& name_;
94 const bool is_inherited_property_; 94 const bool is_inherited_property_;
95 Persistent<const CSSValue> inherited_value_; 95 Persistent<const CSSValue> inherited_value_;
96 Persistent<const CSSValue> initial_value_; 96 Persistent<const CSSValue> initial_value_;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (registration_->Inherits()) { 307 if (registration_->Inherits()) {
308 style.SetResolvedInheritedVariable(property_name, std::move(variable_data), 308 style.SetResolvedInheritedVariable(property_name, std::move(variable_data),
309 css_value); 309 css_value);
310 } else { 310 } else {
311 style.SetResolvedNonInheritedVariable(property_name, 311 style.SetResolvedNonInheritedVariable(property_name,
312 std::move(variable_data), css_value); 312 std::move(variable_data), css_value);
313 } 313 }
314 } 314 }
315 315
316 } // namespace blink 316 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698