Chromium Code Reviews| Index: Source/bindings/templates/methods.cpp |
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp |
| index 6d77aea661bfc71d059d0fdf7be8ac01f5209854..6e4dacda3297c71a0b5b5919b14cd5b0107ea8d6 100644 |
| --- a/Source/bindings/templates/methods.cpp |
| +++ b/Source/bindings/templates/methods.cpp |
| @@ -6,13 +6,6 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const |
| {% if method.has_exception_state %} |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| {% endif %} |
| - {% if method.name in ['addEventListener', 'removeEventListener', |
|
Nils Barth (inactive)
2014/03/18 03:34:46
This if statement lists all the methods in EventTa
|
| - 'dispatchEvent'] %} |
| - {{add_event_listener_remove_event_listener_dispatch_event() | indent}} |
| - {% endif %} |
| - {% if method.name in ['addEventListener', 'removeEventListener'] %} |
|
Nils Barth (inactive)
2014/03/18 03:34:46
This {% if %} block meant that addEventListener/re
|
| - {{add_event_listener_remove_event_listener_method(method.name) | indent}} |
| - {% else %} |
| {% if method.number_of_required_arguments %} |
| if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
| {{throw_type_error(method, |
| @@ -27,7 +20,10 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const |
| {% if method.is_custom_element_callbacks %} |
| CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| {% endif %} |
| - {% if method.is_check_security_for_frame %} |
| + {# Security checks #} |
| + {% if interface_name == 'EventTarget' %} |
| + {{event_target_check_security_for_frame() | indent }} |
| + {% elif method.is_check_security_for_frame %} |
| if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), imp->frame(), exceptionState)) { |
| exceptionState.throwIfNeeded(); |
| return; |
| @@ -40,6 +36,11 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const |
| return; |
| } |
| {% 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 %} |
| @@ -55,11 +56,9 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const |
| {######################################} |
| -{% macro add_event_listener_remove_event_listener_dispatch_event() %} |
| -{# FIXME: Clean up: use the normal |imp| above, |
| - use the existing shouldAllowAccessToFrame check if possible. #} |
| -EventTarget* impl = {{v8_class}}::toNative(info.Holder()); |
| -if (DOMWindow* window = impl->toDOMWindow()) { |
| +{% macro event_target_check_security_for_frame() %} |
|
Nils Barth (inactive)
2014/03/18 03:34:46
Existing name was completely unclear
(just listed
|
| +{# FIXME: use the existing shouldAllowAccessToFrame check if possible. #} |
|
haraken
2014/03/18 03:43:57
We should consider fixing this FIXME in a follow-u
Nils Barth (inactive)
2014/03/18 04:47:03
Yup, I'll look at it!
|
| +if (DOMWindow* window = imp->toDOMWindow()) { |
| if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window->frame(), exceptionState)) { |
| exceptionState.throwIfNeeded(); |
| return; |
| @@ -81,8 +80,8 @@ if (DOMWindow* window = impl->toDOMWindow()) { |
| 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()) |
| + imp->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); |
|
Nils Barth (inactive)
2014/03/18 03:34:46
|impl| => |imp| for consistency.
|
| + if (!imp->toNode()) |
| {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::eventListenerCacheIndex, info.GetIsolate()); |
| } |
| {% endmacro %} |