| Index: Source/bindings/templates/methods.cpp
|
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
|
| index c77ffcb5f7356182f9ecb5e61d9412ceb6908244..516520ba517e9f4fd16522e907fe9bfe7aa0dae9 100644
|
| --- a/Source/bindings/templates/methods.cpp
|
| +++ b/Source/bindings/templates/methods.cpp
|
| @@ -3,6 +3,9 @@
|
| {% filter conditional(method.conditional_string) %}
|
| static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| {
|
| + {% if method.name in ['addEventListener', 'removeEventListener'] %}
|
| + {{add_remove_event_listener_method(method.name) | indent}}
|
| + {% else %}
|
| {% if method.number_of_required_arguments %}
|
| if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) {
|
| throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{interface_name}}", ExceptionMessages::notEnoughArguments({{method.number_of_required_arguments}}, info.Length())), info.GetIsolate());
|
| @@ -85,12 +88,40 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
|
| {% endif %}
|
| {% endfor %}{# arguments #}
|
| {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | indent}}
|
| + {% endif %}{# addEventListener, removeEventListener #}
|
| }
|
| {% endfilter %}
|
| {% endmacro %}
|
|
|
|
|
| {######################################}
|
| +{% macro add_remove_event_listener_method(method_name) %}
|
| +{% set lookup_type, pass_ref_ptr_handling, hidden_dependency_action =
|
| + ('OrCreate', '', 'create')
|
| + if method_name.startswith('add') else
|
| + ('Only', '.get()', 'remove')
|
| +%}
|
| +EventTarget* impl = {{v8_class_name}}::toNative(info.Holder());
|
| +if (DOMWindow* window = impl->toDOMWindow()) {
|
| + ExceptionState es(info.GetIsolate());
|
| + if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), es)) {
|
| + es.throwIfNeeded();
|
| + return;
|
| + }
|
| + if (!window->document())
|
| + return;
|
| +}
|
| +RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1], false, ListenerFind{{lookup_type}});
|
| +if (listener) {
|
| + V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, stringResource, info[0]);
|
| + impl->{{method_name}}(stringResource, listener{{pass_ref_ptr_handling}}, info[2]->BooleanValue());
|
| + if (!impl->toNode())
|
| + {{hidden_dependency_action}}HiddenDependency(info.Holder(), info[1], {{v8_class_name}}::eventListenerCacheIndex, info.GetIsolate());
|
| +}
|
| +{% endmacro %}
|
| +
|
| +
|
| +{######################################}
|
| {% macro cpp_method_call(method, v8_set_return_value, cpp_value) %}
|
| {% if method.is_call_with_script_state %}
|
| ScriptState* currentState = ScriptState::current();
|
|
|