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}}"); |
11 {%- endset %} | 11 {%- endset %} |
12 | 12 |
13 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %} | 13 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %} |
14 | 14 |
15 {% if 'exceptionState' in function_call or | 15 {% if 'exceptionState' in function_call or |
16 (method.returns_promise and not method.is_static) %} | 16 (method.returns_promise and not method.is_static) %} |
17 {{define_exception_state}} | 17 {{define_exception_state}} |
18 {% if method.returns_promise %} | 18 {% if method.returns_promise %} |
19 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState); | 19 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState); |
20 {% endif %} | 20 {% endif %} |
21 {% endif %} | 21 {% endif %} |
22 | 22 |
23 {% if not method.is_static %} | 23 {% if not method.is_static %} |
24 {% if method.returns_promise %} | 24 {% if method.returns_promise or (interface_name == 'Window' and method.is_cros
s_origin) %} |
25 // V8DOMConfiguration::DoNotCheckHolder | 25 // V8DOMConfiguration::DoNotCheckHolder |
26 // Make sure that info.Holder() really points to an instance of the type. | 26 // Make sure that info.Holder() really points to an instance of the type. |
27 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) { | 27 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) { |
28 {{throw_type_error(method, '"Illegal invocation"')}} | 28 {{throw_type_error(method, '"Illegal invocation"')}} |
29 return; | 29 return; |
30 } | 30 } |
31 {% endif %} | 31 {% endif %} |
32 {% set local_dom_window_only = interface_name == 'Window' and not method.is_cr
oss_origin %} | 32 {% set local_dom_window_only = interface_name == 'Window' and not method.is_cr
oss_origin %} |
33 {% if local_dom_window_only %} | 33 {% if local_dom_window_only %} |
34 {% if method.is_check_security_for_receiver %} | 34 {% if method.is_check_security_for_receiver %} |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 540 |
541 {##############################################################################} | 541 {##############################################################################} |
542 {% macro origin_safe_method_getter(method, world_suffix) %} | 542 {% macro origin_safe_method_getter(method, world_suffix) %} |
543 {# TODO(dcheng): Currently, bindings must create a function object for each | 543 {# TODO(dcheng): Currently, bindings must create a function object for each |
544 realm as a hack to support the incumbent realm. Clean this up when Blink | 544 realm as a hack to support the incumbent realm. Clean this up when Blink |
545 properly supports the incumbent realm. #} | 545 properly supports the incumbent realm. #} |
546 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop
ertyCallbackInfo<v8::Value>& info) { | 546 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop
ertyCallbackInfo<v8::Value>& info) { |
547 static int domTemplateKey; // This address is used for a key to look up the do
m template. | 547 static int domTemplateKey; // This address is used for a key to look up the do
m template. |
548 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); | 548 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); |
549 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu
rrentContext()); | 549 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu
rrentContext()); |
| 550 {% if interface_name == 'Window' %} |
| 551 // Note: signature is intentionally omitted when creating origin-safe methods. |
| 552 // A remote context's global proxy does not have the standard prototype chain |
| 553 // set up, so v8 won't be able to find the receiver type in the prototype |
| 554 // chain. Instead, the method implementation must do the check manually. |
| 555 v8::Local<v8::Signature> signature; |
| 556 {% else %} |
550 v8::Local<v8::FunctionTemplate> interfaceTemplate = data->findInterfaceTemplat
e(world, &{{v8_class}}::wrapperTypeInfo); | 557 v8::Local<v8::FunctionTemplate> interfaceTemplate = data->findInterfaceTemplat
e(world, &{{v8_class}}::wrapperTypeInfo); |
551 v8::Local<v8::Signature> signature = v8::Signature::New(info.GetIsolate(), int
erfaceTemplate); | 558 v8::Local<v8::Signature> signature = v8::Signature::New(info.GetIsolate(), int
erfaceTemplate); |
| 559 {% endif %} |
552 | 560 |
553 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe
mplate(world, &domTemplateKey, {{v8_class_or_partial}}::{{method.name}}MethodCal
lback{{world_suffix}}, v8Undefined(), signature, {{method.length}}); | 561 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe
mplate(world, &domTemplateKey, {{v8_class_or_partial}}::{{method.name}}MethodCal
lback{{world_suffix}}, v8Undefined(), signature, {{method.length}}); |
554 // Return the function by default, unless the user script has overwritten it. | 562 // Return the function by default, unless the user script has overwritten it. |
555 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre
ntContext()).ToLocalChecked()); | 563 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre
ntContext()).ToLocalChecked()); |
556 | 564 |
557 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 565 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
558 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()),
impl, BindingSecurity::ErrorReportOption::DoNotReport)) { | 566 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()),
impl, BindingSecurity::ErrorReportOption::DoNotReport)) { |
559 return; | 567 return; |
560 } | 568 } |
561 | 569 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 if method.overloads else | 666 if method.overloads else |
659 method.runtime_enabled_feature_name) %} | 667 method.runtime_enabled_feature_name) %} |
660 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 668 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
661 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); | 669 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); |
662 {% endfilter %}{# runtime_enabled() #} | 670 {% endfilter %}{# runtime_enabled() #} |
663 {% endfilter %}{# exposed() #} | 671 {% endfilter %}{# exposed() #} |
664 {% endfilter %}{# secure_context() #} | 672 {% endfilter %}{# secure_context() #} |
665 {% endfor %} | 673 {% endfor %} |
666 {% endif %} | 674 {% endif %} |
667 {%- endmacro %} | 675 {%- endmacro %} |
OLD | NEW |