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

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

Issue 2130883002: [OriginTrials] Allow origin trials to be installed without an instance object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 {% endif %} 361 {% endif %}
362 } 362 }
363 363
364 {% endif %}{# not is_array_buffer_or_view #} 364 {% endif %}{# not is_array_buffer_or_view #}
365 {% endblock %} 365 {% endblock %}
366 {##############################################################################} 366 {##############################################################################}
367 {% block origin_trials %} 367 {% block origin_trials %}
368 {% from 'attributes.cpp' import attribute_configuration with context %} 368 {% from 'attributes.cpp' import attribute_configuration with context %}
369 {% 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 %} 370 {% from 'methods.cpp' import method_configuration with context %}
371 {% for origin_trial_feature_name in origin_trial_feature_names %}{{newline}} 371 {% for origin_trial_feature in origin_trial_features %}{{newline}}
372 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)
373 { 373 {
374 v8::Local<v8::Object> prototype = instance->GetPrototype()->ToObject(scriptS tate->isolate()); 374 {% if attributes | for_origin_trial_feature(origin_trial_feature.name) or
375 375 methods | method_for_origin_trial_feature(origin_trial_feature.name, i s_partial) %}
376 {# Origin-Trial-enabled attributes #} 376 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTyp eInfo.domTemplate(scriptState->isolate(), scriptState->world());
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) %}
379 V8PerIsolateData* perIsolateData = V8PerIsolateData::from(scriptState->isola te());
380 v8::Local<v8::FunctionTemplate> interfaceTemplate = perIsolateData->findInte rfaceTemplate(scriptState->world(), &{{v8_class}}::wrapperTypeInfo);
381 v8::Local<v8::Signature> signature = v8::Signature::New(scriptState->isolate (), interfaceTemplate); 377 v8::Local<v8::Signature> signature = v8::Signature::New(scriptState->isolate (), interfaceTemplate);
382 ALLOW_UNUSED_LOCAL(signature); 378 ALLOW_UNUSED_LOCAL(signature);
383 {% endif %} 379 {% endif %}
384 V8PerContextData* perContextData = V8PerContextData::from(scriptState->conte xt()); 380 V8PerContextData* perContextData = V8PerContextData::from(scriptState->conte xt());
381 v8::Local<v8::Object> prototype = perContextData->prototypeForType(&{{v8_cla ss}}::wrapperTypeInfo);
385 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8 _class}}::wrapperTypeInfo); 382 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8 _class}}::wrapperTypeInfo);
386 ALLOW_UNUSED_LOCAL(interface); 383 ALLOW_UNUSED_LOCAL(interface);
387 {% for attribute in attributes | for_origin_trial_feature(origin_trial_featu re_name) | unique_by('name') | sort %} 384 {# Origin-Trial-enabled attributes #}
385 {% for attribute in attributes | for_origin_trial_feature(origin_trial_featu re.name) | unique_by('name') | sort %}
388 {% if attribute.is_data_type_property %} 386 {% if attribute.is_data_type_property %}
389 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}} Configuration = \ 387 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}} Configuration = \
390 {{attribute_configuration(attribute)}}; 388 {{attribute_configuration(attribute)}};
391 V8DOMConfiguration::installAttribute(scriptState->isolate(), scriptState->wo rld(), instance, prototype, attribute{{attribute.name}}Configuration); 389 V8DOMConfiguration::installAttribute(scriptState->isolate(), scriptState->wo rld(), instance, prototype, attribute{{attribute.name}}Configuration);
392 {% else %} 390 {% else %}
393 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co nfiguration = \ 391 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co nfiguration = \
394 {{attribute_configuration(attribute)}}; 392 {{attribute_configuration(attribute)}};
395 V8DOMConfiguration::installAccessor(scriptState->isolate(), scriptState->wor ld(), instance, prototype, interface, signature, accessor{{attribute.name}}Confi guration); 393 V8DOMConfiguration::installAccessor(scriptState->isolate(), scriptState->wor ld(), instance, prototype, interface, signature, accessor{{attribute.name}}Confi guration);
396 {% endif %} 394 {% endif %}
397 {% endfor %} 395 {% endfor %}
398 {# Origin-Trial-enabled constants #} 396 {# Origin-Trial-enabled constants #}
399 {% for constant in constants | for_origin_trial_feature(origin_trial_feature _name) | unique_by('name') | sort %} 397 {% for constant in constants | for_origin_trial_feature(origin_trial_feature .name) | unique_by('name') | sort %}
400 {% set constant_name = constant.name.title().replace('_', '') %} 398 {% set constant_name = constant.name.title().replace('_', '') %}
401 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Con figuration = {{constant_configuration(constant)}}; 399 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Con figuration = {{constant_configuration(constant)}};
402 V8DOMConfiguration::installConstant(scriptState->isolate(), interface, proto type, constant{{constant_name}}Configuration); 400 V8DOMConfiguration::installConstant(scriptState->isolate(), interface, proto type, constant{{constant_name}}Configuration);
403 {% endfor %} 401 {% endfor %}
404 {# Origin-Trial-enabled methods (no overloads) #} 402 {# Origin-Trial-enabled methods (no overloads) #}
405 {% for method in methods | method_for_origin_trial_feature(origin_trial_feat ure_name, is_partial) | unique_by('name') | sort %} 403 {% for method in methods | method_for_origin_trial_feature(origin_trial_feat ure.name, is_partial) | unique_by('name') | sort %}
406 {% set method_name = method.name.title().replace('_', '') %} 404 {% set method_name = method.name.title().replace('_', '') %}
407 const V8DOMConfiguration::MethodConfiguration method{{method_name}}Configura tion = {{method_configuration(method)}}; 405 const V8DOMConfiguration::MethodConfiguration method{{method_name}}Configura tion = {{method_configuration(method)}};
408 V8DOMConfiguration::installMethod(scriptState->isolate(), scriptState->world (), instance, prototype, interface, signature, method{{method_name}}Configuratio n); 406 V8DOMConfiguration::installMethod(scriptState->isolate(), scriptState->world (), instance, prototype, interface, signature, method{{method_name}}Configuratio n);
409 {% endfor %} 407 {% endfor %}
410 } 408 }
409 {% if not origin_trial_feature.needs_instance %}
410
411 void {{v8_class_or_partial}}::install{{origin_trial_feature.name}}(ScriptState* scriptState)
412 {
413 install{{origin_trial_feature.name}}(scriptState, v8::Local<v8::Object>());
414 }
415 {% endif %}
411 {% endfor %} 416 {% endfor %}
412 {% endblock %} 417 {% endblock %}
413 {##############################################################################} 418 {##############################################################################}
414 {% block get_dom_template %}{% endblock %} 419 {% block get_dom_template %}{% endblock %}
415 {% block get_dom_template_for_named_properties_object %}{% endblock %} 420 {% block get_dom_template_for_named_properties_object %}{% endblock %}
416 {% block has_instance %}{% endblock %} 421 {% block has_instance %}{% endblock %}
417 {% block to_impl %}{% endblock %} 422 {% block to_impl %}{% endblock %}
418 {% block to_impl_with_type_check %}{% endblock %} 423 {% block to_impl_with_type_check %}{% endblock %}
419 {% block install_conditional_attributes %}{% endblock %} 424 {% block install_conditional_attributes %}{% endblock %}
420 {##############################################################################} 425 {##############################################################################}
421 {% block prepare_prototype_and_interface_object %}{% endblock %} 426 {% block prepare_prototype_and_interface_object %}{% endblock %}
422 {##############################################################################} 427 {##############################################################################}
423 {% block to_active_scriptwrappable %}{% endblock %} 428 {% block to_active_scriptwrappable %}{% endblock %}
424 {% for method in methods if method.is_implemented_in_private_script and method.v isible %} 429 {% for method in methods if method.is_implemented_in_private_script and method.v isible %}
425 {{method_implemented_in_private_script(method)}} 430 {{method_implemented_in_private_script(method)}}
426 {% endfor %} 431 {% endfor %}
427 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 432 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
428 {{attribute_getter_implemented_in_private_script(attribute)}} 433 {{attribute_getter_implemented_in_private_script(attribute)}}
429 {% if attribute.has_setter %} 434 {% if attribute.has_setter %}
430 {{attribute_setter_implemented_in_private_script(attribute)}} 435 {{attribute_setter_implemented_in_private_script(attribute)}}
431 {% endif %} 436 {% endif %}
432 {% endfor %} 437 {% endfor %}
433 {% block partial_interface %}{% endblock %} 438 {% block partial_interface %}{% endblock %}
434 } // namespace blink 439 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698