Chromium Code Reviews| 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.has_exception_state %} | 6 {% if method.has_exception_state %} |
| 7 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 7 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 8 {% endif %} | 8 {% endif %} |
| 9 {% if method.name in ['addEventListener', 'removeEventListener', | |
|
Nils Barth (inactive)
2014/03/18 03:34:46
This if statement lists all the methods in EventTa
| |
| 10 'dispatchEvent'] %} | |
| 11 {{add_event_listener_remove_event_listener_dispatch_event() | indent}} | |
| 12 {% endif %} | |
| 13 {% if method.name in ['addEventListener', 'removeEventListener'] %} | |
|
Nils Barth (inactive)
2014/03/18 03:34:46
This {% if %} block meant that addEventListener/re
| |
| 14 {{add_event_listener_remove_event_listener_method(method.name) | indent}} | |
| 15 {% else %} | |
| 16 {% if method.number_of_required_arguments %} | 9 {% if method.number_of_required_arguments %} |
| 17 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { | 10 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
| 18 {{throw_type_error(method, | 11 {{throw_type_error(method, |
| 19 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % | 12 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % |
| 20 method.number_of_required_arguments) | indent(8)}} | 13 method.number_of_required_arguments) | indent(8)}} |
| 21 return; | 14 return; |
| 22 } | 15 } |
| 23 {% endif %} | 16 {% endif %} |
| 24 {% if not method.is_static %} | 17 {% if not method.is_static %} |
| 25 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); | 18 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); |
| 26 {% endif %} | 19 {% endif %} |
| 27 {% if method.is_custom_element_callbacks %} | 20 {% if method.is_custom_element_callbacks %} |
| 28 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; | 21 CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope; |
| 29 {% endif %} | 22 {% endif %} |
| 30 {% if method.is_check_security_for_frame %} | 23 {# Security checks #} |
| 24 {% if interface_name == 'EventTarget' %} | |
| 25 {{event_target_check_security_for_frame() | indent }} | |
| 26 {% elif method.is_check_security_for_frame %} | |
| 31 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), imp->frame (), exceptionState)) { | 27 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), imp->frame (), exceptionState)) { |
| 32 exceptionState.throwIfNeeded(); | 28 exceptionState.throwIfNeeded(); |
| 33 return; | 29 return; |
| 34 } | 30 } |
| 35 {% endif %} | 31 {% endif %} |
| 36 {% if method.is_check_security_for_node %} | 32 {% if method.is_check_security_for_node %} |
| 37 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), imp->{{meth od.name}}(exceptionState), exceptionState)) { | 33 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), imp->{{meth od.name}}(exceptionState), exceptionState)) { |
| 38 v8SetReturnValueNull(info); | 34 v8SetReturnValueNull(info); |
| 39 exceptionState.throwIfNeeded(); | 35 exceptionState.throwIfNeeded(); |
| 40 return; | 36 return; |
| 41 } | 37 } |
| 42 {% endif %} | 38 {% endif %} |
| 39 {# Call method #} | |
| 40 {% if interface_name == 'EventTarget' and | |
| 41 method.name in ['addEventListener', 'removeEventListener'] %} | |
| 42 {{add_event_listener_remove_event_listener_method(method.name) | indent}} | |
| 43 {% else %} | |
| 43 {% for argument in method.arguments %} | 44 {% for argument in method.arguments %} |
| 44 {{generate_argument(method, argument, world_suffix) | indent}} | 45 {{generate_argument(method, argument, world_suffix) | indent}} |
| 45 {% endfor %} | 46 {% endfor %} |
| 46 {% if world_suffix %} | 47 {% if world_suffix %} |
| 47 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method. cpp_value) | indent}} | 48 {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method. cpp_value) | indent}} |
| 48 {% else %} | 49 {% else %} |
| 49 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in dent}} | 50 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in dent}} |
| 50 {% endif %} | 51 {% endif %} |
| 51 {% endif %}{# addEventListener, removeEventListener #} | 52 {% endif %}{# addEventListener, removeEventListener #} |
| 52 } | 53 } |
| 53 {% endfilter %} | 54 {% endfilter %} |
| 54 {% endmacro %} | 55 {% endmacro %} |
| 55 | 56 |
| 56 | 57 |
| 57 {######################################} | 58 {######################################} |
| 58 {% macro add_event_listener_remove_event_listener_dispatch_event() %} | 59 {% macro event_target_check_security_for_frame() %} |
|
Nils Barth (inactive)
2014/03/18 03:34:46
Existing name was completely unclear
(just listed
| |
| 59 {# FIXME: Clean up: use the normal |imp| above, | 60 {# 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!
| |
| 60 use the existing shouldAllowAccessToFrame check if possible. #} | 61 if (DOMWindow* window = imp->toDOMWindow()) { |
| 61 EventTarget* impl = {{v8_class}}::toNative(info.Holder()); | |
| 62 if (DOMWindow* window = impl->toDOMWindow()) { | |
| 63 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window->fr ame(), exceptionState)) { | 62 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window->fr ame(), exceptionState)) { |
| 64 exceptionState.throwIfNeeded(); | 63 exceptionState.throwIfNeeded(); |
| 65 return; | 64 return; |
| 66 } | 65 } |
| 67 if (!window->document()) | 66 if (!window->document()) |
| 68 return; | 67 return; |
| 69 } | 68 } |
| 70 {% endmacro %} | 69 {% endmacro %} |
| 71 | 70 |
| 72 | 71 |
| 73 {######################################} | 72 {######################################} |
| 74 {% macro add_event_listener_remove_event_listener_method(method_name) %} | 73 {% macro add_event_listener_remove_event_listener_method(method_name) %} |
| 75 {# Set template values for addEventListener vs. removeEventListener #} | 74 {# Set template values for addEventListener vs. removeEventListener #} |
| 76 {% set listener_lookup_type, listener, hidden_dependency_action = | 75 {% set listener_lookup_type, listener, hidden_dependency_action = |
| 77 ('ListenerFindOrCreate', 'listener', 'addHiddenValueToArray') | 76 ('ListenerFindOrCreate', 'listener', 'addHiddenValueToArray') |
| 78 if method_name == 'addEventListener' else | 77 if method_name == 'addEventListener' else |
| 79 ('ListenerFindOnly', 'listener.get()', 'removeHiddenValueFromArray') | 78 ('ListenerFindOnly', 'listener.get()', 'removeHiddenValueFromArray') |
| 80 %} | 79 %} |
| 81 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1], false, {{listener_lookup_type}}); | 80 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1], false, {{listener_lookup_type}}); |
| 82 if (listener) { | 81 if (listener) { |
| 83 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN ame, info[0]); | 82 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, eventN ame, info[0]); |
| 84 impl->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); | 83 imp->{{method_name}}(eventName, {{listener}}, info[2]->BooleanValue()); |
|
Nils Barth (inactive)
2014/03/18 03:34:46
|impl| => |imp| for consistency.
| |
| 85 if (!impl->toNode()) | 84 if (!imp->toNode()) |
| 86 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::event ListenerCacheIndex, info.GetIsolate()); | 85 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::event ListenerCacheIndex, info.GetIsolate()); |
| 87 } | 86 } |
| 88 {% endmacro %} | 87 {% endmacro %} |
| 89 | 88 |
| 90 | 89 |
| 91 {######################################} | 90 {######################################} |
| 92 {% macro generate_argument(method, argument, world_suffix) %} | 91 {% macro generate_argument(method, argument, world_suffix) %} |
| 93 {% if argument.is_optional and not argument.has_default and | 92 {% if argument.is_optional and not argument.has_default and |
| 94 argument.idl_type != 'Dictionary' and | 93 argument.idl_type != 'Dictionary' and |
| 95 not argument.is_callback_interface %} | 94 not argument.is_callback_interface %} |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 v8::Handle<v8::Object> wrapper = info.Holder(); | 435 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 437 {% if is_constructor_raises_exception %} | 436 {% if is_constructor_raises_exception %} |
| 438 if (exceptionState.throwIfNeeded()) | 437 if (exceptionState.throwIfNeeded()) |
| 439 return; | 438 return; |
| 440 {% endif %} | 439 {% endif %} |
| 441 | 440 |
| 442 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent); | 441 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent); |
| 443 v8SetReturnValue(info, wrapper); | 442 v8SetReturnValue(info, wrapper); |
| 444 } | 443 } |
| 445 {% endmacro %} | 444 {% endmacro %} |
| OLD | NEW |