| Index: Source/bindings/templates/methods.cpp
|
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
|
| index 8cc491946ebb0fceb98d98803e55aac5a4b0621a..784c7825c0a218e0e751e2b08e3eff22205165a7 100644
|
| --- a/Source/bindings/templates/methods.cpp
|
| +++ b/Source/bindings/templates/methods.cpp
|
| @@ -39,19 +39,26 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
|
| }
|
| {% endif %}
|
| {# Call method #}
|
| - {% if interface_name == 'EventTarget' and
|
| - 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 %}
|
| @@ -72,20 +79,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) %}
|
| +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 %}
|
|
|
|
|
| @@ -98,11 +98,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 %}
|
| @@ -116,6 +124,14 @@ if (info.Length() > {{argument.index}} && {% if argument.is_nullable %}!isUndefi
|
| }
|
| {% endif %}
|
| {% if argument.is_callback_interface %}
|
| +{# FIXME: remove EventListener special case #}
|
| +{% if argument.idl_type == 'EventListener' %}
|
| +{% if method.name == 'removeEventListener' %}
|
| +RefPtr<{{argument.idl_type}}> {{argument.name}} = V8EventListenerList::getEventListener(info[1], false, ListenerFindOnly);
|
| +{% else %}{# method.name == 'addEventListener' #}
|
| +RefPtr<{{argument.idl_type}}> {{argument.name}} = V8EventListenerList::getEventListener(info[1], false, ListenerFindOrCreate);
|
| +{% endif %}{# method.name #}
|
| +{% else %}
|
| {% if argument.is_optional %}
|
| OwnPtr<{{argument.idl_type}}> {{argument.name}};
|
| if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.index}}])) {
|
| @@ -136,6 +152,7 @@ if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{
|
| }
|
| OwnPtr<{{argument.idl_type}}> {{argument.name}} = {% if argument.is_nullable %}info[{{argument.index}}]->IsNull() ? nullptr : {% endif %}V8{{argument.idl_type}}::create(v8::Handle<v8::Function>::Cast(info[{{argument.index}}]), currentExecutionContext(info.GetIsolate()));
|
| {% endif %}{# argument.is_optional #}
|
| +{% endif %}{# argument.idl_type == 'EventListener' #}
|
| {% elif argument.is_clamp %}{# argument.is_callback_interface #}
|
| {# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #}
|
| {{argument.cpp_type}} {{argument.name}} = 0;
|
|
|