Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl

Issue 2418413004: binding: Creates a reject promise always in the current realm. (Closed)
Patch Set: Added a layout test. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 { 9 {
10 {% set define_exception_state -%} 10 {% set define_exception_state -%}
11 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo ntext, "{{interface_name}}", "{{method.name}}"); 11 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo ntext, "{{interface_name}}", "{{method.name}}");
12 {%- endset %} 12 {%- endset %}
13 13
14 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %} 14 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %}
15 15
16 {% if 'exceptionState' in function_call %} 16 {% if 'exceptionState' in function_call %}
17 {{define_exception_state}} 17 {{define_exception_state}}
18 {% if method.returns_promise %} 18 {% if method.returns_promise %}
19 {% if method.is_static %} 19 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState);
20 ScriptState* scriptState = ScriptState::forFunctionObject(info);
21 {% else %}
22 ScriptState* scriptState = ScriptState::forReceiverObject(info);
23 {% endif %}
24 ExceptionToRejectPromiseScope rejectPromiseScope(info, scriptState, exceptio nState);
25 {% endif %} 20 {% endif %}
26 {% endif %} 21 {% endif %}
27 22
28 {% if not method.is_static %} 23 {% if not method.is_static %}
29 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 24 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
30 {% endif %} 25 {% endif %}
31 26
32 {# Security checks #} 27 {# Security checks #}
Yuki 2016/10/19 11:23:37 This block is checking the origin. We're throwing
haraken 2016/10/19 12:38:48 However, this security check is generated only whe
33 {% if method.is_check_security_for_receiver %} 28 {% if method.is_check_security_for_receiver %}
34 {{define_exception_state}} 29 {{define_exception_state}}
35 {% if interface_name == 'EventTarget' %} 30 {% if interface_name == 'EventTarget' %}
36 // Performance hack for EventTarget. Checking whether it's a Window or not 31 // Performance hack for EventTarget. Checking whether it's a Window or not
37 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30% 32 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30%
38 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE 33 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE
39 // didn't work in this case. 34 // didn't work in this case.
40 if (const DOMWindow* window = impl->toDOMWindow()) { 35 if (const DOMWindow* window = impl->toDOMWindow()) {
41 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsola te()), window, exceptionState)) { 36 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsola te()), window, exceptionState)) {
42 return; 37 return;
(...skipping 18 matching lines...) Expand all
61 ScriptState* scriptState = ScriptState::forFunctionObject(info); 56 ScriptState* scriptState = ScriptState::forFunctionObject(info);
62 {% else %} 57 {% else %}
63 ScriptState* scriptState = ScriptState::forReceiverObject(info); 58 ScriptState* scriptState = ScriptState::forReceiverObject(info);
64 {% endif %} 59 {% endif %}
65 {% endif %} 60 {% endif %}
66 61
67 {% if method.is_custom_element_callbacks %} 62 {% if method.is_custom_element_callbacks %}
68 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; 63 V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
69 {% endif %} 64 {% endif %}
70 65
71 {{function_call | indent}} 66 {{function_call | indent}}
Yuki 2016/10/19 11:23:37 All the other hand-written ScriptPromise::reject()
72 } 67 }
73 {% endfilter %} 68 {% endfilter %}
74 {% endmacro %} 69 {% endmacro %}
75 70
76 71
77 {######################################} 72 {######################################}
78 {% macro func_call_with_prep_of_args(method, world_suffix) %} 73 {% macro func_call_with_prep_of_args(method, world_suffix) %}
79 {{generate_arguments(method, world_suffix)}} 74 {{generate_arguments(method, world_suffix)}}
80 {% if world_suffix %} 75 {% if world_suffix %}
81 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method.cpp_ value)}} 76 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method.cpp_ value)}}
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 395
401 {% if fall_through_to_partial_overloads %} 396 {% if fall_through_to_partial_overloads %}
402 397
403 DCHECK({{overloads.name}}MethodForPartialInterface); 398 DCHECK({{overloads.name}}MethodForPartialInterface);
404 ({{overloads.name}}MethodForPartialInterface)(info); 399 ({{overloads.name}}MethodForPartialInterface)(info);
405 400
406 {% else %}{# fall_through_to_partial_overloads #} 401 {% else %}{# fall_through_to_partial_overloads #}
407 402
408 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo ntext, "{{interface_name}}", "{{overloads.name}}"); 403 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo ntext, "{{interface_name}}", "{{overloads.name}}");
409 {% if overloads.returns_promise_all %} 404 {% if overloads.returns_promise_all %}
410 {% if overloads.is_static %} 405 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState);
411 ScriptState* scriptState = ScriptState::forFunctionObject(info);
412 {% else %}
413 ScriptState* scriptState = ScriptState::forReceiverObject(info);
414 {% endif %}
415 ExceptionToRejectPromiseScope rejectPromiseScope(info, scriptState, exceptio nState);
416 {% endif %} 406 {% endif %}
417 407
418 if (isArityError) { 408 if (isArityError) {
419 {% if overloads.length != 0 %} 409 {% if overloads.length != 0 %}
420 if (info.Length() < {{overloads.length}}) { 410 if (info.Length() < {{overloads.length}}) {
421 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments( {{overloads.length}}, info.Length())); 411 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments( {{overloads.length}}, info.Length()));
422 return; 412 return;
423 } 413 }
424 {% endif %} 414 {% endif %}
425 {% if overloads.valid_arities %} 415 {% if overloads.valid_arities %}
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if method.overloads else 652 if method.overloads else
663 method.runtime_enabled_function) %} 653 method.runtime_enabled_function) %}
664 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 654 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
665 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 655 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
666 {% endfilter %}{# runtime_enabled() #} 656 {% endfilter %}{# runtime_enabled() #}
667 {% endfilter %}{# exposed() #} 657 {% endfilter %}{# exposed() #}
668 {% endfilter %}{# secure_context() #} 658 {% endfilter %}{# secure_context() #}
669 {% endfor %} 659 {% endfor %}
670 {% endif %} 660 {% endif %}
671 {%- endmacro %} 661 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698