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

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

Issue 2106983002: Allow origin trials to be declared on IDL operations (methods) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing unneeded includes, addressing nits Created 4 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
OLDNEW
1 {% include 'copyright_block.txt' %} 1 {% include 'copyright_block.txt' %}
2 #include "{{v8_class_or_partial}}.h" 2 #include "{{v8_class_or_partial}}.h"
3 3
4 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} 4 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
5 #include "{{filename}}" 5 #include "{{filename}}"
6 {% endfor %} 6 {% endfor %}
7 7
8 namespace blink { 8 namespace blink {
9 {% set to_active_scriptwrappable = '%s::toActiveScriptWrappable' % v8_class 9 {% set to_active_scriptwrappable = '%s::toActiveScriptWrappable' % v8_class
10 if active_scriptwrappable else '0' %} 10 if active_scriptwrappable else '0' %}
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 {% for attribute in attributes | has_accessor_configuration %} 211 {% for attribute in attributes | has_accessor_configuration %}
212 {{attribute_configuration(attribute)}}, 212 {{attribute_configuration(attribute)}},
213 {% endfor %} 213 {% endfor %}
214 }; 214 };
215 215
216 {% endif %} 216 {% endif %}
217 {% endblock %} 217 {% endblock %}
218 {##############################################################################} 218 {##############################################################################}
219 {% block install_methods %} 219 {% block install_methods %}
220 {% from 'methods.cpp' import method_configuration with context %} 220 {% from 'methods.cpp' import method_configuration with context %}
221 {% if method_configuration_methods %} 221 {% if methods | has_method_configuration(is_partial) %}
222 const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = { 222 const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = {
223 {% for method in method_configuration_methods %} 223 {% for method in methods | has_method_configuration(is_partial) %}
224 {{method_configuration(method)}}, 224 {{method_configuration(method)}},
225 {% endfor %} 225 {% endfor %}
226 }; 226 };
227 227
228 {% endif %} 228 {% endif %}
229 {% endblock %} 229 {% endblock %}
230 {% endif %}{# not is_array_buffer_or_view #} 230 {% endif %}{# not is_array_buffer_or_view #}
231 {##############################################################################} 231 {##############################################################################}
232 {% block named_constructor %}{% endblock %} 232 {% block named_constructor %}{% endblock %}
233 {% block constructor_callback %}{% endblock %} 233 {% block constructor_callback %}{% endblock %}
234 {##############################################################################} 234 {##############################################################################}
235 {% block install_dom_template %} 235 {% block install_dom_template %}
236 {% if not is_array_buffer_or_view %} 236 {% if not is_array_buffer_or_view %}
237 {% from 'methods.cpp' import install_custom_signature with context %} 237 {% from 'methods.cpp' import install_custom_signature with context %}
238 {% from 'attributes.cpp' import attribute_configuration with context %} 238 {% from 'attributes.cpp' import attribute_configuration with context %}
239 {% from 'constants.cpp' import install_constants with context %} 239 {% from 'constants.cpp' import install_constants with context %}
240 {% from 'methods.cpp' import method_configuration with context %}
240 {% if has_partial_interface or is_partial %} 241 {% if has_partial_interface or is_partial %}
241 void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) 242 void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate)
242 {% else %} 243 {% else %}
243 static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo rld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) 244 static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo rld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate)
244 {% endif %} 245 {% endif %}
245 { 246 {
246 {% set newline = '' %} 247 {% set newline = '' %}
247 // Initialize the interface object's template. 248 // Initialize the interface object's template.
248 {% if is_partial %} 249 {% if is_partial %}
249 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate) ; 250 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate) ;
(...skipping 25 matching lines...) Expand all
275 {% filter runtime_enabled(runtime_enabled_function) %} 276 {% filter runtime_enabled(runtime_enabled_function) %}
276 {% if constants %} 277 {% if constants %}
277 {{install_constants() | indent}} 278 {{install_constants() | indent}}
278 {% endif %} 279 {% endif %}
279 {% if attributes | has_attribute_configuration %} 280 {% if attributes | has_attribute_configuration %}
280 V8DOMConfiguration::installAttributes(isolate, world, instanceTemplate, prot otypeTemplate, {{'%sAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class}}); 281 V8DOMConfiguration::installAttributes(isolate, world, instanceTemplate, prot otypeTemplate, {{'%sAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class}});
281 {% endif %} 282 {% endif %}
282 {% if attributes | has_accessor_configuration %} 283 {% if attributes | has_accessor_configuration %}
283 V8DOMConfiguration::installAccessors(isolate, world, instanceTemplate, proto typeTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF _ARRAY_LENGTH(%sAccessors)' % v8_class}}); 284 V8DOMConfiguration::installAccessors(isolate, world, instanceTemplate, proto typeTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF _ARRAY_LENGTH(%sAccessors)' % v8_class}});
284 {% endif %} 285 {% endif %}
285 {% if method_configuration_methods %} 286 {% if methods | has_method_configuration(is_partial) %}
286 V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototy peTemplate, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARR AY_LENGTH(%sMethods)' % v8_class}}); 287 V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototy peTemplate, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARR AY_LENGTH(%sMethods)' % v8_class}});
287 {% endif %} 288 {% endif %}
288 {% endfilter %} 289 {% endfilter %}
289 {%- if has_access_check_callbacks and not is_partial %}{{newline}} 290 {%- if has_access_check_callbacks and not is_partial %}{{newline}}
290 // Cross-origin access check 291 // Cross-origin access check
291 instanceTemplate->SetAccessCheckCallback({{cpp_class}}V8Internal::securityCh eck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrap perTypeInfo))); 292 instanceTemplate->SetAccessCheckCallback({{cpp_class}}V8Internal::securityCh eck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrap perTypeInfo)));
292 {% endif %} 293 {% endif %}
293 294
294 {%- if has_array_iterator and not is_partial and not is_global %}{{newline}} 295 {%- if has_array_iterator and not is_partial and not is_global %}{{newline}}
295 // Array iterator 296 // Array iterator
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 334
334 {%- if has_custom_legacy_call_as_function and not is_partial %}{{newline}} 335 {%- if has_custom_legacy_call_as_function and not is_partial %}{{newline}}
335 instanceTemplate->SetCallAsFunctionHandler({{v8_class}}::legacyCallCustom); 336 instanceTemplate->SetCallAsFunctionHandler({{v8_class}}::legacyCallCustom);
336 {% endif %} 337 {% endif %}
337 338
338 {%- if interface_name == 'HTMLAllCollection' and not is_partial %}{{newline} } 339 {%- if interface_name == 'HTMLAllCollection' and not is_partial %}{{newline} }
339 // Needed for legacy support of document.all 340 // Needed for legacy support of document.all
340 instanceTemplate->MarkAsUndetectable(); 341 instanceTemplate->MarkAsUndetectable();
341 {% endif %} 342 {% endif %}
342 343
343 {%- if custom_registration_methods %}{{newline}} 344 {%- if methods | custom_registration(is_partial) %}{{newline}}
344 {% for method in custom_registration_methods %} 345 {% for method in methods | custom_registration(is_partial) %}
345 {# install_custom_signature #} 346 {# install_custom_signature #}
346 {% filter exposed(method.overloads.exposed_test_all 347 {% filter exposed(method.overloads.exposed_test_all
347 if method.overloads else 348 if method.overloads else
348 method.exposed_test) %} 349 method.exposed_test) %}
349 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all 350 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
350 if method.overloads else 351 if method.overloads else
351 method.runtime_enabled_function) %} 352 method.runtime_enabled_function) %}
352 {% if method.is_do_not_check_security %} 353 {% if method.is_do_not_check_security %}
353 {{install_do_not_check_security_method(method, '', 'instanceTemplate', 'prot otypeTemplate') | indent}} 354 {{install_do_not_check_security_method(method, '', 'instanceTemplate', 'prot otypeTemplate') | indent}}
354 {% else %} 355 {% else %}
355 {{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'interfaceTemplate', 'signature') | indent}} 356 {{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'interfaceTemplate', 'signature') | indent}}
356 {% endif %} 357 {% endif %}
357 {% endfilter %} 358 {% endfilter %}
358 {% endfilter %} 359 {% endfilter %}
359 {% endfor %} 360 {% endfor %}
360 {% endif %} 361 {% endif %}
361 } 362 }
362 363
363 {% endif %}{# not is_array_buffer_or_view #} 364 {% endif %}{# not is_array_buffer_or_view #}
364 {% endblock %} 365 {% endblock %}
365 {##############################################################################} 366 {##############################################################################}
366 {% block origin_trials %} 367 {% block origin_trials %}
367 {% from 'attributes.cpp' import attribute_configuration with context %} 368 {% from 'attributes.cpp' import attribute_configuration with context %}
368 {% from 'constants.cpp' import constant_configuration with context %} 369 {% from 'constants.cpp' import constant_configuration with context %}
370 {% from 'methods.cpp' import method_configuration with context %}
369 {% for origin_trial_feature_name in origin_trial_feature_names %}{{newline}} 371 {% for origin_trial_feature_name in origin_trial_feature_names %}{{newline}}
370 void {{v8_class_or_partial}}::install{{origin_trial_feature_name}}(ScriptState* scriptState, v8::Local<v8::Object> instance) 372 void {{v8_class_or_partial}}::install{{origin_trial_feature_name}}(ScriptState* scriptState, v8::Local<v8::Object> instance)
371 { 373 {
372 v8::Local<v8::Object> prototype = instance->GetPrototype()->ToObject(scriptS tate->isolate()); 374 v8::Local<v8::Object> prototype = instance->GetPrototype()->ToObject(scriptS tate->isolate());
375
373 {# Origin-Trial-enabled attributes #} 376 {# Origin-Trial-enabled attributes #}
374 {% if attributes | for_origin_trial_feature(origin_trial_feature_name) %} 377 {% if attributes | for_origin_trial_feature(origin_trial_feature_name) or
378 methods | method_for_origin_trial_feature(origin_trial_feature_name, i s_partial) %}
375 V8PerIsolateData* perIsolateData = V8PerIsolateData::from(scriptState->isola te()); 379 V8PerIsolateData* perIsolateData = V8PerIsolateData::from(scriptState->isola te());
376 v8::Local<v8::FunctionTemplate> interfaceTemplate = perIsolateData->findInte rfaceTemplate(scriptState->world(), &{{v8_class}}::wrapperTypeInfo); 380 v8::Local<v8::FunctionTemplate> interfaceTemplate = perIsolateData->findInte rfaceTemplate(scriptState->world(), &{{v8_class}}::wrapperTypeInfo);
377 v8::Local<v8::Signature> signature = v8::Signature::New(scriptState->isolate (), interfaceTemplate); 381 v8::Local<v8::Signature> signature = v8::Signature::New(scriptState->isolate (), interfaceTemplate);
378 ALLOW_UNUSED_LOCAL(signature); 382 ALLOW_UNUSED_LOCAL(signature);
383 {% endif %}
384 {% if constants | for_origin_trial_feature(origin_trial_feature_name) or
385 methods | method_for_origin_trial_feature(origin_trial_feature_name, i s_partial) %}
386 V8PerContextData* perContextData = V8PerContextData::from(scriptState->conte xt());
387 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8 _class}}::wrapperTypeInfo);
388 {% endif %}
379 {% for attribute in attributes | for_origin_trial_feature(origin_trial_featu re_name) | unique_by('name') | sort %} 389 {% for attribute in attributes | for_origin_trial_feature(origin_trial_featu re_name) | unique_by('name') | sort %}
380 {% if attribute.is_data_type_property %} 390 {% if attribute.is_data_type_property %}
381 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}} Configuration = \ 391 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}} Configuration = \
382 {{attribute_configuration(attribute)}}; 392 {{attribute_configuration(attribute)}};
383 V8DOMConfiguration::installAttribute(scriptState->isolate(), scriptState->wo rld(), instance, prototype, attribute{{attribute.name}}Configuration); 393 V8DOMConfiguration::installAttribute(scriptState->isolate(), scriptState->wo rld(), instance, prototype, attribute{{attribute.name}}Configuration);
384 {% else %} 394 {% else %}
385 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co nfiguration = \ 395 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co nfiguration = \
386 {{attribute_configuration(attribute)}}; 396 {{attribute_configuration(attribute)}};
387 V8DOMConfiguration::installAccessor(scriptState->isolate(), scriptState->wor ld(), instance, prototype, v8::Local<v8::Function>(), signature, accessor{{attri bute.name}}Configuration); 397 V8DOMConfiguration::installAccessor(scriptState->isolate(), scriptState->wor ld(), instance, prototype, v8::Local<v8::Function>(), signature, accessor{{attri bute.name}}Configuration);
388 {% endif %} 398 {% endif %}
389 {% endfor %} 399 {% endfor %}
390 {% endif %}
391
392 {# Origin-Trial-enabled constants #} 400 {# Origin-Trial-enabled constants #}
393 {% if constants | for_origin_trial_feature(origin_trial_feature_name) %}
394 V8PerContextData* perContextData = V8PerContextData::from(scriptState->conte xt());
395 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8 _class}}::wrapperTypeInfo);
396 {% for constant in constants | for_origin_trial_feature(origin_trial_feature _name) | unique_by('name') | sort %} 401 {% for constant in constants | for_origin_trial_feature(origin_trial_feature _name) | unique_by('name') | sort %}
397 {% set constant_name = constant.name.title().replace('_', '') %} 402 {% set constant_name = constant.name.title().replace('_', '') %}
398 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Con figuration = {{constant_configuration(constant)}}; 403 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Con figuration = {{constant_configuration(constant)}};
399 V8DOMConfiguration::installConstant(scriptState->isolate(), interface, proto type, constant{{constant_name}}Configuration); 404 V8DOMConfiguration::installConstant(scriptState->isolate(), interface, proto type, constant{{constant_name}}Configuration);
400 {% endfor %} 405 {% endfor %}
401 {% endif %} 406 {# Origin-Trial-enabled methods (no overloads) #}
407 {% for method in methods | method_for_origin_trial_feature(origin_trial_feat ure_name, is_partial) | unique_by('name') | sort %}
408 {% set method_name = method.name.title().replace('_', '') %}
409 const V8DOMConfiguration::MethodConfiguration method{{method_name}}Configura tion = {{method_configuration(method)}};
410 V8DOMConfiguration::installMethod(scriptState->isolate(), scriptState->world (), instance, prototype, interface, signature, method{{method_name}}Configuratio n);
411 {% endfor %}
402 } 412 }
403 {% endfor %} 413 {% endfor %}
404 {% endblock %} 414 {% endblock %}
405 {##############################################################################} 415 {##############################################################################}
406 {% block get_dom_template %}{% endblock %} 416 {% block get_dom_template %}{% endblock %}
407 {% block get_dom_template_for_named_properties_object %}{% endblock %} 417 {% block get_dom_template_for_named_properties_object %}{% endblock %}
408 {% block has_instance %}{% endblock %} 418 {% block has_instance %}{% endblock %}
409 {% block to_impl %}{% endblock %} 419 {% block to_impl %}{% endblock %}
410 {% block to_impl_with_type_check %}{% endblock %} 420 {% block to_impl_with_type_check %}{% endblock %}
411 {% block install_conditional_attributes %}{% endblock %} 421 {% block install_conditional_attributes %}{% endblock %}
412 {##############################################################################} 422 {##############################################################################}
413 {% block prepare_prototype_and_interface_object %}{% endblock %} 423 {% block prepare_prototype_and_interface_object %}{% endblock %}
414 {##############################################################################} 424 {##############################################################################}
415 {% block to_active_scriptwrappable %}{% endblock %} 425 {% block to_active_scriptwrappable %}{% endblock %}
416 {% for method in methods if method.is_implemented_in_private_script and method.v isible %} 426 {% for method in methods if method.is_implemented_in_private_script and method.v isible %}
417 {{method_implemented_in_private_script(method)}} 427 {{method_implemented_in_private_script(method)}}
418 {% endfor %} 428 {% endfor %}
419 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 429 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
420 {{attribute_getter_implemented_in_private_script(attribute)}} 430 {{attribute_getter_implemented_in_private_script(attribute)}}
421 {% if attribute.has_setter %} 431 {% if attribute.has_setter %}
422 {{attribute_setter_implemented_in_private_script(attribute)}} 432 {{attribute_setter_implemented_in_private_script(attribute)}}
423 {% endif %} 433 {% endif %}
424 {% endfor %} 434 {% endfor %}
425 {% block partial_interface %}{% endblock %} 435 {% block partial_interface %}{% endblock %}
426 } // namespace blink 436 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/interface.cpp ('k') | third_party/WebKit/Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698