OLD | NEW |
1 {##############################################################################} | 1 {##############################################################################} |
2 {% macro generate_method(method, world_suffix) %} | 2 {% macro generate_method(method, world_suffix) %} |
3 {% filter conditional(method.conditional_string) %} | 3 {% filter conditional(method.conditional_string) %} |
4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) | 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) |
5 { | 5 { |
6 {# Local variables #} | 6 {# Local variables #} |
7 {% if method.has_exception_state %} | 7 {% if method.has_exception_state %} |
8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
9 {% endif %} | 9 {% endif %} |
10 {# Overloaded methods have length checked during overload resolution #} | 10 {# Overloaded methods have length checked during overload resolution #} |
11 {% if method.number_of_required_arguments and not method.overload_index %} | 11 {% if method.number_of_required_arguments and not method.overload_index %} |
12 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { | 12 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
13 {{throw_minimum_arity_type_error(method, method.number_of_required_argum
ents)}}; | 13 {{throw_minimum_arity_type_error(method, method.number_of_required_argum
ents)}}; |
14 return; | 14 return; |
15 } | 15 } |
16 {% endif %} | 16 {% endif %} |
17 {% if not method.is_static %} | 17 {% if not method.is_static %} |
18 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); | 18 {{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder()); |
19 {% endif %} | 19 {% endif %} |
20 {% if method.is_custom_element_callbacks %} | 20 {% if method.is_custom_element_callbacks %} |
21 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 21 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
22 {% endif %} | 22 {% endif %} |
23 {# Security checks #} | 23 {# Security checks #} |
24 {# FIXME: change to method.is_check_security_for_window #} | 24 {# FIXME: merge to method.is_check_security_for_frame http://crbug.com/38369
9 #} |
25 {% if interface_name == 'EventTarget' %} | 25 {% if interface_name == 'EventTarget' %} |
26 if (LocalDOMWindow* window = impl->toDOMWindow()) { | 26 if (LocalDOMWindow* window = impl->toDOMWindow()) { |
27 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window
->frame(), exceptionState)) { | 27 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window
->frame(), exceptionState)) { |
28 {{throw_from_exception_state(method)}}; | 28 {{throw_from_exception_state(method)}}; |
29 return; | 29 return; |
30 } | 30 } |
31 if (!window->document()) | 31 if (!window->document()) |
32 return; | 32 return; |
33 } | 33 } |
34 {% elif method.is_check_security_for_frame %} | 34 {% elif method.is_check_security_for_frame %} |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 {% endif %} | 251 {% endif %} |
252 {# Set return value #} | 252 {# Set return value #} |
253 {% if method.is_constructor %} | 253 {% if method.is_constructor %} |
254 {{generate_constructor_wrapper(method)}} | 254 {{generate_constructor_wrapper(method)}} |
255 {%- elif method.union_arguments %} | 255 {%- elif method.union_arguments %} |
256 {{union_type_method_call_and_set_return_value(method)}} | 256 {{union_type_method_call_and_set_return_value(method)}} |
257 {%- elif v8_set_return_value %} | 257 {%- elif v8_set_return_value %} |
258 {{v8_set_return_value}}; | 258 {{v8_set_return_value}}; |
259 {%- endif %}{# None for void #} | 259 {%- endif %}{# None for void #} |
260 {# Post-set #} | 260 {# Post-set #} |
261 {% if interface_name == 'EventTarget' and method.name in ('addEventListener', | 261 {# Arguments length check needed to skip action on legacy calls without enough |
262 'removeEventListener')
%} | 262 arguments. http://crbug.com/353484 #} |
| 263 {% if interface_name == 'EventTarget' and |
| 264 method.name in ('addEventListener', 'removeEventListener') and |
| 265 method.arguments|length >= 2 %} |
263 {% set hidden_dependency_action = 'addHiddenValueToArray' | 266 {% set hidden_dependency_action = 'addHiddenValueToArray' |
264 if method.name == 'addEventListener' else 'removeHiddenValueFromArray' %} | 267 if method.name == 'addEventListener' else 'removeHiddenValueFromArray' %} |
265 {# Length check needed to skip action on legacy calls without enough arguments. | 268 if (listener && !impl->toNode()) |
266 http://crbug.com/353484 #} | |
267 if (info.Length() >= 2 && listener && !impl->toNode()) | |
268 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::eventList
enerCacheIndex, info.GetIsolate()); | 269 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::eventList
enerCacheIndex, info.GetIsolate()); |
269 {% endif %} | 270 {% endif %} |
270 {% endmacro %} | 271 {% endmacro %} |
271 | 272 |
272 | 273 |
273 {######################################} | 274 {######################################} |
274 {% macro union_type_method_call_and_set_return_value(method) %} | 275 {% macro union_type_method_call_and_set_return_value(method) %} |
275 {% for cpp_type in method.cpp_type %} | 276 {% for cpp_type in method.cpp_type %} |
276 bool result{{loop.index0}}Enabled = false; | 277 bool result{{loop.index0}}Enabled = false; |
277 {{cpp_type}} result{{loop.index0}}; | 278 {{cpp_type}} result{{loop.index0}}; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 {% endif %} | 563 {% endif %} |
563 {{constructor.cpp_type}} impl = {{constructor.cpp_value}}; | 564 {{constructor.cpp_type}} impl = {{constructor.cpp_value}}; |
564 {% if is_constructor_raises_exception %} | 565 {% if is_constructor_raises_exception %} |
565 if (exceptionState.throwIfNeeded()) | 566 if (exceptionState.throwIfNeeded()) |
566 return; | 567 return; |
567 {% endif %} | 568 {% endif %} |
568 | 569 |
569 {{generate_constructor_wrapper(constructor) | indent}} | 570 {{generate_constructor_wrapper(constructor) | indent}} |
570 } | 571 } |
571 {% endmacro %} | 572 {% endmacro %} |
OLD | NEW |