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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl

Issue 2837923003: Make NodeFilter a legacy callback interface. (Closed)
Patch Set: legacy_callback_interface.*.tmpl, etc. Created 3 years, 7 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
OLDNEW
1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% macro generate_method(method, world_suffix) %} 4 {% macro generate_method(method, world_suffix) %}
5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) { 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) {
6 {% filter format_remove_duplicates([ 6 {% filter format_remove_duplicates([
7 'ExceptionState exceptionState', 7 'ExceptionState exceptionState',
8 'ScriptState* scriptState = ']) %} 8 'ScriptState* scriptState = ']) %}
9 {% set define_exception_state -%} 9 {% set define_exception_state -%}
10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionCon text, "{{interface_name}}", "{{method.name}}"); 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionCon text, "{{interface_name}}", "{{method.name}}");
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (UNLIKELY(numArgsPassed <= {{argument.index}})) { 130 if (UNLIKELY(numArgsPassed <= {{argument.index}})) {
131 {% if world_suffix %} 131 {% if world_suffix %}
132 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argumen t.cpp_value) | indent(2)}} 132 {{cpp_method_call(method, argument.v8_set_return_value_for_main_world, argumen t.cpp_value) | indent(2)}}
133 {% else %} 133 {% else %}
134 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent(2)}} 134 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent(2)}}
135 {% endif %} 135 {% endif %}
136 return; 136 return;
137 } 137 }
138 {% endif %} 138 {% endif %}
139 {% if argument.is_callback_interface %} 139 {% if argument.is_callback_interface %}
140 {# FIXME: remove EventListener special case #} 140 {# FIXME: remove EventListener/NodeFilter special case. crbug.com/630986 #}
141 {% if argument.idl_type == 'EventListener' %} 141 {% if argument.idl_type == 'EventListener' %}
142 {% if method.name == 'RemoveEventListener' or method.name == 'RemoveListener' %} 142 {% if method.name == 'RemoveEventListener' or method.name == 'RemoveListener' %}
143 {{argument.name}} = V8EventListenerHelper::GetEventListener(ScriptState::Current (info.GetIsolate()), info[{{argument.index}}], false, kListenerFindOnly); 143 {{argument.name}} = V8EventListenerHelper::GetEventListener(ScriptState::Current (info.GetIsolate()), info[{{argument.index}}], false, kListenerFindOnly);
144 {% else %}{# method.name == 'AddEventListener' #} 144 {% else %}{# method.name == 'AddEventListener' #}
145 {{argument.name}} = V8EventListenerHelper::GetEventListener(ScriptState::Current (info.GetIsolate()), info[{{argument.index}}], false, kListenerFindOrCreate); 145 {{argument.name}} = V8EventListenerHelper::GetEventListener(ScriptState::Current (info.GetIsolate()), info[{{argument.index}}], false, kListenerFindOrCreate);
146 {% endif %}{# method.name #} 146 {% endif %}{# method.name #}
147 {% else %}{# argument.idl_type == 'EventListener' #} 147 {% elif argument.idl_type == 'NodeFilter' %}
148 {{argument.name}} = V8NodeFilterCondition::CreateOrNull(info[{{argument.index}}] , ScriptState::Current(info.GetIsolate()));
149 {% else %}{# argument.idl_type == 'EventListener'/'NodeFilter #}
148 {# Callback functions must be functions: 150 {# Callback functions must be functions:
149 http://www.w3.org/TR/WebIDL/#es-callback-function #} 151 http://www.w3.org/TR/WebIDL/#es-callback-function #}
150 {% if argument.is_optional %} 152 {% if argument.is_optional %}
151 if (!IsUndefinedOrNull(info[{{argument.index}}])) { 153 if (!IsUndefinedOrNull(info[{{argument.index}}])) {
152 if (!info[{{argument.index}}]->IsFunction()) { 154 if (!info[{{argument.index}}]->IsFunction()) {
153 {{throw_argument_error(method, argument, "The callback provided as parameter %(index)d is not a function.")}} 155 {{throw_argument_error(method, argument, "The callback provided as parameter %(index)d is not a function.")}}
154 return; 156 return;
155 } 157 }
156 {{argument.name}} = V8{{argument.idl_type}}::Create(v8::Local<v8::Function>::C ast(info[{{argument.index}}]), ScriptState::Current(info.GetIsolate())); 158 {{argument.name}} = V8{{argument.idl_type}}::Create(v8::Local<v8::Function>::C ast(info[{{argument.index}}]), ScriptState::Current(info.GetIsolate()));
157 } else { 159 } else {
158 {{argument.name}} = nullptr; 160 {{argument.name}} = nullptr;
159 } 161 }
160 {% else %}{# argument.is_optional #} 162 {% else %}{# argument.is_optional #}
161 if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{ {argument.index}}]->IsFunction() || info[{{argument.index}}]->IsNull()){% else % }info[{{argument.index}}]->IsFunction(){% endif %}) { 163 if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{ {argument.index}}]->IsFunction() || info[{{argument.index}}]->IsNull()){% else % }info[{{argument.index}}]->IsFunction(){% endif %}) {
162 {{throw_argument_error(method, argument, "The callback provided as parameter % (index)d is not a function.")}} 164 {{throw_argument_error(method, argument, "The callback provided as parameter % (index)d is not a function.")}}
163 return; 165 return;
164 } 166 }
165 {{argument.name}} = {% if argument.is_nullable %}info[{{argument.index}}]->IsNul l() ? nullptr : {% endif %}V8{{argument.idl_type}}::Create(v8::Local<v8::Functio n>::Cast(info[{{argument.index}}]), ScriptState::Current(info.GetIsolate())); 167 {{argument.name}} = {% if argument.is_nullable %}info[{{argument.index}}]->IsNul l() ? nullptr : {% endif %}V8{{argument.idl_type}}::Create(v8::Local<v8::Functio n>::Cast(info[{{argument.index}}]), ScriptState::Current(info.GetIsolate()));
166 {% endif %}{# argument.is_optional #} 168 {% endif %}{# argument.is_optional #}
167 {% endif %}{# argument.idl_type == 'EventListener' #} 169 {% endif %}{# argument.idl_type == 'EventListener'/'NodeFilter' #}
168 {% elif argument.is_callback_function %} 170 {% elif argument.is_callback_function %}
169 if ({% if argument.is_nullable %}!IsUndefinedOrNull(info[{{argument.index}}]) && {% endif %}!(info[{{argument.index}}]->IsObject() && v8::Local<v8::Object>::Cas t(info[{{argument.index}}])->IsCallable())) { 171 if ({% if argument.is_nullable %}!IsUndefinedOrNull(info[{{argument.index}}]) && {% endif %}!(info[{{argument.index}}]->IsObject() && v8::Local<v8::Object>::Cas t(info[{{argument.index}}])->IsCallable())) {
170 {{throw_argument_error(method, argument, "The callback provided as parameter % (index)d is not a function.")}} 172 {{throw_argument_error(method, argument, "The callback provided as parameter % (index)d is not a function.")}}
171 return; 173 return;
172 } 174 }
173 {{v8_value_to_local_cpp_value(argument)}} 175 {{v8_value_to_local_cpp_value(argument)}}
174 {% elif argument.is_variadic_wrapper_type %} 176 {% elif argument.is_variadic_wrapper_type %}
175 for (int i = {{argument.index}}; i < info.Length(); ++i) { 177 for (int i = {{argument.index}}; i < info.Length(); ++i) {
176 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { 178 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) {
177 {{throw_argument_error(method, argument, "parameter %(index)d is not of type '%(type)s'.")}} 179 {{throw_argument_error(method, argument, "parameter %(index)d is not of type '%(type)s'.")}}
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 {{method_configuration(method) | indent(2)}} 652 {{method_configuration(method) | indent(2)}}
651 }; 653 };
652 for (const auto& methodConfig : {{method.name}}MethodConfiguration) 654 for (const auto& methodConfig : {{method.name}}MethodConfiguration)
653 V8DOMConfiguration::InstallMethod(isolate, world, v8::Local<v8::Object>(), pro totypeObject, interfaceObject, signature, methodConfig); 655 V8DOMConfiguration::InstallMethod(isolate, world, v8::Local<v8::Object>(), pro totypeObject, interfaceObject, signature, methodConfig);
654 {% endfilter %}{# runtime_enabled() #} 656 {% endfilter %}{# runtime_enabled() #}
655 {% endfilter %}{# exposed() #} 657 {% endfilter %}{# exposed() #}
656 {% endfilter %}{# secure_context() #} 658 {% endfilter %}{# secure_context() #}
657 {% endfor %} 659 {% endfor %}
658 {% endif %} 660 {% endif %}
659 {%- endmacro %} 661 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698