Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: Source/bindings/templates/methods.cpp

Issue 396283004: Make the MediaQueryList listener an EventListener (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 {# Local variables #} 6 {# Local variables #}
7 {% if method.has_exception_state %} 7 {% if method.has_exception_state %}
8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
9 {% endif %} 9 {% endif %}
10 {# Overloaded methods have length checked during overload resolution #} 10 {# Overloaded methods have length checked during overload resolution #}
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 argument instead; see argument.is_variadic_wrapper_type code-path below. #} 128 argument instead; see argument.is_variadic_wrapper_type code-path below. #}
129 if (info.Length() > {{argument.index}} && {% if argument.is_nullable %}!isUndefi nedOrNull(info[{{argument.index}}]) && {% endif %}!V8{{argument.idl_type}}::hasI nstance(info[{{argument.index}}], info.GetIsolate())) { 129 if (info.Length() > {{argument.index}} && {% if argument.is_nullable %}!isUndefi nedOrNull(info[{{argument.index}}]) && {% endif %}!V8{{argument.idl_type}}::hasI nstance(info[{{argument.index}}], info.GetIsolate())) {
130 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % 130 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
131 (argument.index + 1, argument.idl_type)) | indent }} 131 (argument.index + 1, argument.idl_type)) | indent }}
132 return; 132 return;
133 } 133 }
134 {% endif %}{# argument.has_type_checking_interface #} 134 {% endif %}{# argument.has_type_checking_interface #}
135 {% if argument.is_callback_interface %} 135 {% if argument.is_callback_interface %}
136 {# FIXME: remove EventListener special case #} 136 {# FIXME: remove EventListener special case #}
137 {% if argument.idl_type == 'EventListener' %} 137 {% if argument.idl_type == 'EventListener' %}
138 {% if method.name == 'removeEventListener' %} 138 {% if method.name == 'removeEventListener' or method.name == 'removeListener' %}
139 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOnly); 139 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOnly);
140 {% else %}{# method.name == 'addEventListener' #} 140 {% else %}{# method.name == 'addEventListener' #}
141 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOrCreate); 141 {{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(i nfo.GetIsolate()), info[{{argument.index}}], false, ListenerFindOrCreate);
142 {% endif %}{# method.name #} 142 {% endif %}{# method.name #}
143 {% else %}{# argument.idl_type == 'EventListener' #} 143 {% else %}{# argument.idl_type == 'EventListener' #}
144 {# Callback functions must be functions: 144 {# Callback functions must be functions:
145 http://www.w3.org/TR/WebIDL/#es-callback-function #} 145 http://www.w3.org/TR/WebIDL/#es-callback-function #}
146 {% if argument.is_optional %} 146 {% if argument.is_optional %}
147 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind ex}}])) { 147 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind ex}}])) {
148 if (!info[{{argument.index}}]->IsFunction()) { 148 if (!info[{{argument.index}}]->IsFunction()) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 {# Post-set #} 280 {# Post-set #}
281 {% if interface_name == 'EventTarget' and method.name in ('addEventListener', 281 {% if interface_name == 'EventTarget' and method.name in ('addEventListener',
282 'removeEventListener') %} 282 'removeEventListener') %}
283 {% set hidden_dependency_action = 'addHiddenValueToArray' 283 {% set hidden_dependency_action = 'addHiddenValueToArray'
284 if method.name == 'addEventListener' else 'removeHiddenValueFromArray' %} 284 if method.name == 'addEventListener' else 'removeHiddenValueFromArray' %}
285 {# Length check needed to skip action on legacy calls without enough arguments. 285 {# Length check needed to skip action on legacy calls without enough arguments.
286 http://crbug.com/353484 #} 286 http://crbug.com/353484 #}
287 if (info.Length() >= 2 && listener && !impl->toNode()) 287 if (info.Length() >= 2 && listener && !impl->toNode())
288 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::eventList enerCacheIndex, info.GetIsolate()); 288 {{hidden_dependency_action}}(info.Holder(), info[1], {{v8_class}}::eventList enerCacheIndex, info.GetIsolate());
289 {% endif %} 289 {% endif %}
290 {% if interface_name == 'MediaQueryList' and method.name in ('addListener',
haraken 2014/07/20 05:14:49 Why does the MediaQueryList need separate code fro
cbiesinger 2014/07/21 22:07:19 Done.
291 'removeListener') % }
292 {% set hidden_dependency_action = 'addHiddenValueToArray'
293 if method.name == 'addListener' else 'removeHiddenValueFromArray' %}
294 if (listener)
295 {{hidden_dependency_action}}(info.Holder(), info[0], {{v8_class}}::eventList enerCacheIndex, info.GetIsolate());
296 {% endif %}
290 {% endmacro %} 297 {% endmacro %}
291 298
292 299
293 {######################################} 300 {######################################}
294 {% macro union_type_method_call_and_set_return_value(method) %} 301 {% macro union_type_method_call_and_set_return_value(method) %}
295 {% for cpp_type in method.cpp_type %} 302 {% for cpp_type in method.cpp_type %}
296 bool result{{loop.index0}}Enabled = false; 303 bool result{{loop.index0}}Enabled = false;
297 {{cpp_type}} result{{loop.index0}}; 304 {{cpp_type}} result{{loop.index0}};
298 {% endfor %} 305 {% endfor %}
299 {{method.cpp_value}}; 306 {{method.cpp_value}};
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIsolate ()); 600 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIsolate ());
594 {% else %} 601 {% else %}
595 {% set constructor_class = v8_class + ('Constructor' 602 {% set constructor_class = v8_class + ('Constructor'
596 if constructor.is_named_constructor else 603 if constructor.is_named_constructor else
597 '') %} 604 '') %}
598 v8::Handle<v8::Object> wrapper = info.Holder(); 605 v8::Handle<v8::Object> wrapper = info.Holder();
599 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_configurat ion}}); 606 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), {{wrapper_configurat ion}});
600 {% endif %} 607 {% endif %}
601 v8SetReturnValue(info, wrapper); 608 v8SetReturnValue(info, wrapper);
602 {% endmacro %} 609 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698