| OLD | NEW |
| 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l
ocal_cpp_value %} | 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l
ocal_cpp_value %} |
| 2 | 2 |
| 3 | 3 |
| 4 {##############################################################################} | 4 {##############################################################################} |
| 5 {% macro generate_method(method, world_suffix) %} | 5 {% macro generate_method(method, world_suffix) %} |
| 6 {% filter conditional(method.conditional_string) %} | 6 {% filter conditional(method.conditional_string) %} |
| 7 {% if method.returns_promise and method.has_exception_state %} | 7 {% if method.returns_promise and method.has_exception_state %} |
| 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis
e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat
e) | 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis
e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat
e) |
| 9 {% else %} | 9 {% else %} |
| 10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) | 10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) |
| 11 {% endif %} | 11 {% endif %} |
| 12 { | 12 { |
| 13 {# Local variables #} | 13 {# Local variables #} |
| 14 {% if method.has_exception_state and not method.returns_promise %} | 14 {% if method.has_exception_state and not method.returns_promise %} |
| 15 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 15 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 16 {% endif %} | 16 {% endif %} |
| 17 {# Overloaded methods have length checked during overload resolution #} | 17 {# Overloaded methods have length checked during overload resolution #} |
| 18 {% if method.number_of_required_arguments and not method.overload_index %} | 18 {% if method.number_of_required_arguments and not method.overload_index %} |
| 19 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { | 19 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
| 20 {{throw_minimum_arity_type_error(method, method.number_of_required_argum
ents) | indent(8)}} | 20 {{throw_minimum_arity_type_error(method, method.number_of_required_argum
ents) | indent(8)}} |
| 21 } | 21 } |
| 22 {% endif %} | 22 {% endif %} |
| 23 {% if not method.is_static %} | 23 {% if not method.is_static %} |
| 24 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 24 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| 25 {% endif %} | 25 {% endif %} |
| 26 {% if method.is_custom_element_callbacks %} | 26 {% if method.is_custom_element_callbacks %} |
| 27 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; | 27 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; |
| 28 {% endif %} | 28 {% endif %} |
| 29 {# Security checks #} | 29 {# Security checks #} |
| 30 {% if method.is_check_security_for_window %} | 30 {% if method.is_check_security_for_window or |
| 31 if (LocalDOMWindow* window = impl->toDOMWindow()) { | 31 method.is_check_security_for_frame or |
| 32 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callin
gDOMWindow(info.GetIsolate()), window->frame(), exceptionState)) { | 32 method.is_check_security_for_node %} |
| 33 {{propagate_error_with_exception_state(method) | indent(12)}} | 33 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo
w(info.GetIsolate()), {{method.cpp_value if method.is_check_security_for_node el
se 'impl'}}, exceptionState)) { |
| 34 } | 34 {% if method.is_check_security_for_node %} |
| 35 if (!window->document()) | |
| 36 return; | |
| 37 } | |
| 38 {% elif method.is_check_security_for_frame %} | |
| 39 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOM
Window(info.GetIsolate()), impl->frame(), exceptionState)) { | |
| 40 {{propagate_error_with_exception_state(method) | indent(8)}} | |
| 41 } | |
| 42 {% endif %} | |
| 43 {% if method.is_check_security_for_node %} | |
| 44 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), callingDOMW
indow(info.GetIsolate()), impl->{{method.name}}(exceptionState), exceptionState)
) { | |
| 45 v8SetReturnValueNull(info); | 35 v8SetReturnValueNull(info); |
| 46 {{propagate_error_with_exception_state(method) | indent(8)}} | 36 {% endif %} |
| 37 {% if not method.returns_promise %} |
| 38 exceptionState.throwIfNeeded(); |
| 39 {% endif %} |
| 40 return; |
| 47 } | 41 } |
| 48 {% endif %} | 42 {% endif %} |
| 49 {# Call method #} | 43 {# Call method #} |
| 50 {% if method.arguments %} | 44 {% if method.arguments %} |
| 51 {{generate_arguments(method, world_suffix) | indent}} | 45 {{generate_arguments(method, world_suffix) | indent}} |
| 52 {% endif %} | 46 {% endif %} |
| 53 {% if world_suffix %} | 47 {% if world_suffix %} |
| 54 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method.
cpp_value) | indent}} | 48 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method.
cpp_value) | indent}} |
| 55 {% else %} | 49 {% else %} |
| 56 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in
dent}} | 50 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in
dent}} |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 v8::Local<v8::FunctionTemplate> domTemplate = data->domTemplate(&domTemplate
Key, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}}, v8U
ndefined(), {{signature}}, {{method.length}}); | 523 v8::Local<v8::FunctionTemplate> domTemplate = data->domTemplate(&domTemplate
Key, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}}, v8U
ndefined(), {{signature}}, {{method.length}}); |
| 530 | 524 |
| 531 // It is unsafe to use info.Holder() because OriginSafeMethodGetter is calle
d | 525 // It is unsafe to use info.Holder() because OriginSafeMethodGetter is calle
d |
| 532 // back without checking the type of info.Holder(). | 526 // back without checking the type of info.Holder(). |
| 533 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in
fo.This(), info.GetIsolate()); | 527 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in
fo.This(), info.GetIsolate()); |
| 534 if (holder.IsEmpty()) { | 528 if (holder.IsEmpty()) { |
| 535 v8SetReturnValue(info, domTemplate->GetFunction(info.GetIsolate()->GetCu
rrentContext()).ToLocalChecked()); | 529 v8SetReturnValue(info, domTemplate->GetFunction(info.GetIsolate()->GetCu
rrentContext()).ToLocalChecked()); |
| 536 return; | 530 return; |
| 537 } | 531 } |
| 538 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 532 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
| 539 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOM
Window(info.GetIsolate()), impl->frame(), DoNotReportSecurityError)) { | 533 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo
w(info.GetIsolate()), impl, DoNotReportSecurityError)) { |
| 540 v8SetReturnValue(info, domTemplate->GetFunction(info.GetIsolate()->GetCu
rrentContext()).ToLocalChecked()); | 534 v8SetReturnValue(info, domTemplate->GetFunction(info.GetIsolate()->GetCu
rrentContext()).ToLocalChecked()); |
| 541 return; | 535 return; |
| 542 } | 536 } |
| 543 | 537 |
| 544 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha
ndle if info.This() is an Object. #} | 538 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha
ndle if info.This() is an Object. #} |
| 545 v8::Local<v8::Value> hiddenValue = V8HiddenValue::getHiddenValue(ScriptState
::current(info.GetIsolate()), v8::Local<v8::Object>::Cast(info.This()), v8Atomic
String(info.GetIsolate(), "{{method.name}}")); | 539 v8::Local<v8::Value> hiddenValue = V8HiddenValue::getHiddenValue(ScriptState
::current(info.GetIsolate()), v8::Local<v8::Object>::Cast(info.This()), v8Atomic
String(info.GetIsolate(), "{{method.name}}")); |
| 546 if (!hiddenValue.IsEmpty()) { | 540 if (!hiddenValue.IsEmpty()) { |
| 547 v8SetReturnValue(info, hiddenValue); | 541 v8SetReturnValue(info, hiddenValue); |
| 548 return; | 542 return; |
| 549 } | 543 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all | 679 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all |
| 686 if method.overloads else | 680 if method.overloads else |
| 687 method.runtime_enabled_function) %} | 681 method.runtime_enabled_function) %} |
| 688 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 682 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
| 689 V8DOMConfiguration::installMethod(isolate, v8::Local<v8::Object>(), prototypeObj
ect, interfaceObject, defaultSignature, {{method.name}}MethodConfiguration); | 683 V8DOMConfiguration::installMethod(isolate, v8::Local<v8::Object>(), prototypeObj
ect, interfaceObject, defaultSignature, {{method.name}}MethodConfiguration); |
| 690 {% endfilter %}{# runtime_enabled() #} | 684 {% endfilter %}{# runtime_enabled() #} |
| 691 {% endfilter %}{# exposed() #} | 685 {% endfilter %}{# exposed() #} |
| 692 {% endfor %} | 686 {% endfor %} |
| 693 {% endif %} | 687 {% endif %} |
| 694 {%- endmacro %} | 688 {%- endmacro %} |
| OLD | NEW |