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

Side by Side Diff: third_party/WebKit/Source/core/css/PropertyRegistration.cpp

Issue 2618673003: Store registered property InterpolationTypes in PropertyRegistration (Closed)
Patch Set: Remove duplicate Created 3 years, 11 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/css/PropertyRegistration.h" 5 #include "core/css/PropertyRegistration.h"
6 6
7 #include "core/animation/CSSValueInterpolationType.h"
7 #include "core/css/CSSSyntaxDescriptor.h" 8 #include "core/css/CSSSyntaxDescriptor.h"
8 #include "core/css/CSSValueList.h" 9 #include "core/css/CSSValueList.h"
9 #include "core/css/CSSVariableReferenceValue.h" 10 #include "core/css/CSSVariableReferenceValue.h"
10 #include "core/css/PropertyDescriptor.h" 11 #include "core/css/PropertyDescriptor.h"
11 #include "core/css/PropertyRegistry.h" 12 #include "core/css/PropertyRegistry.h"
12 #include "core/css/parser/CSSTokenizer.h" 13 #include "core/css/parser/CSSTokenizer.h"
13 #include "core/css/parser/CSSVariableParser.h" 14 #include "core/css/parser/CSSVariableParser.h"
14 #include "core/dom/Document.h" 15 #include "core/dom/Document.h"
15 #include "core/dom/ExceptionCode.h" 16 #include "core/dom/ExceptionCode.h"
16 #include "core/dom/StyleChangeReason.h" 17 #include "core/dom/StyleChangeReason.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 50 }
50 return true; 51 return true;
51 } 52 }
52 53
53 // TODO(timloh): Images and transform-function values can also contain 54 // TODO(timloh): Images and transform-function values can also contain
54 // lengths. 55 // lengths.
55 56
56 return true; 57 return true;
57 } 58 }
58 59
60 InterpolationTypes interpolationTypesForSyntax(const AtomicString& propertyName,
61 const CSSSyntaxDescriptor&) {
62 PropertyHandle property(propertyName);
63 InterpolationTypes interpolationTypes;
64 // TODO(alancutter): Read the syntax descriptor and add the appropriate
65 // CSSInterpolationType subclasses.
66 interpolationTypes.append(
67 WTF::makeUnique<CSSValueInterpolationType>(property));
68 return interpolationTypes;
69 }
70
59 void PropertyRegistration::registerProperty( 71 void PropertyRegistration::registerProperty(
60 ExecutionContext* executionContext, 72 ExecutionContext* executionContext,
61 const PropertyDescriptor& descriptor, 73 const PropertyDescriptor& descriptor,
62 ExceptionState& exceptionState) { 74 ExceptionState& exceptionState) {
63 // Bindings code ensures these are set. 75 // Bindings code ensures these are set.
64 DCHECK(descriptor.hasName()); 76 DCHECK(descriptor.hasName());
65 DCHECK(descriptor.hasInherits()); 77 DCHECK(descriptor.hasInherits());
66 DCHECK(descriptor.hasSyntax()); 78 DCHECK(descriptor.hasSyntax());
67 79
68 String name = descriptor.name(); 80 String name = descriptor.name();
(...skipping 13 matching lines...) Expand all
82 } 94 }
83 95
84 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax()); 96 CSSSyntaxDescriptor syntaxDescriptor(descriptor.syntax());
85 if (!syntaxDescriptor.isValid()) { 97 if (!syntaxDescriptor.isValid()) {
86 exceptionState.throwDOMException( 98 exceptionState.throwDOMException(
87 SyntaxError, 99 SyntaxError,
88 "The syntax provided is not a valid custom property syntax."); 100 "The syntax provided is not a valid custom property syntax.");
89 return; 101 return;
90 } 102 }
91 103
104 InterpolationTypes interpolationTypes =
105 interpolationTypesForSyntax(atomicName, syntaxDescriptor);
106
92 if (descriptor.hasInitialValue()) { 107 if (descriptor.hasInitialValue()) {
93 CSSTokenizer tokenizer(descriptor.initialValue()); 108 CSSTokenizer tokenizer(descriptor.initialValue());
94 bool isAnimationTainted = false; 109 bool isAnimationTainted = false;
95 const CSSValue* initial = 110 const CSSValue* initial =
96 syntaxDescriptor.parse(tokenizer.tokenRange(), isAnimationTainted); 111 syntaxDescriptor.parse(tokenizer.tokenRange(), isAnimationTainted);
97 if (!initial) { 112 if (!initial) {
98 exceptionState.throwDOMException( 113 exceptionState.throwDOMException(
99 SyntaxError, 114 SyntaxError,
100 "The initial value provided does not parse for the given syntax."); 115 "The initial value provided does not parse for the given syntax.");
101 return; 116 return;
102 } 117 }
103 if (!computationallyIndependent(*initial)) { 118 if (!computationallyIndependent(*initial)) {
104 exceptionState.throwDOMException( 119 exceptionState.throwDOMException(
105 SyntaxError, 120 SyntaxError,
106 "The initial value provided is not computationally independent."); 121 "The initial value provided is not computationally independent.");
107 return; 122 return;
108 } 123 }
109 RefPtr<CSSVariableData> initialVariableData = CSSVariableData::create( 124 RefPtr<CSSVariableData> initialVariableData = CSSVariableData::create(
110 tokenizer.tokenRange(), isAnimationTainted, false); 125 tokenizer.tokenRange(), isAnimationTainted, false);
111 registry.registerProperty(atomicName, syntaxDescriptor, 126 registry.registerProperty(
112 descriptor.inherits(), initial, 127 atomicName, syntaxDescriptor, descriptor.inherits(), initial,
113 initialVariableData.release()); 128 initialVariableData.release(), std::move(interpolationTypes));
114 } else { 129 } else {
115 if (!syntaxDescriptor.isTokenStream()) { 130 if (!syntaxDescriptor.isTokenStream()) {
116 exceptionState.throwDOMException( 131 exceptionState.throwDOMException(
117 SyntaxError, 132 SyntaxError,
118 "An initial value must be provided if the syntax is not '*'"); 133 "An initial value must be provided if the syntax is not '*'");
119 return; 134 return;
120 } 135 }
121 registry.registerProperty(atomicName, syntaxDescriptor, 136 registry.registerProperty(atomicName, syntaxDescriptor,
122 descriptor.inherits(), nullptr, nullptr); 137 descriptor.inherits(), nullptr, nullptr,
138 std::move(interpolationTypes));
123 } 139 }
124 140
125 // TODO(timloh): Invalidate only elements with this custom property set 141 // TODO(timloh): Invalidate only elements with this custom property set
126 document->setNeedsStyleRecalc(SubtreeStyleChange, 142 document->setNeedsStyleRecalc(SubtreeStyleChange,
127 StyleChangeReasonForTracing::create( 143 StyleChangeReasonForTracing::create(
128 StyleChangeReason::PropertyRegistration)); 144 StyleChangeReason::PropertyRegistration));
129 } 145 }
130 146
131 } // namespace blink 147 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/InterpolationType.h ('k') | third_party/WebKit/Source/core/css/PropertyRegistry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698