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

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

Issue 2057273002: [OriginTrials] Support OriginTrialEnabled IDL attribute on constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make constants immutable, get interface template properly, improve efficiency Created 4 years, 6 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 {% endfilter %} 358 {% endfilter %}
359 {% endfor %} 359 {% endfor %}
360 {% endif %} 360 {% endif %}
361 } 361 }
362 362
363 {% endif %}{# not is_array_buffer_or_view #} 363 {% endif %}{# not is_array_buffer_or_view #}
364 {% endblock %} 364 {% endblock %}
365 {##############################################################################} 365 {##############################################################################}
366 {% block origin_trials %} 366 {% block origin_trials %}
367 {% from 'attributes.cpp' import attribute_configuration with context %} 367 {% from 'attributes.cpp' import attribute_configuration with context %}
368 {% for group in attributes|origin_trial_enabled_attributes|groupby('origin_trial _feature_name') %}{{newline}} 368 {% from 'constants.cpp' import constant_configuration with context %}
369 void {{v8_class_or_partial}}::install{{group.grouper}}(ScriptState* scriptState, v8::Local<v8::Object> instance) 369 {% 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)
370 { 371 {
371 v8::Local<v8::Object> prototype = instance->GetPrototype()->ToObject(scriptS tate->isolate()); 372 v8::Local<v8::Object> prototype = instance->GetPrototype()->ToObject(scriptS tate->isolate());
372 v8::Local<v8::Signature> signature; 373 {# Origin-Trial-enabled attributes #}
373 ALLOW_UNUSED_LOCAL(signature); 374 {% if attributes | for_origin_trial_feature(origin_trial_feature_name) %}
374 {% for attribute in group.list | unique_by('name') | sort %} 375 V8PerIsolateData* perIsolateData = V8PerIsolateData::from(scriptState->isola te());
376 v8::Local<v8::FunctionTemplate> interfaceTemplate = perIsolateData->findInte rfaceTemplate(scriptState->world(), &{{v8_class}}::wrapperTypeInfo);
377 ALLOW_UNUSED_LOCAL(interfaceTemplate);
378 {% for attribute in attributes | for_origin_trial_feature(origin_trial_featu re_name) | unique_by('name') | sort %}
375 {% if attribute.is_data_type_property %} 379 {% if attribute.is_data_type_property %}
376 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}} Configuration = \ 380 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}} Configuration = \
377 {{attribute_configuration(attribute)}}; 381 {{attribute_configuration(attribute)}};
378 V8DOMConfiguration::installAttribute(scriptState->isolate(), scriptState->wo rld(), instance, prototype, attribute{{attribute.name}}Configuration); 382 V8DOMConfiguration::installAttribute(scriptState->isolate(), scriptState->wo rld(), instance, prototype, attribute{{attribute.name}}Configuration);
379 {% else %} 383 {% else %}
380 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co nfiguration = \ 384 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co nfiguration = \
381 {{attribute_configuration(attribute)}}; 385 {{attribute_configuration(attribute)}};
386 v8::Local<v8::Signature> signature = v8::Signature::New(scriptState->isolate (), interfaceTemplate);
Yuki 2016/06/17 05:37:47 You don't need to create |signature| every time in
iclelland 2016/06/17 06:08:49 Done.
382 V8DOMConfiguration::installAccessor(scriptState->isolate(), scriptState->wor ld(), instance, prototype, v8::Local<v8::Function>(), signature, accessor{{attri bute.name}}Configuration); 387 V8DOMConfiguration::installAccessor(scriptState->isolate(), scriptState->wor ld(), instance, prototype, v8::Local<v8::Function>(), signature, accessor{{attri bute.name}}Configuration);
383 {% endif %} 388 {% endif %}
384 {% endfor %} 389 {% endfor %}
390 {% endif %}
391
392 {# 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 %}
397 {% set constant_name = constant.name.title().replace('_', '') %}
398 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Con figuration = {{constant_configuration(constant)}};
399 V8DOMConfiguration::installConstant(scriptState->isolate(), interface, proto type, constant{{constant_name}}Configuration);
400 {% endfor %}
401 {% endif %}
385 } 402 }
386 {% endfor %} 403 {% endfor %}
387 {% endblock %} 404 {% endblock %}
388 {##############################################################################} 405 {##############################################################################}
389 {% block get_dom_template %}{% endblock %} 406 {% block get_dom_template %}{% endblock %}
390 {% block get_dom_template_for_named_properties_object %}{% endblock %} 407 {% block get_dom_template_for_named_properties_object %}{% endblock %}
391 {% block has_instance %}{% endblock %} 408 {% block has_instance %}{% endblock %}
392 {% block to_impl %}{% endblock %} 409 {% block to_impl %}{% endblock %}
393 {% block to_impl_with_type_check %}{% endblock %} 410 {% block to_impl_with_type_check %}{% endblock %}
394 {% block install_conditional_attributes %}{% endblock %} 411 {% block install_conditional_attributes %}{% endblock %}
395 {##############################################################################} 412 {##############################################################################}
396 {% block prepare_prototype_and_interface_object %}{% endblock %} 413 {% block prepare_prototype_and_interface_object %}{% endblock %}
397 {##############################################################################} 414 {##############################################################################}
398 {% block to_active_scriptwrappable %}{% endblock %} 415 {% block to_active_scriptwrappable %}{% endblock %}
399 {% for method in methods if method.is_implemented_in_private_script and method.v isible %} 416 {% for method in methods if method.is_implemented_in_private_script and method.v isible %}
400 {{method_implemented_in_private_script(method)}} 417 {{method_implemented_in_private_script(method)}}
401 {% endfor %} 418 {% endfor %}
402 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 419 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
403 {{attribute_getter_implemented_in_private_script(attribute)}} 420 {{attribute_getter_implemented_in_private_script(attribute)}}
404 {% if attribute.has_setter %} 421 {% if attribute.has_setter %}
405 {{attribute_setter_implemented_in_private_script(attribute)}} 422 {{attribute_setter_implemented_in_private_script(attribute)}}
406 {% endif %} 423 {% endif %}
407 {% endfor %} 424 {% endfor %}
408 {% block partial_interface %}{% endblock %} 425 {% block partial_interface %}{% endblock %}
409 } // namespace blink 426 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698