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.name in ['addEventListener', 'removeEventListener'] %} | |
| 7 {{add_remove_event_listener_method(method.name) | indent}} | |
| 8 {% else %} | |
| 6 {% if method.number_of_required_arguments %} | 9 {% if method.number_of_required_arguments %} |
| 7 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { | 10 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
| 8 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{ interface_name}}", ExceptionMessages::notEnoughArguments({{method.number_of_requ ired_arguments}}, info.Length())), info.GetIsolate()); | 11 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{ interface_name}}", ExceptionMessages::notEnoughArguments({{method.number_of_requ ired_arguments}}, info.Length())), info.GetIsolate()); |
| 9 return; | 12 return; |
| 10 } | 13 } |
| 11 {% endif %} | 14 {% endif %} |
| 12 {% if not method.is_static %} | 15 {% if not method.is_static %} |
| 13 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | 16 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); |
| 14 {% endif %} | 17 {% endif %} |
| 15 {% if method.is_custom_element_callbacks %} | 18 {% if method.is_custom_element_callbacks %} |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 } | 81 } |
| 79 {% endif %} | 82 {% endif %} |
| 80 {% if argument.idl_type in ['Dictionary', 'Promise'] %} | 83 {% if argument.idl_type in ['Dictionary', 'Promise'] %} |
| 81 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { | 84 if (!{{argument.name}}.isUndefinedOrNull() && !{{argument.name}}.isObject()) { |
| 82 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{ interface_name}}", "parameter {{argument.index + 1}} ('{{argument.name}}') is no t an object."), info.GetIsolate()); | 85 throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{ interface_name}}", "parameter {{argument.index + 1}} ('{{argument.name}}') is no t an object."), info.GetIsolate()); |
| 83 return; | 86 return; |
| 84 } | 87 } |
| 85 {% endif %} | 88 {% endif %} |
| 86 {% endfor %}{# arguments #} | 89 {% endfor %}{# arguments #} |
| 87 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in dent}} | 90 {{cpp_method_call(method, method.v8_set_return_value, method.cpp_value) | in dent}} |
| 91 {% endif %}{# addEventListener, removeEventListener #} | |
| 88 } | 92 } |
| 89 {% endfilter %} | 93 {% endfilter %} |
| 90 {% endmacro %} | 94 {% endmacro %} |
| 91 | 95 |
| 92 | 96 |
| 93 {######################################} | 97 {######################################} |
| 98 {% macro add_remove_event_listener_method(method_name) %} | |
| 99 {% set lookup_type, pass_ref_ptr_handling, hidden_dependency_action = | |
|
haraken
2013/11/13 08:33:53
Actually I don't understand why we need these comp
Nils Barth (inactive)
2013/11/13 11:33:29
Clarified by:
* adding a comment, and
* making the
haraken
2013/11/13 11:37:46
Can't we somehow get rid of the distinction betwee
Nils Barth (inactive)
2013/11/14 03:01:53
We probably need to generate *some* different code
haraken
2013/11/14 04:33:02
Yeah, I haven't yet checked the code of event list
| |
| 100 ('OrCreate', '', 'create') | |
| 101 if method_name.startswith('add') else | |
| 102 ('Only', '.get()', 'remove') | |
| 103 %} | |
| 104 EventTarget* impl = {{v8_class_name}}::toNative(info.Holder()); | |
| 105 if (DOMWindow* window = impl->toDOMWindow()) { | |
| 106 ExceptionState es(info.GetIsolate()); | |
| 107 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), es)) { | |
| 108 es.throwIfNeeded(); | |
| 109 return; | |
| 110 } | |
| 111 if (!window->document()) | |
| 112 return; | |
| 113 } | |
| 114 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[1], false, ListenerFind{{lookup_type}}); | |
| 115 if (listener) { | |
| 116 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, string Resource, info[0]); | |
|
haraken
2013/11/13 08:33:53
stringResource => eventName ?
Nils Barth (inactive)
2013/11/13 11:33:29
Done.
| |
| 117 impl->{{method_name}}(stringResource, listener{{pass_ref_ptr_handling}}, inf o[2]->BooleanValue()); | |
| 118 if (!impl->toNode()) | |
| 119 {{hidden_dependency_action}}HiddenDependency(info.Holder(), info[1], {{v 8_class_name}}::eventListenerCacheIndex, info.GetIsolate()); | |
|
haraken
2013/11/13 08:33:53
Probably we need to refactor *HiddenDependency cod
Nils Barth (inactive)
2013/11/13 11:33:29
Got it; added to TODO, and will look into.
Quick
haraken
2013/11/14 04:33:02
Regarding hidden dependency, kouhei-san might have
Nils Barth (inactive)
2013/11/14 05:47:20
Thanks, will do!
| |
| 120 } | |
| 121 {% endmacro %} | |
| 122 | |
| 123 | |
| 124 {######################################} | |
| 94 {% macro cpp_method_call(method, v8_set_return_value, cpp_value) %} | 125 {% macro cpp_method_call(method, v8_set_return_value, cpp_value) %} |
| 95 {% if method.is_call_with_script_state %} | 126 {% if method.is_call_with_script_state %} |
| 96 ScriptState* currentState = ScriptState::current(); | 127 ScriptState* currentState = ScriptState::current(); |
| 97 if (!currentState) | 128 if (!currentState) |
| 98 return; | 129 return; |
| 99 ScriptState& state = *currentState; | 130 ScriptState& state = *currentState; |
| 100 {% endif %} | 131 {% endif %} |
| 101 {% if method.is_call_with_execution_context %} | 132 {% if method.is_call_with_execution_context %} |
| 102 ExecutionContext* scriptContext = getExecutionContext(); | 133 ExecutionContext* scriptContext = getExecutionContext(); |
| 103 {% endif %} | 134 {% endif %} |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 {% endif %} | 201 {% endif %} |
| 171 {% if method.is_custom %} | 202 {% if method.is_custom %} |
| 172 {{v8_class_name}}::{{method.name}}MethodCustom(info); | 203 {{v8_class_name}}::{{method.name}}MethodCustom(info); |
| 173 {% else %} | 204 {% else %} |
| 174 {{cpp_class_name}}V8Internal::{{method.name}}Method{{world_suffix}}(info); | 205 {{cpp_class_name}}V8Internal::{{method.name}}Method{{world_suffix}}(info); |
| 175 {% endif %} | 206 {% endif %} |
| 176 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 207 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 177 } | 208 } |
| 178 {% endfilter %} | 209 {% endfilter %} |
| 179 {% endmacro %} | 210 {% endmacro %} |
| OLD | NEW |