Chromium Code Reviews| Index: Source/bindings/templates/methods.cpp |
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp |
| index 493dfd47ccfba2b7a151d0304a7561b9774db3ce..8c7149320c8418b56691071601985ee956d08cb5 100644 |
| --- a/Source/bindings/templates/methods.cpp |
| +++ b/Source/bindings/templates/methods.cpp |
| @@ -37,19 +37,26 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const |
| } |
| {% endif %} |
| {# Call method #} |
| - {% if interface_name == 'EventTarget' and |
|
Nils Barth (inactive)
2014/03/18 07:20:36
Moved down, so now arguments are always generated
|
| - method.name in ['addEventListener', 'removeEventListener'] %} |
| - {{add_event_listener_remove_event_listener_method(method.name) | indent}} |
| - {% else %} |
| {% for argument in method.arguments %} |
| {{generate_argument(method, argument, world_suffix) | indent}} |
| {% endfor %} |
| + {% if interface_name == 'EventTarget' and |
| + method.name in ['addEventListener', 'removeEventListener'] %} |
| + {# FIXME: can we move this |listener| check into Blink and |
| + hidden_dependency_action? I.e., "if (!listener) return;" in Blink |
| + and "if (listener && !impl->toNode())" in hidden_dependency_action} #} |
| + if (!listener) |
| + return; |
| + {% endif %} |
| {% if world_suffix %} |
| {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method.cpp_value) | indent}} |
| {% else %} |
| {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | indent}} |
| {% endif %} |
| - {% endif %}{# addEventListener, removeEventListener #} |
| + {% if interface_name == 'EventTarget' and |
| + method.name in ['addEventListener', 'removeEventListener'] %} |
| + {{hidden_dependency_action(method.name) | indent}} |
| + {% endif %} |
| } |
| {% endfilter %} |
| {% endmacro %} |
| @@ -70,20 +77,13 @@ if (DOMWindow* window = impl->toDOMWindow()) { |
| {######################################} |
| -{% macro add_event_listener_remove_event_listener_method(method_name) %} |
| -{# Set template values for addEventListener vs. removeEventListener #} |
| -{% set listener_lookup_type, listener, hidden_dependency_action = |
| - ('ListenerFindOrCreate', 'listener', 'addHiddenValueToArray') |
| - if method_name == 'addEventListener' else |
| - ('ListenerFindOnly', 'listener.get()', 'removeHiddenValueFromArray') |
| -%} |
| -RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1], false, {{listener_lookup_type}}); |
| -if (listener) { |
| - V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventName, info[0]); |
| - impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); |
| - if (!impl->toNode()) |
| - {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::eventListenerCacheIndex, info.GetIsolate()); |
| -} |
| +{% macro hidden_dependency_action(method_name) %} |
|
Nils Barth (inactive)
2014/03/18 07:20:36
Much simpler, because now only the really special
|
| +if (!impl->toNode()) |
| + {% if method_name == 'addEventListener' %} |
| + addHiddenValueToArray(info.Holder(), info[1], {{v8_class}}::eventListenerCacheIndex, info.GetIsolate()); |
| + {% else %}{# method_name == 'removeEventListener' #} |
| + removeHiddenValueFromArray(info.Holder(), info[1], {{v8_class}}::eventListenerCacheIndex, info.GetIsolate()); |
| + {% endif %} |
| {% endmacro %} |
| @@ -96,11 +96,19 @@ if (listener) { |
| fewer arguments if they are omitted. |
| Optional Dictionary arguments default to empty dictionary. #} |
| if (UNLIKELY(info.Length() <= {{argument.index}})) { |
| + {% if interface_name == 'EventTarget' %} |
| + {# FIXME: can we move this |listener| check into Blink? (see above) #} |
| + if (!listener) |
| + return; |
| + {% endif %} |
| {% if world_suffix %} |
| {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argument.cpp_value) | indent}} |
| {% else %} |
| {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}} |
| {% endif %} |
| + {% if interface_name == 'EventTarget' %} |
| + {{hidden_dependency_action(method.name) | indent}} |
| + {% endif %} |
| return; |
| } |
| {% endif %} |
| @@ -156,6 +164,16 @@ for (int i = {{argument.index}}; i < info.Length(); ++i) { |
| } |
| {{argument.name}}.append(V8{{argument.idl_type}}::toNative(v8::Handle<v8::Object>::Cast(info[i]))); |
| } |
| +{# FIXME: remove EventListener special case |
|
Nils Barth (inactive)
2014/03/18 07:20:36
This is really ugly, and it's all because we want
|
| + (just for ListenerFindOrCreate/ListenerFindOnly argument) #} |
| +{% elif argument.idl_type == 'EventListener' and |
| + interface_name == 'EventTarget' and |
| + method.name == 'addEventListener' %} |
| +V8TRYCATCH_VOID(RefPtr<EventListener>, {{argument.name}}, V8EventListenerList::getEventListener(info[{{argument.index}}], false, ListenerFindOrCreate)); |
| +{% elif argument.idl_type == 'EventListener' and |
| + interface_name == 'EventTarget' and |
| + method.name == 'removeEventListener' %} |
| +V8TRYCATCH_VOID(RefPtr<EventListener>, {{argument.name}}, V8EventListenerList::getEventListener(info[{{argument.index}}], false, ListenerFindOnly)); |
| {% else %} |
| {{argument.v8_value_to_local_cpp_value}}; |
| {% endif %} |