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

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

Issue 2620153004: [Bindings] Code cleanup: Early return if funtime enabled interface is false (Closed)
Patch Set: . Created 3 years, 11 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 {% filter format_blink_cpp_source_code %} 1 {% filter format_blink_cpp_source_code %}
2 2
3 {% include 'copyright_block.txt' %} 3 {% include 'copyright_block.txt' %}
4 #include "{{v8_class_or_partial}}.h" 4 #include "{{v8_class_or_partial}}.h"
5 5
6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if has_named_properties_object else 398 if has_named_properties_object else
399 'V8%s::domTemplate(isolate, world)' % parent_interface 399 'V8%s::domTemplate(isolate, world)' % parent_interface
400 if parent_interface else 400 if parent_interface else
401 'v8::Local<v8::FunctionTemplate>()' %} 401 'v8::Local<v8::FunctionTemplate>()' %}
402 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, {{v8_class}}::wrapperTypeInfo.interfaceName, {{parent_interface_template}}, {{v 8_class}}::internalFieldCount); 402 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, {{v8_class}}::wrapperTypeInfo.interfaceName, {{parent_interface_template}}, {{v 8_class}}::internalFieldCount);
403 {% if constructors or has_custom_constructor or has_event_constructor or has_h tml_constructor %} 403 {% if constructors or has_custom_constructor or has_event_constructor or has_h tml_constructor %}
404 interfaceTemplate->SetCallHandler({{v8_class}}::constructorCallback); 404 interfaceTemplate->SetCallHandler({{v8_class}}::constructorCallback);
405 interfaceTemplate->SetLength({{interface_length}}); 405 interfaceTemplate->SetLength({{interface_length}});
406 {% endif %} 406 {% endif %}
407 {% endif %}{# is_partial #} 407 {% endif %}{# is_partial #}
408
409 {% if runtime_enabled_feature_name %}
410 if (!{{runtime_enabled_feature_name | runtime_enabled_function}}) {
Yuki 2017/01/13 02:38:37 This is okay, but I guess you should be able to wr
Yuki 2017/01/13 02:38:37 If the feature is disabled, we shouldn't hit this
peria 2017/01/13 05:54:26 V8Type::domTemplate() calls it through V8DOMConfig
peria 2017/01/13 05:54:26 As a context of Jinja, I think it better to make t
411 return;
412 }
413 {% endif %}
414
408 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); 415 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
409 ALLOW_UNUSED_LOCAL(signature); 416 ALLOW_UNUSED_LOCAL(signature);
410 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe mplate(); 417 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe mplate();
411 ALLOW_UNUSED_LOCAL(instanceTemplate); 418 ALLOW_UNUSED_LOCAL(instanceTemplate);
412 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype Template(); 419 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype Template();
413 ALLOW_UNUSED_LOCAL(prototypeTemplate); 420 ALLOW_UNUSED_LOCAL(prototypeTemplate);
414 421
415 {% if interface_name == 'Window' and not is_partial %} 422 {% if interface_name == 'Window' and not is_partial %}
416 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount); 423 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount);
417 {% endif %} 424 {% endif %}
418 425
419 {% if is_immutable_prototype %} 426 {% if is_immutable_prototype %}
420 // Global object prototype chain consists of Immutable Prototype Exotic Object s 427 // Global object prototype chain consists of Immutable Prototype Exotic Object s
421 prototypeTemplate->SetImmutableProto(); 428 prototypeTemplate->SetImmutableProto();
422 {% endif %} 429 {% endif %}
423 430
424 {% if is_global %} 431 {% if is_global %}
425 // Global objects are Immutable Prototype Exotic Objects 432 // Global objects are Immutable Prototype Exotic Objects
426 instanceTemplate->SetImmutableProto(); 433 instanceTemplate->SetImmutableProto();
427 {% endif %} 434 {% endif %}
428 435
429 // Register DOM constants, attributes and operations. 436 // Register DOM constants, attributes and operations.
430 {% filter runtime_enabled(runtime_enabled_feature_name) %}
431 {% if constants %} 437 {% if constants %}
432 {{install_constants() | indent(2)}} 438 {{install_constants() | indent(2)}}
433 {% endif %} 439 {% endif %}
434 {% if data_attributes %} 440 {% if data_attributes %}
435 V8DOMConfiguration::installAttributes(isolate, world, instanceTemplate, protot ypeTemplate, {{'%sAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class}}); 441 V8DOMConfiguration::installAttributes(isolate, world, instanceTemplate, protot ypeTemplate, {{'%sAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class}});
436 {% endif %} 442 {% endif %}
437 {% if lazy_data_attributes %} 443 {% if lazy_data_attributes %}
438 V8DOMConfiguration::installLazyDataAttributes(isolate, world, instanceTemplate , prototypeTemplate, {{'%sLazyDataAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH( %sLazyDataAttributes)' % v8_class}}); 444 V8DOMConfiguration::installLazyDataAttributes(isolate, world, instanceTemplate , prototypeTemplate, {{'%sLazyDataAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH( %sLazyDataAttributes)' % v8_class}});
439 {% endif %} 445 {% endif %}
440 {% if accessors %} 446 {% if accessors %}
441 V8DOMConfiguration::installAccessors(isolate, world, instanceTemplate, prototy peTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF_A RRAY_LENGTH(%sAccessors)' % v8_class}}); 447 V8DOMConfiguration::installAccessors(isolate, world, instanceTemplate, prototy peTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF_A RRAY_LENGTH(%sAccessors)' % v8_class}});
442 {% endif %} 448 {% endif %}
443 {% if methods | has_method_configuration(is_partial) %} 449 {% if methods | has_method_configuration(is_partial) %}
444 V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototype Template, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARRAY _LENGTH(%sMethods)' % v8_class}}); 450 V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototype Template, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARRAY _LENGTH(%sMethods)' % v8_class}});
445 {% endif %} 451 {% endif %}
446 {% endfilter %}
447 452
448 {% if has_access_check_callbacks and not is_partial %} 453 {% if has_access_check_callbacks and not is_partial %}
449 // Cross-origin access check 454 // Cross-origin access check
450 {% set cross_origin_named_getter = '%sV8Internal::crossOriginNamedGetter' % cp p_class if has_cross_origin_named_getter else 'nullptr' %} 455 {% set cross_origin_named_getter = '%sV8Internal::crossOriginNamedGetter' % cp p_class if has_cross_origin_named_getter else 'nullptr' %}
451 {% set cross_origin_named_setter = '%sV8Internal::crossOriginNamedSetter' % cp p_class if has_cross_origin_named_setter else 'nullptr' %} 456 {% set cross_origin_named_setter = '%sV8Internal::crossOriginNamedSetter' % cp p_class if has_cross_origin_named_setter else 'nullptr' %}
452 {% set cross_origin_named_enumerator = '%sV8Internal::crossOriginNamedEnumerat or' % cpp_class if has_cross_origin_named_enumerator else 'nullptr' %} 457 {% set cross_origin_named_enumerator = '%sV8Internal::crossOriginNamedEnumerat or' % cpp_class if has_cross_origin_named_enumerator else 'nullptr' %}
453 {% set cross_origin_indexed_getter = '%sV8Internal::crossOriginIndexedGetter' % cpp_class if has_cross_origin_indexed_getter else 'nullptr' %} 458 {% set cross_origin_indexed_getter = '%sV8Internal::crossOriginIndexedGetter' % cpp_class if has_cross_origin_indexed_getter else 'nullptr' %}
454 instanceTemplate->SetAccessCheckCallbackAndHandler({{cpp_class}}V8Internal::se curityCheck, v8::NamedPropertyHandlerConfiguration({{cross_origin_named_getter}} , {{cross_origin_named_setter}}, nullptr, nullptr, {{cross_origin_named_enumerat or}}), v8::IndexedPropertyHandlerConfiguration({{cross_origin_indexed_getter}}), v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperT ypeInfo))); 459 instanceTemplate->SetAccessCheckCallbackAndHandler({{cpp_class}}V8Internal::se curityCheck, v8::NamedPropertyHandlerConfiguration({{cross_origin_named_getter}} , {{cross_origin_named_setter}}, nullptr, nullptr, {{cross_origin_named_enumerat or}}), v8::IndexedPropertyHandlerConfiguration({{cross_origin_indexed_getter}}), v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperT ypeInfo)));
455 {% endif %} 460 {% endif %}
456 461
457 {% for group in runtime_enabled_attributes | groupby('runtime_enabled_feature_ name') %} 462 {% for feature_name, attribute_list in runtime_enabled_attributes | groupby('r untime_enabled_feature_name') %}
458 {% filter runtime_enabled(group.list[0].runtime_enabled_feature_name) %} 463 {% filter runtime_enabled(feature_name) %}
459 {% for attribute in group.list | unique_by('name') | sort %} 464 {% for attribute in attribute_list | unique_by('name') | sort %}
460 {% if attribute.is_data_type_property %} 465 {% if attribute.is_data_type_property %}
461 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Co nfiguration = {{attribute_configuration(attribute)}}; 466 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Co nfiguration = {{attribute_configuration(attribute)}};
462 V8DOMConfiguration::installAttribute(isolate, world, instanceTemplate, prototy peTemplate, attribute{{attribute.name}}Configuration); 467 V8DOMConfiguration::installAttribute(isolate, world, instanceTemplate, prototy peTemplate, attribute{{attribute.name}}Configuration);
463 {% else %} 468 {% else %}
464 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Conf iguration = {{attribute_configuration(attribute)}}; 469 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Conf iguration = {{attribute_configuration(attribute)}};
465 V8DOMConfiguration::installAccessor(isolate, world, instanceTemplate, prototyp eTemplate, interfaceTemplate, signature, accessor{{attribute.name}}Configuration ); 470 V8DOMConfiguration::installAccessor(isolate, world, instanceTemplate, prototyp eTemplate, interfaceTemplate, signature, accessor{{attribute.name}}Configuration );
466 {% endif %} 471 {% endif %}
467 {% endfor %} 472 {% endfor %}
468 {% endfilter %} 473 {% endfilter %}
469 {% endfor %} 474 {% endfor %}
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 {% block has_instance %}{% endblock %} 654 {% block has_instance %}{% endblock %}
650 {% block to_impl %}{% endblock %} 655 {% block to_impl %}{% endblock %}
651 {% block to_impl_with_type_check %}{% endblock %} 656 {% block to_impl_with_type_check %}{% endblock %}
652 {##############################################################################} 657 {##############################################################################}
653 {% block prepare_prototype_and_interface_object %}{% endblock %} 658 {% block prepare_prototype_and_interface_object %}{% endblock %}
654 {##############################################################################} 659 {##############################################################################}
655 {% block partial_interface %}{% endblock %} 660 {% block partial_interface %}{% endblock %}
656 } // namespace blink 661 } // namespace blink
657 662
658 {% endfilter %}{# format_blink_cpp_source_code #} 663 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698