| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 86 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 87 {% endif %} | 87 {% endif %} |
| 88 {% endif %} | 88 {% endif %} |
| 89 {% if attribute.is_getter_raises_exception %} | 89 {% if attribute.is_getter_raises_exception %} |
| 90 {{define_exception_state}} | 90 {{define_exception_state}} |
| 91 {% endif %} | 91 {% endif %} |
| 92 {% if attribute.is_explicit_nullable %} | 92 {% if attribute.is_explicit_nullable %} |
| 93 bool isNull = false; | 93 bool isNull = false; |
| 94 {% endif %} | 94 {% endif %} |
| 95 | 95 |
| 96 {% if attribute.is_implemented_in_private_script %} | 96 {% if attribute.cpp_value_original %} |
| 97 {{attribute.cpp_type}} result{{attribute.cpp_type_initializer}}; | |
| 98 if (!{{attribute.cpp_value_original}}) | |
| 99 return; | |
| 100 {% elif attribute.cpp_value_original %} | |
| 101 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_original}
}); | 97 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_original}
}); |
| 102 {% endif %} | 98 {% endif %} |
| 103 | 99 |
| 104 {% if attribute.use_output_parameter_for_result %} | 100 {% if attribute.use_output_parameter_for_result %} |
| 105 {{attribute.cpp_type}} result; | 101 {{attribute.cpp_type}} result; |
| 106 {{attribute.cpp_value}}; | 102 {{attribute.cpp_value}}; |
| 107 {% endif %} | 103 {% endif %} |
| 108 | 104 |
| 109 {% if attribute.is_getter_raises_exception %} | 105 {% if attribute.is_getter_raises_exception %} |
| 110 if (UNLIKELY(exceptionState.hadException())) | 106 if (UNLIKELY(exceptionState.hadException())) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 188 |
| 193 {##############################################################################} | 189 {##############################################################################} |
| 194 {% macro attribute_getter_callback(attribute, world_suffix) %} | 190 {% macro attribute_getter_callback(attribute, world_suffix) %} |
| 195 void {{attribute.name}}AttributeGetterCallback{{world_suffix}}( | 191 void {{attribute.name}}AttributeGetterCallback{{world_suffix}}( |
| 196 {%- if attribute.is_data_type_property %} | 192 {%- if attribute.is_data_type_property %} |
| 197 v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info | 193 v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info |
| 198 {%- else %} | 194 {%- else %} |
| 199 const v8::FunctionCallbackInfo<v8::Value>& info | 195 const v8::FunctionCallbackInfo<v8::Value>& info |
| 200 {%- endif %}) { | 196 {%- endif %}) { |
| 201 {% if attribute.deprecate_as %} | 197 {% if attribute.deprecate_as %} |
| 202 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentExec
utionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); | 198 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC
ounter::{{attribute.deprecate_as}}); |
| 203 {% endif %} | 199 {% endif %} |
| 204 | 200 |
| 205 {% if attribute.measure_as %} | 201 {% if attribute.measure_as %} |
| 206 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionContext
(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeGetter')}}); | 202 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{at
tribute.measure_as('AttributeGetter')}}); |
| 207 {% endif %} | 203 {% endif %} |
| 208 | 204 |
| 209 {% if world_suffix in attribute.activity_logging_world_list_for_getter %} | 205 {% if world_suffix in attribute.activity_logging_world_list_for_getter %} |
| 210 {% if attribute.is_static %} | 206 {% if attribute.is_static %} |
| 211 ScriptState* scriptState = ScriptState::forFunctionObject(info); | 207 ScriptState* scriptState = ScriptState::forFunctionObject(info); |
| 212 {% else %} | 208 {% else %} |
| 213 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 209 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 214 {% endif %} | 210 {% endif %} |
| 215 V8PerContextData* contextData = scriptState->perContextData(); | 211 V8PerContextData* contextData = scriptState->perContextData(); |
| 216 if ( | 212 if ( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 237 { | 233 { |
| 238 return V8PrivateProperty::get{{attribute.cached_accessor_name}}(isolate).get
Private(); | 234 return V8PrivateProperty::get{{attribute.cached_accessor_name}}(isolate).get
Private(); |
| 239 } | 235 } |
| 240 {% endmacro %} | 236 {% endmacro %} |
| 241 | 237 |
| 242 | 238 |
| 243 {##############################################################################} | 239 {##############################################################################} |
| 244 {% macro constructor_getter_callback(attribute, world_suffix) %} | 240 {% macro constructor_getter_callback(attribute, world_suffix) %} |
| 245 void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Local<v8::N
ame> property, const v8::PropertyCallbackInfo<v8::Value>& info) { | 241 void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Local<v8::N
ame> property, const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 246 {% if attribute.deprecate_as %} | 242 {% if attribute.deprecate_as %} |
| 247 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentExec
utionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); | 243 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC
ounter::{{attribute.deprecate_as}}); |
| 248 {% endif %} | 244 {% endif %} |
| 249 | 245 |
| 250 {% if attribute.measure_as %} | 246 {% if attribute.measure_as %} |
| 251 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionContext
(info.GetIsolate()), UseCounter::{{attribute.measure_as('ConstructorGetter')}}); | 247 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{at
tribute.measure_as('ConstructorGetter')}}); |
| 252 {% endif %} | 248 {% endif %} |
| 253 | 249 |
| 254 v8ConstructorAttributeGetter(property, info); | 250 v8ConstructorAttributeGetter(property, info); |
| 255 } | 251 } |
| 256 {% endmacro %} | 252 {% endmacro %} |
| 257 | 253 |
| 258 | 254 |
| 259 {##############################################################################} | 255 {##############################################################################} |
| 260 {% macro attribute_setter(attribute, world_suffix) %} | 256 {% macro attribute_setter(attribute, world_suffix) %} |
| 261 static void {{attribute.name}}AttributeSetter{{world_suffix}}( | 257 static void {{attribute.name}}AttributeSetter{{world_suffix}}( |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 {%- if attribute.is_data_type_property %} | 370 {%- if attribute.is_data_type_property %} |
| 375 v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInf
o<void>& info | 371 v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInf
o<void>& info |
| 376 {%- else %} | 372 {%- else %} |
| 377 const v8::FunctionCallbackInfo<v8::Value>& info | 373 const v8::FunctionCallbackInfo<v8::Value>& info |
| 378 {%- endif %}) { | 374 {%- endif %}) { |
| 379 {% if not attribute.is_data_type_property %} | 375 {% if not attribute.is_data_type_property %} |
| 380 v8::Local<v8::Value> v8Value = info[0]; | 376 v8::Local<v8::Value> v8Value = info[0]; |
| 381 {% endif %} | 377 {% endif %} |
| 382 | 378 |
| 383 {% if attribute.deprecate_as %} | 379 {% if attribute.deprecate_as %} |
| 384 Deprecation::countDeprecationIfNotPrivateScript(info.GetIsolate(), currentExec
utionContext(info.GetIsolate()), UseCounter::{{attribute.deprecate_as}}); | 380 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC
ounter::{{attribute.deprecate_as}}); |
| 385 {% endif %} | 381 {% endif %} |
| 386 | 382 |
| 387 {% if attribute.measure_as %} | 383 {% if attribute.measure_as %} |
| 388 UseCounter::countIfNotPrivateScript(info.GetIsolate(), currentExecutionContext
(info.GetIsolate()), UseCounter::{{attribute.measure_as('AttributeSetter')}}); | 384 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{at
tribute.measure_as('AttributeSetter')}}); |
| 389 {% endif %} | 385 {% endif %} |
| 390 | 386 |
| 391 {% if world_suffix in attribute.activity_logging_world_list_for_setter %} | 387 {% if world_suffix in attribute.activity_logging_world_list_for_setter %} |
| 392 {% if attribute.is_static %} | 388 {% if attribute.is_static %} |
| 393 ScriptState* scriptState = ScriptState::forFunctionObject(info); | 389 ScriptState* scriptState = ScriptState::forFunctionObject(info); |
| 394 {% else %} | 390 {% else %} |
| 395 ScriptState* scriptState = ScriptState::forReceiverObject(info); | 391 ScriptState* scriptState = ScriptState::forReceiverObject(info); |
| 396 {% endif %} | 392 {% endif %} |
| 397 V8PerContextData* contextData = scriptState->perContextData(); | 393 V8PerContextData* contextData = scriptState->perContextData(); |
| 398 if ( | 394 if ( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 417 {% elif attribute.has_cross_origin_setter %} | 413 {% elif attribute.has_cross_origin_setter %} |
| 418 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter(v8Value,
V8CrossOriginSetterInfo(info.GetIsolate(), info.Holder())); | 414 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter(v8Value,
V8CrossOriginSetterInfo(info.GetIsolate(), info.Holder())); |
| 419 {% else %} | 415 {% else %} |
| 420 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter{{world_s
uffix}}(v8Value, info); | 416 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter{{world_s
uffix}}(v8Value, info); |
| 421 {% endif %} | 417 {% endif %} |
| 422 } | 418 } |
| 423 {% endmacro %} | 419 {% endmacro %} |
| 424 | 420 |
| 425 | 421 |
| 426 {##############################################################################} | 422 {##############################################################################} |
| 427 {% macro attribute_getter_implemented_in_private_script(attribute) %} | |
| 428 bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeGetter(LocalFrame*
frame, {{cpp_class}}* holderImpl, {{attribute.cpp_type}}* result) { | |
| 429 if (!frame) | |
| 430 return false; | |
| 431 v8::HandleScope handleScope(toIsolate(frame)); | |
| 432 ScriptForbiddenScope::AllowUserAgentScript script; | |
| 433 ScriptState* scriptState = ScriptState::forWorld(frame, DOMWrapperWorld::priva
teScriptIsolatedWorld()); | |
| 434 if (!scriptState) | |
| 435 return false; | |
| 436 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); | |
| 437 if (!scriptStateInUserScript) | |
| 438 return false; | |
| 439 | |
| 440 ScriptState::Scope scope(scriptState); | |
| 441 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Global(
), scriptState->isolate()); | |
| 442 ExceptionState exceptionState(scriptState->isolate(), ExceptionState::GetterCo
ntext, "{{cpp_class}}", "{{attribute.name}}"); | |
| 443 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(scri
ptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holder)
; | |
| 444 if (v8Value.IsEmpty()) | |
| 445 return false; | |
| 446 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp_v
alue) | indent(2)}} | |
| 447 CHECK(!exceptionState.hadException()); | |
| 448 *result = cppValue; | |
| 449 return true; | |
| 450 } | |
| 451 {% endmacro %} | |
| 452 | |
| 453 | |
| 454 {% macro attribute_setter_implemented_in_private_script(attribute) %} | |
| 455 bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame*
frame, {{cpp_class}}* holderImpl, {{attribute.argument_cpp_type}} cppValue) { | |
| 456 if (!frame) | |
| 457 return false; | |
| 458 v8::HandleScope handleScope(toIsolate(frame)); | |
| 459 ScriptForbiddenScope::AllowUserAgentScript script; | |
| 460 ScriptState* scriptState = ScriptState::forWorld(frame, DOMWrapperWorld::priva
teScriptIsolatedWorld()); | |
| 461 if (!scriptState) | |
| 462 return false; | |
| 463 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); | |
| 464 if (!scriptStateInUserScript) | |
| 465 return false; | |
| 466 | |
| 467 ScriptState::Scope scope(scriptState); | |
| 468 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Global(
), scriptState->isolate()); | |
| 469 ExceptionState exceptionState(scriptState->isolate(), ExceptionState::SetterCo
ntext, "{{cpp_class}}", "{{attribute.name}}"); | |
| 470 return PrivateScriptRunner::runDOMAttributeSetter(scriptState, scriptStateInUs
erScript, "{{cpp_class}}", "{{attribute.name}}", holder, {{attribute.private_scr
ipt_cpp_value_to_v8_value}}); | |
| 471 } | |
| 472 {% endmacro %} | |
| 473 | |
| 474 | |
| 475 {##############################################################################} | |
| 476 {% macro attribute_configuration(attribute) %} | 423 {% macro attribute_configuration(attribute) %} |
| 477 {% from 'utilities.cpp.tmpl' import property_location %} | 424 {% from 'utilities.cpp.tmpl' import property_location %} |
| 478 {% if attribute.constructor_type %} | 425 {% if attribute.constructor_type %} |
| 479 {% set getter_callback = | 426 {% set getter_callback = |
| 480 '%sV8Internal::%sConstructorGetterCallback' % (cpp_class_or_partial, attr
ibute.name) | 427 '%sV8Internal::%sConstructorGetterCallback' % (cpp_class_or_partial, attr
ibute.name) |
| 481 if attribute.needs_constructor_getter_callback else | 428 if attribute.needs_constructor_getter_callback else |
| 482 'v8ConstructorAttributeGetter' %} | 429 'v8ConstructorAttributeGetter' %} |
| 483 {% set setter_callback = '0' %} | 430 {% set setter_callback = '0' %} |
| 484 {% else %}{# regular attributes #} | 431 {% else %}{# regular attributes #} |
| 485 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' % | 432 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' % |
| (...skipping 13 matching lines...) Expand all Loading... |
| 499 attribute.constructor_type | 446 attribute.constructor_type |
| 500 if attribute.constructor_type else '0' %} | 447 if attribute.constructor_type else '0' %} |
| 501 {% if attribute.is_data_type_property %} | 448 {% if attribute.is_data_type_property %} |
| 502 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % | 449 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % |
| 503 ' | '.join(attribute.access_control_list) %} | 450 ' | '.join(attribute.access_control_list) %} |
| 504 {% else %} | 451 {% else %} |
| 505 {% set access_control = 'v8::DEFAULT' %} | 452 {% set access_control = 'v8::DEFAULT' %} |
| 506 {% endif %} | 453 {% endif %} |
| 507 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % | 454 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % |
| 508 ' | '.join(attribute.property_attributes) %} | 455 ' | '.join(attribute.property_attributes) %} |
| 509 {% set only_exposed_to_private_script = | |
| 510 'V8DOMConfiguration::OnlyExposedToPrivateScript' | |
| 511 if attribute.only_exposed_to_private_script else | |
| 512 'V8DOMConfiguration::ExposedToAllScripts' %} | |
| 513 {% set cached_accessor_callback = | 456 {% set cached_accessor_callback = |
| 514 '%sV8Internal::%sCachedAccessorCallback' % (cpp_class_or_partial, attribu
te.name) | 457 '%sV8Internal::%sCachedAccessorCallback' % (cpp_class_or_partial, attribu
te.name) |
| 515 if attribute.is_cached_accessor else | 458 if attribute.is_cached_accessor else |
| 516 'nullptr' %} | 459 'nullptr' %} |
| 517 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' | 460 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' |
| 518 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %} | 461 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %} |
| 519 {% set attribute_configuration_list = [ | 462 {% set attribute_configuration_list = [ |
| 520 '"%s"' % attribute.name, | 463 '"%s"' % attribute.name, |
| 521 getter_callback, | 464 getter_callback, |
| 522 setter_callback, | 465 setter_callback, |
| 523 getter_callback_for_main_world, | 466 getter_callback_for_main_world, |
| 524 setter_callback_for_main_world, | 467 setter_callback_for_main_world, |
| 525 cached_accessor_callback, | 468 cached_accessor_callback, |
| 526 wrapper_type_info, | 469 wrapper_type_info, |
| 527 access_control, | 470 access_control, |
| 528 property_attribute, | 471 property_attribute, |
| 529 only_exposed_to_private_script, | |
| 530 property_location(attribute), | 472 property_location(attribute), |
| 531 holder_check, | 473 holder_check, |
| 532 ] %} | 474 ] %} |
| 533 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} | 475 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} |
| 534 {%- endmacro %} | 476 {%- endmacro %} |
| OLD | NEW |