| 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 {% if method.name in ['addEventListener', 'removeEventListener'] %} | 6 {% if method.name in ['addEventListener', 'removeEventListener'] %} |
| 7 {{add_remove_event_listener_method(method.name) | indent}} | 7 {{add_remove_event_listener_method(method.name) | indent}} |
| 8 {% else %} | 8 {% else %} |
| 9 {% if method.number_of_required_arguments %} | 9 {% if method.number_of_required_arguments %} |
| 10 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { | 10 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
| 11 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{
interface_name}}", ExceptionMessages::notEnoughArguments({{method.number_of_requ
ired_arguments}}, info.Length())), info.GetIsolate()); | 11 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{
interface_name}}", ExceptionMessages::notEnoughArguments({{method.number_of_requ
ired_arguments}}, info.Length())), info.GetIsolate()); |
| 12 return; | 12 return; |
| 13 } | 13 } |
| 14 {% endif %} | 14 {% endif %} |
| 15 {% if not method.is_static %} | 15 {% if not method.is_static %} |
| 16 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | 16 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); |
| 17 {% endif %} | 17 {% endif %} |
| 18 {% if method.is_custom_element_callbacks %} | 18 {% if method.is_custom_element_callbacks %} |
| 19 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 19 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 20 {% endif %} | 20 {% endif %} |
| 21 {% if method.is_raises_exception %} | 21 {% if method.is_raises_exception %} |
| 22 ExceptionState es(info.GetIsolate()); | 22 ExceptionState exceptionState(info.GetIsolate()); |
| 23 {% endif %} | 23 {% endif %} |
| 24 {% if method.is_check_security_for_node %} | 24 {% if method.is_check_security_for_node %} |
| 25 if (!BindingSecurity::shouldAllowAccessToNode(imp->{{method.name}}(es), es))
{ | 25 if (!BindingSecurity::shouldAllowAccessToNode(imp->{{method.name}}(exception
State), exceptionState)) { |
| 26 v8SetReturnValueNull(info); | 26 v8SetReturnValueNull(info); |
| 27 es.throwIfNeeded(); | 27 exceptionState.throwIfNeeded(); |
| 28 return; | 28 return; |
| 29 } | 29 } |
| 30 {% endif %} | 30 {% endif %} |
| 31 {% for argument in method.arguments %} | 31 {% for argument in method.arguments %} |
| 32 {% if argument.is_optional and not argument.has_default and | 32 {% if argument.is_optional and not argument.has_default and |
| 33 argument.idl_type != 'Dictionary' %} | 33 argument.idl_type != 'Dictionary' %} |
| 34 {# Optional arguments without a default value generate an early call with | 34 {# Optional arguments without a default value generate an early call with |
| 35 fewer arguments if they are omitted. | 35 fewer arguments if they are omitted. |
| 36 Optional Dictionary arguments default to empty dictionary. #} | 36 Optional Dictionary arguments default to empty dictionary. #} |
| 37 if (UNLIKELY(info.Length() <= {{argument.index}})) { | 37 if (UNLIKELY(info.Length() <= {{argument.index}})) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 {######################################} | 97 {######################################} |
| 98 {% macro add_remove_event_listener_method(method_name) %} | 98 {% macro add_remove_event_listener_method(method_name) %} |
| 99 {# Set template values for addEventListener vs. removeEventListener #} | 99 {# Set template values for addEventListener vs. removeEventListener #} |
| 100 {% set listener_lookup_type, listener, hidden_dependency_action = | 100 {% set listener_lookup_type, listener, hidden_dependency_action = |
| 101 ('ListenerFindOrCreate', 'listener', 'createHiddenDependency') | 101 ('ListenerFindOrCreate', 'listener', 'createHiddenDependency') |
| 102 if method_name == 'addEventListener' else | 102 if method_name == 'addEventListener' else |
| 103 ('ListenerFindOnly', 'listener.get()', 'removeHiddenDependency') | 103 ('ListenerFindOnly', 'listener.get()', 'removeHiddenDependency') |
| 104 %} | 104 %} |
| 105 EventTarget* impl = {{v8_class_name}}::toNative(info.Holder()); | 105 EventTarget* impl = {{v8_class_name}}::toNative(info.Holder()); |
| 106 if (DOMWindow* window = impl->toDOMWindow()) { | 106 if (DOMWindow* window = impl->toDOMWindow()) { |
| 107 ExceptionState es(info.GetIsolate()); | 107 ExceptionState exceptionState(info.GetIsolate()); |
| 108 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), es)) { | 108 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptionSta
te)) { |
| 109 es.throwIfNeeded(); | 109 exceptionState.throwIfNeeded(); |
| 110 return; | 110 return; |
| 111 } | 111 } |
| 112 if (!window->document()) | 112 if (!window->document()) |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1],
false, {{listener_lookup_type}}); | 115 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1],
false, {{listener_lookup_type}}); |
| 116 if (listener) { | 116 if (listener) { |
| 117 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN
ame, info[0]); | 117 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN
ame, info[0]); |
| 118 impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); | 118 impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); |
| 119 if (!impl->toNode()) | 119 if (!impl->toNode()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 136 {% if method.is_call_with_script_arguments %} | 136 {% if method.is_call_with_script_arguments %} |
| 137 RefPtr<ScriptArguments> scriptArguments(createScriptArguments(info, {{method.num
ber_of_arguments}})); | 137 RefPtr<ScriptArguments> scriptArguments(createScriptArguments(info, {{method.num
ber_of_arguments}})); |
| 138 {% endif %} | 138 {% endif %} |
| 139 {% if method.idl_type == 'void' %} | 139 {% if method.idl_type == 'void' %} |
| 140 {{cpp_value}}; | 140 {{cpp_value}}; |
| 141 {% elif method.is_call_with_script_state %} | 141 {% elif method.is_call_with_script_state %} |
| 142 {# FIXME: consider always using a local variable #} | 142 {# FIXME: consider always using a local variable #} |
| 143 {{method.cpp_type}} result = {{cpp_value}}; | 143 {{method.cpp_type}} result = {{cpp_value}}; |
| 144 {% endif %} | 144 {% endif %} |
| 145 {% if method.is_raises_exception %} | 145 {% if method.is_raises_exception %} |
| 146 if (es.throwIfNeeded()) | 146 if (exceptionState.throwIfNeeded()) |
| 147 return; | 147 return; |
| 148 {% endif %} | 148 {% endif %} |
| 149 {% if method.is_call_with_script_state %} | 149 {% if method.is_call_with_script_state %} |
| 150 if (state.hadException()) { | 150 if (state.hadException()) { |
| 151 v8::Local<v8::Value> exception = state.exception(); | 151 v8::Local<v8::Value> exception = state.exception(); |
| 152 state.clearException(); | 152 state.clearException(); |
| 153 throwError(exception, info.GetIsolate()); | 153 throwError(exception, info.GetIsolate()); |
| 154 return; | 154 return; |
| 155 } | 155 } |
| 156 {% endif %} | 156 {% endif %} |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 {% endif %} | 202 {% endif %} |
| 203 {% if method.is_custom %} | 203 {% if method.is_custom %} |
| 204 {{v8_class_name}}::{{method.name}}MethodCustom(info); | 204 {{v8_class_name}}::{{method.name}}MethodCustom(info); |
| 205 {% else %} | 205 {% else %} |
| 206 {{cpp_class_name}}V8Internal::{{method.name}}Method{{world_suffix}}(info); | 206 {{cpp_class_name}}V8Internal::{{method.name}}Method{{world_suffix}}(info); |
| 207 {% endif %} | 207 {% endif %} |
| 208 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 208 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 209 } | 209 } |
| 210 {% endfilter %} | 210 {% endfilter %} |
| 211 {% endmacro %} | 211 {% endmacro %} |
| OLD | NEW |