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

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

Issue 2836093004: Remove V8Call and replace with v8::Maybe<T>::To and v8::MaybeLocal<T>::ToLocal. (Closed)
Patch Set: rebase Created 3 years, 7 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 "modules/csspaint/PaintWorkletGlobalScope.h" 5 #include "modules/csspaint/PaintWorkletGlobalScope.h"
6 6
7 #include "bindings/core/v8/IDLTypes.h" 7 #include "bindings/core/v8/IDLTypes.h"
8 #include "bindings/core/v8/NativeValueTraitsImpl.h" 8 #include "bindings/core/v8/NativeValueTraitsImpl.h"
9 #include "bindings/core/v8/V8BindingMacros.h" 9 #include "bindings/core/v8/V8BindingMacros.h"
10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 v8::Isolate* isolate = ScriptController()->GetScriptState()->GetIsolate(); 81 v8::Isolate* isolate = ScriptController()->GetScriptState()->GetIsolate();
82 v8::Local<v8::Context> context = ScriptController()->GetContext(); 82 v8::Local<v8::Context> context = ScriptController()->GetContext();
83 83
84 ASSERT(ctor_value.V8Value()->IsFunction()); 84 ASSERT(ctor_value.V8Value()->IsFunction());
85 v8::Local<v8::Function> constructor = 85 v8::Local<v8::Function> constructor =
86 v8::Local<v8::Function>::Cast(ctor_value.V8Value()); 86 v8::Local<v8::Function>::Cast(ctor_value.V8Value());
87 87
88 v8::Local<v8::Value> input_properties_value; 88 v8::Local<v8::Value> input_properties_value;
89 if (!V8Call(constructor->Get(context, V8String(isolate, "inputProperties")), 89 if (!constructor->Get(context, V8String(isolate, "inputProperties"))
90 input_properties_value)) 90 .ToLocal(&input_properties_value))
91 return; 91 return;
92 92
93 Vector<CSSPropertyID> native_invalidation_properties; 93 Vector<CSSPropertyID> native_invalidation_properties;
94 Vector<AtomicString> custom_invalidation_properties; 94 Vector<AtomicString> custom_invalidation_properties;
95 95
96 if (!IsUndefinedOrNull(input_properties_value)) { 96 if (!IsUndefinedOrNull(input_properties_value)) {
97 Vector<String> properties = 97 Vector<String> properties =
98 NativeValueTraits<IDLSequence<IDLString>>::NativeValue( 98 NativeValueTraits<IDLSequence<IDLString>>::NativeValue(
99 isolate, input_properties_value, exception_state); 99 isolate, input_properties_value, exception_state);
100 100
101 if (exception_state.HadException()) 101 if (exception_state.HadException())
102 return; 102 return;
103 103
104 for (const auto& property : properties) { 104 for (const auto& property : properties) {
105 CSSPropertyID property_id = cssPropertyID(property); 105 CSSPropertyID property_id = cssPropertyID(property);
106 if (property_id == CSSPropertyVariable) { 106 if (property_id == CSSPropertyVariable) {
107 custom_invalidation_properties.push_back(property); 107 custom_invalidation_properties.push_back(property);
108 } else if (property_id != CSSPropertyInvalid) { 108 } else if (property_id != CSSPropertyInvalid) {
109 native_invalidation_properties.push_back(property_id); 109 native_invalidation_properties.push_back(property_id);
110 } 110 }
111 } 111 }
112 } 112 }
113 113
114 // Get input argument types. Parse the argument type values only when 114 // Get input argument types. Parse the argument type values only when
115 // cssPaintAPIArguments is enabled. 115 // cssPaintAPIArguments is enabled.
116 Vector<CSSSyntaxDescriptor> input_argument_types; 116 Vector<CSSSyntaxDescriptor> input_argument_types;
117 if (RuntimeEnabledFeatures::cssPaintAPIArgumentsEnabled()) { 117 if (RuntimeEnabledFeatures::cssPaintAPIArgumentsEnabled()) {
118 v8::Local<v8::Value> input_argument_type_values; 118 v8::Local<v8::Value> input_argument_type_values;
119 if (!V8Call(constructor->Get(context, V8String(isolate, "inputArguments")), 119 if (!constructor->Get(context, V8String(isolate, "inputArguments"))
120 input_argument_type_values)) 120 .ToLocal(&input_argument_type_values))
121 return; 121 return;
122 122
123 if (!IsUndefinedOrNull(input_argument_type_values)) { 123 if (!IsUndefinedOrNull(input_argument_type_values)) {
124 Vector<String> argument_types = 124 Vector<String> argument_types =
125 NativeValueTraits<IDLSequence<IDLString>>::NativeValue( 125 NativeValueTraits<IDLSequence<IDLString>>::NativeValue(
126 isolate, input_argument_type_values, exception_state); 126 isolate, input_argument_type_values, exception_state);
127 127
128 if (exception_state.HadException()) 128 if (exception_state.HadException())
129 return; 129 return;
130 130
131 for (const auto& type : argument_types) { 131 for (const auto& type : argument_types) {
132 CSSSyntaxDescriptor syntax_descriptor(type); 132 CSSSyntaxDescriptor syntax_descriptor(type);
133 if (!syntax_descriptor.IsValid()) { 133 if (!syntax_descriptor.IsValid()) {
134 exception_state.ThrowTypeError("Invalid argument types."); 134 exception_state.ThrowTypeError("Invalid argument types.");
135 return; 135 return;
136 } 136 }
137 input_argument_types.push_back(syntax_descriptor); 137 input_argument_types.push_back(syntax_descriptor);
138 } 138 }
139 } 139 }
140 } 140 }
141 141
142 // Parse 'alpha' AKA hasAlpha property. 142 // Parse 'alpha' AKA hasAlpha property.
143 v8::Local<v8::Value> alpha_value; 143 v8::Local<v8::Value> alpha_value;
144 if (!V8Call(constructor->Get(context, V8String(isolate, "alpha")), 144 if (!constructor->Get(context, V8String(isolate, "alpha"))
145 alpha_value)) 145 .ToLocal(&alpha_value))
146 return; 146 return;
147 if (!IsUndefinedOrNull(alpha_value) && !alpha_value->IsBoolean()) { 147 if (!IsUndefinedOrNull(alpha_value) && !alpha_value->IsBoolean()) {
148 exception_state.ThrowTypeError( 148 exception_state.ThrowTypeError(
149 "The 'alpha' property on the class is not a boolean."); 149 "The 'alpha' property on the class is not a boolean.");
150 return; 150 return;
151 } 151 }
152 bool has_alpha = alpha_value->IsBoolean() 152 bool has_alpha = alpha_value->IsBoolean()
153 ? v8::Local<v8::Boolean>::Cast(alpha_value)->Value() 153 ? v8::Local<v8::Boolean>::Cast(alpha_value)->Value()
154 : true; 154 : true;
155 155
156 v8::Local<v8::Value> prototype_value; 156 v8::Local<v8::Value> prototype_value;
157 if (!V8Call(constructor->Get(context, V8String(isolate, "prototype")), 157 if (!constructor->Get(context, V8String(isolate, "prototype"))
158 prototype_value)) 158 .ToLocal(&prototype_value))
159 return; 159 return;
160 160
161 if (IsUndefinedOrNull(prototype_value)) { 161 if (IsUndefinedOrNull(prototype_value)) {
162 exception_state.ThrowTypeError( 162 exception_state.ThrowTypeError(
163 "The 'prototype' object on the class does not exist."); 163 "The 'prototype' object on the class does not exist.");
164 return; 164 return;
165 } 165 }
166 166
167 if (!prototype_value->IsObject()) { 167 if (!prototype_value->IsObject()) {
168 exception_state.ThrowTypeError( 168 exception_state.ThrowTypeError(
169 "The 'prototype' property on the class is not an object."); 169 "The 'prototype' property on the class is not an object.");
170 return; 170 return;
171 } 171 }
172 172
173 v8::Local<v8::Object> prototype = 173 v8::Local<v8::Object> prototype =
174 v8::Local<v8::Object>::Cast(prototype_value); 174 v8::Local<v8::Object>::Cast(prototype_value);
175 175
176 v8::Local<v8::Value> paint_value; 176 v8::Local<v8::Value> paint_value;
177 if (!V8Call(prototype->Get(context, V8String(isolate, "paint")), paint_value)) 177 if (!prototype->Get(context, V8String(isolate, "paint"))
178 .ToLocal(&paint_value))
178 return; 179 return;
179 180
180 if (IsUndefinedOrNull(paint_value)) { 181 if (IsUndefinedOrNull(paint_value)) {
181 exception_state.ThrowTypeError( 182 exception_state.ThrowTypeError(
182 "The 'paint' function on the prototype does not exist."); 183 "The 'paint' function on the prototype does not exist.");
183 return; 184 return;
184 } 185 }
185 186
186 if (!paint_value->IsFunction()) { 187 if (!paint_value->IsFunction()) {
187 exception_state.ThrowTypeError( 188 exception_state.ThrowTypeError(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 set->insert(generator); 225 set->insert(generator);
225 } 226 }
226 227
227 DEFINE_TRACE(PaintWorkletGlobalScope) { 228 DEFINE_TRACE(PaintWorkletGlobalScope) {
228 visitor->Trace(paint_definitions_); 229 visitor->Trace(paint_definitions_);
229 visitor->Trace(pending_generators_); 230 visitor->Trace(pending_generators_);
230 MainThreadWorkletGlobalScope::Trace(visitor); 231 MainThreadWorkletGlobalScope::Trace(visitor);
231 } 232 }
232 233
233 } // namespace blink 234 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/crypto/CryptoResultImpl.cpp ('k') | third_party/WebKit/Source/modules/fetch/Body.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698