| 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 v8::Local<v8::FunctionTemplate> domTemplate = data->domTemplate(&domTemplate
Key, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}}, v8U
ndefined(), {{signature}}, {{method.length}}); | 522 v8::Local<v8::FunctionTemplate> domTemplate = data->domTemplate(&domTemplate
Key, {{cpp_class}}V8Internal::{{method.name}}MethodCallback{{world_suffix}}, v8U
ndefined(), {{signature}}, {{method.length}}); |
| 529 | 523 |
| 530 // It is unsafe to use info.Holder() because OriginSafeMethodGetter is calle
d | 524 // It is unsafe to use info.Holder() because OriginSafeMethodGetter is calle
d |
| 531 // back without checking the type of info.Holder(). | 525 // back without checking the type of info.Holder(). |
| 532 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in
fo.This(), info.GetIsolate()); | 526 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in
fo.This(), info.GetIsolate()); |
| 533 if (holder.IsEmpty()) { | 527 if (holder.IsEmpty()) { |
| 534 v8SetReturnValue(info, domTemplate->GetFunction(info.GetIsolate()->GetCu
rrentContext()).ToLocalChecked()); | 528 v8SetReturnValue(info, domTemplate->GetFunction(info.GetIsolate()->GetCu
rrentContext()).ToLocalChecked()); |
| 535 return; | 529 return; |
| 536 } | 530 } |
| 537 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 531 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
| 538 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOM
Window(info.GetIsolate()), impl->frame(), DoNotReportSecurityError)) { | 532 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo
w(info.GetIsolate()), impl, DoNotReportSecurityError)) { |
| 539 v8SetReturnValue(info, domTemplate->GetFunction(info.GetIsolate()->GetCu
rrentContext()).ToLocalChecked()); | 533 v8SetReturnValue(info, domTemplate->GetFunction(info.GetIsolate()->GetCu
rrentContext()).ToLocalChecked()); |
| 540 return; | 534 return; |
| 541 } | 535 } |
| 542 | 536 |
| 543 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha
ndle if info.This() is an Object. #} | 537 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha
ndle if info.This() is an Object. #} |
| 544 v8::Local<v8::Value> hiddenValue = V8HiddenValue::getHiddenValue(ScriptState
::current(info.GetIsolate()), v8::Local<v8::Object>::Cast(info.This()), v8Atomic
String(info.GetIsolate(), "{{method.name}}")); | 538 v8::Local<v8::Value> hiddenValue = V8HiddenValue::getHiddenValue(ScriptState
::current(info.GetIsolate()), v8::Local<v8::Object>::Cast(info.This()), v8Atomic
String(info.GetIsolate(), "{{method.name}}")); |
| 545 if (!hiddenValue.IsEmpty()) { | 539 if (!hiddenValue.IsEmpty()) { |
| 546 v8SetReturnValue(info, hiddenValue); | 540 v8SetReturnValue(info, hiddenValue); |
| 547 return; | 541 return; |
| 548 } | 542 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all | 678 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all |
| 685 if method.overloads else | 679 if method.overloads else |
| 686 method.runtime_enabled_function) %} | 680 method.runtime_enabled_function) %} |
| 687 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 681 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
| 688 V8DOMConfiguration::installMethod(isolate, v8::Local<v8::Object>(), prototypeObj
ect, interfaceObject, defaultSignature, {{method.name}}MethodConfiguration); | 682 V8DOMConfiguration::installMethod(isolate, v8::Local<v8::Object>(), prototypeObj
ect, interfaceObject, defaultSignature, {{method.name}}MethodConfiguration); |
| 689 {% endfilter %}{# runtime_enabled() #} | 683 {% endfilter %}{# runtime_enabled() #} |
| 690 {% endfilter %}{# exposed() #} | 684 {% endfilter %}{# exposed() #} |
| 691 {% endfor %} | 685 {% endfor %} |
| 692 {% endif %} | 686 {% endif %} |
| 693 {%- endmacro %} | 687 {%- endmacro %} |
| OLD | NEW |