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

Side by Side Diff: third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp

Issue 2561773003: Parse input argument types and store the argument types in CSSPaintDefinition. (Closed)
Patch Set: input arguments parsing Created 4 years 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 "modules/csspaint/PaintWorkletGlobalScope.h" 5 #include "modules/csspaint/PaintWorkletGlobalScope.h"
6 6
7 #include "bindings/core/v8/V8BindingMacros.h" 7 #include "bindings/core/v8/V8BindingMacros.h"
8 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 8 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
9 #include "core/CSSPropertyNames.h" 9 #include "core/CSSPropertyNames.h"
10 #include "core/css/CSSSyntaxDescriptor.h"
10 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
11 #include "core/inspector/MainThreadDebugger.h" 12 #include "core/inspector/MainThreadDebugger.h"
12 #include "modules/csspaint/CSSPaintDefinition.h" 13 #include "modules/csspaint/CSSPaintDefinition.h"
13 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h" 14 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 // static 18 // static
18 PaintWorkletGlobalScope* PaintWorkletGlobalScope::create( 19 PaintWorkletGlobalScope* PaintWorkletGlobalScope::create(
19 LocalFrame* frame, 20 LocalFrame* frame,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 for (const auto& property : properties) { 97 for (const auto& property : properties) {
97 CSSPropertyID propertyID = cssPropertyID(property); 98 CSSPropertyID propertyID = cssPropertyID(property);
98 if (propertyID == CSSPropertyVariable) { 99 if (propertyID == CSSPropertyVariable) {
99 customInvalidationProperties.append(property); 100 customInvalidationProperties.append(property);
100 } else if (propertyID != CSSPropertyInvalid) { 101 } else if (propertyID != CSSPropertyInvalid) {
101 nativeInvalidationProperties.append(propertyID); 102 nativeInvalidationProperties.append(propertyID);
102 } 103 }
103 } 104 }
104 } 105 }
105 106
107 // Get input argument types.
108 v8::Local<v8::Value> inputArgumentTypeValues;
ikilpatrick 2017/01/12 18:17:03 we should also only attempt to parse this if the r
renjieliu1 2017/01/13 04:18:23 Done.
109 if (!v8Call(constructor->Get(context, v8String(isolate, "inputArguments")),
110 inputArgumentTypeValues))
111 return;
112
113 Vector<CSSSyntaxDescriptor> inputArgumentTypes;
114 if (!isUndefinedOrNull(inputArgumentTypeValues)) {
115 Vector<String> argumentTypes = toImplArray<Vector<String>>(
116 inputArgumentTypeValues, 0, isolate, exceptionState);
117
118 if (exceptionState.hadException())
119 return;
120
121 for (const auto& type : argumentTypes) {
122 CSSSyntaxDescriptor syntaxDescriptor(type);
123 if (!syntaxDescriptor.isValid())
ikilpatrick 2017/01/12 05:36:04 It would be good to throw a TypeError here.
renjieliu1 2017/01/13 04:18:23 Done.
124 return;
125 inputArgumentTypes.append(syntaxDescriptor);
126 }
127 }
128
106 // Parse 'alpha' AKA hasAlpha property. 129 // Parse 'alpha' AKA hasAlpha property.
107 v8::Local<v8::Value> alphaValue; 130 v8::Local<v8::Value> alphaValue;
108 if (!v8Call(constructor->Get(context, v8String(isolate, "alpha")), 131 if (!v8Call(constructor->Get(context, v8String(isolate, "alpha")),
109 alphaValue)) 132 alphaValue))
110 return; 133 return;
111 if (!isUndefinedOrNull(alphaValue) && !alphaValue->IsBoolean()) { 134 if (!isUndefinedOrNull(alphaValue) && !alphaValue->IsBoolean()) {
112 exceptionState.throwTypeError( 135 exceptionState.throwTypeError(
113 "The 'alpha' property on the class is not a boolean."); 136 "The 'alpha' property on the class is not a boolean.");
114 return; 137 return;
115 } 138 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (!paintValue->IsFunction()) { 172 if (!paintValue->IsFunction()) {
150 exceptionState.throwTypeError( 173 exceptionState.throwTypeError(
151 "The 'paint' property on the prototype is not a function."); 174 "The 'paint' property on the prototype is not a function.");
152 return; 175 return;
153 } 176 }
154 177
155 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue); 178 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue);
156 179
157 CSSPaintDefinition* definition = CSSPaintDefinition::create( 180 CSSPaintDefinition* definition = CSSPaintDefinition::create(
158 scriptController()->getScriptState(), constructor, paint, 181 scriptController()->getScriptState(), constructor, paint,
159 nativeInvalidationProperties, customInvalidationProperties, hasAlpha); 182 nativeInvalidationProperties, customInvalidationProperties,
183 inputArgumentTypes, hasAlpha);
160 m_paintDefinitions.set(name, definition); 184 m_paintDefinitions.set(name, definition);
161 185
162 // Set the definition on any pending generators. 186 // Set the definition on any pending generators.
163 GeneratorHashSet* set = m_pendingGenerators.get(name); 187 GeneratorHashSet* set = m_pendingGenerators.get(name);
164 if (set) { 188 if (set) {
165 for (const auto& generator : *set) { 189 for (const auto& generator : *set) {
166 if (generator) { 190 if (generator) {
167 generator->setDefinition(definition); 191 generator->setDefinition(definition);
168 } 192 }
169 } 193 }
(...skipping 16 matching lines...) Expand all
186 set->add(generator); 210 set->add(generator);
187 } 211 }
188 212
189 DEFINE_TRACE(PaintWorkletGlobalScope) { 213 DEFINE_TRACE(PaintWorkletGlobalScope) {
190 visitor->trace(m_paintDefinitions); 214 visitor->trace(m_paintDefinitions);
191 visitor->trace(m_pendingGenerators); 215 visitor->trace(m_pendingGenerators);
192 MainThreadWorkletGlobalScope::trace(visitor); 216 MainThreadWorkletGlobalScope::trace(visitor);
193 } 217 }
194 218
195 } // namespace blink 219 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698