| OLD | NEW |
| 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t
o_local_cpp_value %} | 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t
o_local_cpp_value %} |
| 2 | 2 |
| 3 {##############################################################################} | 3 {##############################################################################} |
| 4 {% macro attribute_getter(attribute, world_suffix) %} | 4 {% macro attribute_getter(attribute, world_suffix) %} |
| 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( | 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( |
| 6 {%- if attribute.is_data_type_property %} | 6 {%- if attribute.is_data_type_property %} |
| 7 const v8::PropertyCallbackInfo<v8::Value>& info | 7 const v8::PropertyCallbackInfo<v8::Value>& info |
| 8 {%- else %} | 8 {%- else %} |
| 9 const v8::FunctionCallbackInfo<v8::Value>& info | 9 const v8::FunctionCallbackInfo<v8::Value>& info |
| 10 {%- endif %}) { | 10 {%- endif %}) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // safe to downcast here. | 53 // safe to downcast here. |
| 54 LocalDOMWindow* impl = toLocalDOMWindow({{v8_class}}::toImpl(holder)); | 54 LocalDOMWindow* impl = toLocalDOMWindow({{v8_class}}::toImpl(holder)); |
| 55 {% endif %}{# attribute.is_check_security_for_receiver #} | 55 {% endif %}{# attribute.is_check_security_for_receiver #} |
| 56 {% else %} | 56 {% else %} |
| 57 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 57 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
| 58 {% endif %}{# local_dom_window_only #} | 58 {% endif %}{# local_dom_window_only #} |
| 59 {% endif %}{# not attribute.is_static #} | 59 {% endif %}{# not attribute.is_static #} |
| 60 | 60 |
| 61 {% if attribute.cached_attribute_validation_method %} | 61 {% if attribute.cached_attribute_validation_method %} |
| 62 // [CachedAttribute] | 62 // [CachedAttribute] |
| 63 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attr
ibute.name}}"); | 63 V8PrivateProperty::Symbol propertySymbol = |
| 64 V8PrivateProperty::getSymbol(info.GetIsolate(), |
| 65 "{{cpp_class}}#{{attribute.name.capitalize()}}"); |
| 64 if (!impl->{{attribute.cached_attribute_validation_method}}()) { | 66 if (!impl->{{attribute.cached_attribute_validation_method}}()) { |
| 65 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState::fo
rFunctionObject(info), holder, propertyName); | 67 v8::Local<v8::Value> v8Value = propertySymbol.getOrUndefined(holder); |
| 66 if (!v8Value.IsEmpty() && !v8Value->IsUndefined()) { | 68 if (!v8Value->IsUndefined()) { |
| 67 v8SetReturnValue(info, v8Value); | 69 v8SetReturnValue(info, v8Value); |
| 68 return; | 70 return; |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 {% endif %} | 73 {% endif %} |
| 72 | 74 |
| 73 {% if attribute.is_check_security_for_receiver and not attribute.is_data_type_
property %} | 75 {% if attribute.is_check_security_for_receiver and not attribute.is_data_type_
property %} |
| 74 // Perform a security check for the receiver object. | 76 // Perform a security check for the receiver object. |
| 75 {{define_exception_state}} | 77 {{define_exception_state}} |
| 76 {% if local_dom_window_only %} | 78 {% if local_dom_window_only %} |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 {% if attribute.reflect_only %} | 131 {% if attribute.reflect_only %} |
| 130 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, | 132 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, |
| 131 attribute.reflect_invalid, attribute.reflect_empty, | 133 attribute.reflect_invalid, attribute.reflect_empty, |
| 132 attribute.cpp_value) | 134 attribute.cpp_value) |
| 133 | indent(2)}} | 135 | indent(2)}} |
| 134 {% endif %} | 136 {% endif %} |
| 135 | 137 |
| 136 {% if attribute.cached_attribute_validation_method %} | 138 {% if attribute.cached_attribute_validation_method %} |
| 137 // [CachedAttribute] | 139 // [CachedAttribute] |
| 138 v8::Local<v8::Value> v8Value({{attribute.cpp_value_to_v8_value}}); | 140 v8::Local<v8::Value> v8Value({{attribute.cpp_value_to_v8_value}}); |
| 139 V8HiddenValue::setHiddenValue(ScriptState::forFunctionObject(info), holder, pr
opertyName, v8Value); | 141 propertySymbol.set(holder, v8Value); |
| 140 {% endif %} | 142 {% endif %} |
| 141 | 143 |
| 142 {% if attribute.is_explicit_nullable %} | 144 {% if attribute.is_explicit_nullable %} |
| 143 if (isNull) { | 145 if (isNull) { |
| 144 v8SetReturnValueNull(info); | 146 v8SetReturnValueNull(info); |
| 145 return; | 147 return; |
| 146 } | 148 } |
| 147 {% endif %} | 149 {% endif %} |
| 148 | 150 |
| 149 {% if attribute.is_keep_alive_for_gc %} | 151 {% if attribute.is_keep_alive_for_gc %} |
| 150 // Keep the wrapper object for the return value alive as long as |this| | 152 // Keep the wrapper object for the return value alive as long as |this| |
| 151 // object is alive in order to save creation time of the wrapper object. | 153 // object is alive in order to save creation time of the wrapper object. |
| 152 if ({{attribute.cpp_value}} && DOMDataStore::setReturnValue{{world_suffix}}(in
fo.GetReturnValue(), {{attribute.cpp_value}})) | 154 if ({{attribute.cpp_value}} && DOMDataStore::setReturnValue{{world_suffix}}(in
fo.GetReturnValue(), {{attribute.cpp_value}})) |
| 153 return; | 155 return; |
| 154 v8::Local<v8::Value> v8Value(ToV8({{attribute.cpp_value}}, holder, info.GetIso
late())); | 156 v8::Local<v8::Value> v8Value(ToV8({{attribute.cpp_value}}, holder, info.GetIso
late())); |
| 155 V8HiddenValue::setHiddenValue(ScriptState::current(info.GetIsolate()), holder,
v8AtomicString(info.GetIsolate(), "KeepAlive#{{interface_name}}#{{attribute.nam
e}}"), v8Value); | 157 V8PrivateProperty::getSymbol( |
| 158 info.GetIsolate(), "KeepAlive#{{interface_name}}#{{attribute.name}}") |
| 159 .set(holder, v8Value); |
| 156 {% endif %} | 160 {% endif %} |
| 157 | 161 |
| 158 {% if world_suffix %} | 162 {% if world_suffix %} |
| 159 {{attribute.v8_set_return_value_for_main_world}}; | 163 {{attribute.v8_set_return_value_for_main_world}}; |
| 160 {% else %} | 164 {% else %} |
| 161 {{attribute.v8_set_return_value}}; | 165 {{attribute.v8_set_return_value}}; |
| 162 {% endif %} | 166 {% endif %} |
| 163 | 167 |
| 164 {% if attribute.is_save_same_object %} | 168 {% if attribute.is_save_same_object %} |
| 165 // [SaveSameObject] | 169 // [SaveSameObject] |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 {% macro attribute_setter(attribute, world_suffix) %} | 278 {% macro attribute_setter(attribute, world_suffix) %} |
| 275 static void {{attribute.name}}AttributeSetter{{world_suffix}}( | 279 static void {{attribute.name}}AttributeSetter{{world_suffix}}( |
| 276 {%- if attribute.has_cross_origin_setter %} | 280 {%- if attribute.has_cross_origin_setter %} |
| 277 v8::Local<v8::Value> v8Value, const V8CrossOriginSetterInfo& info | 281 v8::Local<v8::Value> v8Value, const V8CrossOriginSetterInfo& info |
| 278 {%- elif attribute.is_data_type_property %} | 282 {%- elif attribute.is_data_type_property %} |
| 279 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info | 283 v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info |
| 280 {%- else %} | 284 {%- else %} |
| 281 v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info | 285 v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info |
| 282 {%- endif %}) { | 286 {%- endif %}) { |
| 283 {% filter format_remove_duplicates(['ExceptionState exceptionState']) %} | 287 {% filter format_remove_duplicates(['ExceptionState exceptionState']) %} |
| 288 v8::Isolate* isolate = info.GetIsolate(); |
| 289 ALLOW_UNUSED_LOCAL(isolate); |
| 290 |
| 284 {% set define_exception_state -%} | 291 {% set define_exception_state -%} |
| 285 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::SetterContext
, "{{interface_name}}", "{{attribute.name}}"); | 292 ExceptionState exceptionState(isolate, ExceptionState::SetterContext, "{{inter
face_name}}", "{{attribute.name}}"); |
| 286 {%- endset %} | 293 {%- endset %} |
| 287 | 294 |
| 288 {% if attribute.is_lenient_this %} | 295 {% if attribute.is_lenient_this %} |
| 289 // [LenientThis] | 296 // [LenientThis] |
| 290 // Make sure that info.Holder() really points to an instance if [LenientThis]. | 297 // Make sure that info.Holder() really points to an instance if [LenientThis]. |
| 291 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) | 298 if (!{{v8_class}}::hasInstance(info.Holder(), isolate)) |
| 292 return; // Return silently because of [LenientThis]. | 299 return; // Return silently because of [LenientThis]. |
| 293 {% endif %} | 300 {% endif %} |
| 294 | 301 |
| 295 {% if not attribute.is_static and not attribute.is_replaceable %} | 302 {% if not attribute.is_static and not attribute.is_replaceable %} |
| 296 v8::Local<v8::Object> holder = info.Holder(); | 303 v8::Local<v8::Object> holder = info.Holder(); |
| 297 {% if attribute.is_put_forwards %} | 304 {% if attribute.is_put_forwards %} |
| 298 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); | 305 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); |
| 299 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); | 306 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); |
| 300 if (!impl) | 307 if (!impl) |
| 301 return; | 308 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 313 {% else %} | 320 {% else %} |
| 314 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 321 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
| 315 {% endif %}{# local_dom_window_only #} | 322 {% endif %}{# local_dom_window_only #} |
| 316 {% endif %} | 323 {% endif %} |
| 317 {% endif %} | 324 {% endif %} |
| 318 | 325 |
| 319 {% if attribute.is_check_security_for_receiver and not attribute.is_data_type_
property %} | 326 {% if attribute.is_check_security_for_receiver and not attribute.is_data_type_
property %} |
| 320 // Perform a security check for the receiver object. | 327 // Perform a security check for the receiver object. |
| 321 {{define_exception_state}} | 328 {{define_exception_state}} |
| 322 {% if local_dom_window_only %} | 329 {% if local_dom_window_only %} |
| 323 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()),
uncheckedImpl, exceptionState)) { | 330 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(isolate), unchecked
Impl, exceptionState)) { |
| 324 {% else %} | 331 {% else %} |
| 325 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()),
impl, exceptionState)) { | 332 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(isolate), impl, exc
eptionState)) { |
| 326 {% endif %}{# local_dom_window_only #} | 333 {% endif %}{# local_dom_window_only #} |
| 327 v8SetReturnValue(info, v8Value); | 334 v8SetReturnValue(info, v8Value); |
| 328 return; | 335 return; |
| 329 } | 336 } |
| 330 {% if local_dom_window_only %} | 337 {% if local_dom_window_only %} |
| 331 LocalDOMWindow* impl = toLocalDOMWindow(uncheckedImpl); | 338 LocalDOMWindow* impl = toLocalDOMWindow(uncheckedImpl); |
| 332 {% endif %}{# local_dom_window_only #} | 339 {% endif %}{# local_dom_window_only #} |
| 333 {% endif %} | 340 {% endif %} |
| 334 | 341 |
| 335 {% if attribute.is_check_security_for_return_value %} | 342 {% if attribute.is_check_security_for_return_value %} |
| 336 #error Attribute setter with the security check for the return value is not supp
orted. Since the return value is the given value to be set, it\'s meaningless t
o perform the security check for the return value. | 343 #error Attribute setter with the security check for the return value is not supp
orted. Since the return value is the given value to be set, it\'s meaningless t
o perform the security check for the return value. |
| 337 {% endif %} | 344 {% endif %} |
| 338 | 345 |
| 339 {% if attribute.is_custom_element_callbacks or | 346 {% if attribute.is_custom_element_callbacks or |
| 340 (attribute.is_reflect and not (attribute.idl_type == 'DOMString' and is_
node)) %} | 347 (attribute.is_reflect and not (attribute.idl_type == 'DOMString' and is_
node)) %} |
| 341 // Skip on compact node DOMString getters. | 348 // Skip on compact node DOMString getters. |
| 342 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; | 349 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; |
| 343 {% endif %} | 350 {% endif %} |
| 344 | 351 |
| 345 {% if attribute.has_setter_exception_state %} | 352 {% if attribute.has_setter_exception_state %} |
| 346 {{define_exception_state}} | 353 {{define_exception_state}} |
| 347 {% endif %} | 354 {% endif %} |
| 348 | 355 |
| 349 // Prepare the value to be set. | 356 // Prepare the value to be set. |
| 350 {% if attribute.idl_type == 'EventHandler' %} | 357 {% if attribute.idl_type == 'EventHandler' %} |
| 351 {% if not is_node %} | 358 {% if not is_node %} |
| 352 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_han
dler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); | 359 moveEventListenerToNewWrapper(isolate, holder, {{attribute.event_handler_gette
r_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); |
| 353 {% endif %} | 360 {% endif %} |
| 354 {% else %}{# not EventHandler #} | 361 {% else %}{# not EventHandler #} |
| 355 {{v8_value_to_local_cpp_value(attribute) | indent(2)}} | 362 {{v8_value_to_local_cpp_value(attribute) | indent(2)}} |
| 356 {% endif %} | 363 {% endif %} |
| 357 | 364 |
| 358 {% if attribute.has_type_checking_interface %} | 365 {% if attribute.has_type_checking_interface %} |
| 359 // Type check per: http://heycam.github.io/webidl/#es-interface | 366 // Type check per: http://heycam.github.io/webidl/#es-interface |
| 360 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% e
ndif %}) { | 367 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% e
ndif %}) { |
| 361 exceptionState.throwTypeError("The provided value is not of type '{{attribut
e.idl_type}}'."); | 368 exceptionState.throwTypeError("The provided value is not of type '{{attribut
e.idl_type}}'."); |
| 362 return; | 369 return; |
| 363 } | 370 } |
| 364 {% endif %} | 371 {% endif %} |
| 365 | 372 |
| 366 {% if attribute.enum_values %} | 373 {% if attribute.enum_values %} |
| 367 // Type check per: http://heycam.github.io/webidl/#dfn-attribute-setter | 374 // Type check per: http://heycam.github.io/webidl/#dfn-attribute-setter |
| 368 // Returns undefined without setting the value if the value is invalid. | 375 // Returns undefined without setting the value if the value is invalid. |
| 369 DummyExceptionStateForTesting dummyExceptionState; | 376 DummyExceptionStateForTesting dummyExceptionState; |
| 370 {{declare_enum_validation_variable(attribute.enum_values) | indent(2)}} | 377 {{declare_enum_validation_variable(attribute.enum_values) | indent(2)}} |
| 371 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{attr
ibute.enum_type}}", dummyExceptionState)) { | 378 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), "{{attr
ibute.enum_type}}", dummyExceptionState)) { |
| 372 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMessage
::create(JSMessageSource, WarningMessageLevel, dummyExceptionState.message())); | 379 currentExecutionContext(isolate)->addConsoleMessage(ConsoleMessage::create(J
SMessageSource, WarningMessageLevel, dummyExceptionState.message())); |
| 373 return; | 380 return; |
| 374 } | 381 } |
| 375 {% endif %} | 382 {% endif %} |
| 376 | 383 |
| 377 {% if attribute.is_call_with_execution_context or attribute.is_setter_call_wit
h_execution_context %} | 384 {% if attribute.is_call_with_execution_context or attribute.is_setter_call_wit
h_execution_context %} |
| 378 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()
); | 385 ExecutionContext* executionContext = currentExecutionContext(isolate); |
| 379 {% endif %} | 386 {% endif %} |
| 380 | 387 |
| 381 {% if attribute.is_call_with_script_state %} | 388 {% if attribute.is_call_with_script_state %} |
| 382 {% if attribute.is_static %} | 389 {% if attribute.is_static %} |
| 383 ScriptState* scriptState = ScriptState::forFunctionObject(info); | 390 ScriptState* scriptState = ScriptState::forFunctionObject(info); |
| 384 {% else %} | 391 {% else %} |
| 385 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 392 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 386 {% endif %} | 393 {% endif %} |
| 387 {% endif %} | 394 {% endif %} |
| 388 | 395 |
| 389 {% if attribute.is_replaceable %} | 396 {% if attribute.is_replaceable %} |
| 390 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attr
ibute.name}}"); | 397 v8::Local<v8::String> propertyName = v8AtomicString(isolate, "{{attribute.name
}}"); |
| 391 {% endif %} | 398 {% endif %} |
| 392 {{attribute.cpp_setter}}; | 399 {{attribute.cpp_setter}}; |
| 393 | 400 |
| 394 {% if attribute.cached_attribute_validation_method %} | 401 {% if attribute.cached_attribute_validation_method %} |
| 395 // [CachedAttribute] | 402 // [CachedAttribute] |
| 396 // Invalidate the cached value. | 403 // Invalidate the cached value. Actually deleting the attribute would make |
| 397 V8HiddenValue::deleteHiddenValue(ScriptState::forFunctionObject(info), holder,
v8AtomicString(info.GetIsolate(), "{{attribute.name}}")); | 404 // force the object into dictionary mode which is unnecessarily slow. |
| 405 // Instead, we replace the cached value with "undefined". |
| 406 V8PrivateProperty::getSymbol( |
| 407 isolate, "{{cpp_class}}#{{attribute.name.capitalize()}}") |
| 408 .set(holder, v8::Undefined(isolate)); |
| 398 {% endif %} | 409 {% endif %} |
| 399 } | 410 } |
| 400 {% endfilter %}{# format_remove_duplicates #} | 411 {% endfilter %}{# format_remove_duplicates #} |
| 401 {% endmacro %} | 412 {% endmacro %} |
| 402 | 413 |
| 403 | 414 |
| 404 {##############################################################################} | 415 {##############################################################################} |
| 405 {% macro attribute_setter_callback(attribute, world_suffix) %} | 416 {% macro attribute_setter_callback(attribute, world_suffix) %} |
| 406 void {{v8_class_or_partial}}::{{attribute.name}}AttributeSetterCallback{{world_s
uffix}}( | 417 void {{v8_class_or_partial}}::{{attribute.name}}AttributeSetterCallback{{world_s
uffix}}( |
| 407 {%- if attribute.is_data_type_property %} | 418 {%- if attribute.is_data_type_property %} |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration[] =
{ | 517 static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration[] =
{ |
| 507 {{attribute_configuration(attribute)}} | 518 {{attribute_configuration(attribute)}} |
| 508 }; | 519 }; |
| 509 for (const auto& accessorConfig : accessorConfiguration) | 520 for (const auto& accessorConfig : accessorConfiguration) |
| 510 V8DOMConfiguration::installAccessor(isolate, world, v8::Local<v8::Object>(), p
rototypeObject, interfaceObject, signature, accessorConfig); | 521 V8DOMConfiguration::installAccessor(isolate, world, v8::Local<v8::Object>(), p
rototypeObject, interfaceObject, signature, accessorConfig); |
| 511 {% endfilter %}{# runtime_enabled #} | 522 {% endfilter %}{# runtime_enabled #} |
| 512 {% endfilter %}{# secure_context #} | 523 {% endfilter %}{# secure_context #} |
| 513 {% endfilter %}{# exposed #} | 524 {% endfilter %}{# exposed #} |
| 514 {% endfor %} | 525 {% endfor %} |
| 515 {% endmacro %} | 526 {% endmacro %} |
| OLD | NEW |