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 generate_method(method, world_suffix) %} | 4 {% macro generate_method(method, world_suffix) %} |
5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) { | 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) { |
6 {% filter format_remove_duplicates([ | 6 {% filter format_remove_duplicates([ |
7 'ExceptionState exceptionState', | 7 'ExceptionState exceptionState', |
8 'ScriptState* scriptState = ']) %} | 8 'ScriptState* scriptState = ']) %} |
9 {% set define_exception_state -%} | 9 {% set define_exception_state -%} |
10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont
ext, "{{interface_name}}", "{{method.name}}"); | 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont
ext, "{{interface_name}}", "{{method.name}}"); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 527 |
528 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe
mplate(world, &domTemplateKey, {{v8_class_or_partial}}::{{method.name}}MethodCal
lback{{world_suffix}}, v8Undefined(), signature, {{method.length}}); | 528 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe
mplate(world, &domTemplateKey, {{v8_class_or_partial}}::{{method.name}}MethodCal
lback{{world_suffix}}, v8Undefined(), signature, {{method.length}}); |
529 // Return the function by default, unless the user script has overwritten it. | 529 // Return the function by default, unless the user script has overwritten it. |
530 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre
ntContext()).ToLocalChecked()); | 530 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre
ntContext()).ToLocalChecked()); |
531 | 531 |
532 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 532 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
533 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()),
impl, BindingSecurity::ErrorReportOption::DoNotReport)) { | 533 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()),
impl, BindingSecurity::ErrorReportOption::DoNotReport)) { |
534 return; | 534 return; |
535 } | 535 } |
536 | 536 |
537 v8::Local<v8::Value> hiddenValue = V8HiddenValue::getHiddenValue(ScriptState::
current(info.GetIsolate()), v8::Local<v8::Object>::Cast(info.Holder()), v8Atomic
String(info.GetIsolate(), "{{method.name}}")); | 537 {% raw %} |
538 if (!hiddenValue.IsEmpty()) { | 538 // {{method.name}} must be same with |methodName| (=name) in |
539 v8SetReturnValue(info, hiddenValue); | 539 // {{cpp_class}}OriginSafeMethodSetter defined in interface.cpp.tmpl. |
| 540 {% endraw %} |
| 541 V8PrivateProperty::Symbol propertySymbol = |
| 542 V8PrivateProperty::getSymbol(info.GetIsolate(), "{{method.name}}"); |
| 543 v8::Local<v8::Object> holder = v8::Local<v8::Object>::Cast(info.Holder()); |
| 544 if (propertySymbol.hasValue(holder)) { |
| 545 v8SetReturnValue(info, propertySymbol.getOrUndefined(holder)); |
540 } | 546 } |
541 } | 547 } |
542 {% endmacro %} | 548 {% endmacro %} |
543 | 549 |
544 {% macro origin_safe_method_getter_callback(method, world_suffix) %} | 550 {% macro origin_safe_method_getter_callback(method, world_suffix) %} |
545 void {{v8_class_or_partial}}::{{method.name}}OriginSafeMethodGetterCallback{{wor
ld_suffix}}(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info
) { | 551 void {{v8_class_or_partial}}::{{method.name}}OriginSafeMethodGetterCallback{{wor
ld_suffix}}(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info
) { |
546 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix}}
(info); | 552 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix}}
(info); |
547 } | 553 } |
548 {% endmacro %} | 554 {% endmacro %} |
549 | 555 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 {{method_configuration(method) | indent(2)}} | 650 {{method_configuration(method) | indent(2)}} |
645 }; | 651 }; |
646 for (const auto& methodConfig : {{method.name}}MethodConfiguration) | 652 for (const auto& methodConfig : {{method.name}}MethodConfiguration) |
647 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), pro
totypeObject, interfaceObject, signature, methodConfig); | 653 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), pro
totypeObject, interfaceObject, signature, methodConfig); |
648 {% endfilter %}{# runtime_enabled() #} | 654 {% endfilter %}{# runtime_enabled() #} |
649 {% endfilter %}{# exposed() #} | 655 {% endfilter %}{# exposed() #} |
650 {% endfilter %}{# secure_context() #} | 656 {% endfilter %}{# secure_context() #} |
651 {% endfor %} | 657 {% endfor %} |
652 {% endif %} | 658 {% endif %} |
653 {%- endmacro %} | 659 {%- endmacro %} |
OLD | NEW |