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

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

Issue 2841443005: [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: Support runtime feature on templates Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl
index d15a65c87308e8c4e34715313e5f49523e9470b0..8e1d8801d0990221a9a2e2aeef132bb870ea09b0 100644
--- a/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl
+++ b/third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl
@@ -421,9 +421,15 @@ static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = {
{% from 'constants.cpp.tmpl' import install_constants with context %}
{% from 'methods.cpp.tmpl' import method_configuration with context %}
{% if has_partial_interface or is_partial %}
-void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
+void {{v8_class_or_partial}}::install{{v8_class}}Template(
+ v8::Isolate* isolate,
+ const DOMWrapperWorld& world,
+ v8::Local<v8::FunctionTemplate> interfaceTemplate) {
{% else %}
-static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
+static void install{{v8_class}}Template(
+ v8::Isolate* isolate,
+ const DOMWrapperWorld& world,
+ v8::Local<v8::FunctionTemplate> interfaceTemplate) {
{% endif %}
// Initialize the interface object's template.
{% if is_partial %}
@@ -642,17 +648,22 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo
attribute_configuration,
with context %}
{% from 'methods.cpp.tmpl' import install_custom_signature with context %}
-void {{v8_class_or_partial}}::installRuntimeEnabledFeatures(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface) {
+void {{v8_class_or_partial}}::InstallRuntimeEnabledFeatures(
+ v8::Isolate* isolate,
+ const DOMWrapperWorld& world,
+ v8::Local<v8::Object> instance,
+ v8::Local<v8::Object> prototype,
+ v8::Local<v8::Function> interface) {
{% if runtime_enabled_feature_name %}
#error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to have installRuntimeEnabledFeatures()."
{% endif %}
{% if is_partial %}
- {{v8_class}}::installRuntimeEnabledFeatures(isolate, world, instance, prototype, interface);
+ {{v8_class}}::InstallRuntimeEnabledFeatures(isolate, world, instance, prototype, interface);
{% endif %}
- v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeInfo.domTemplate(isolate, world);
- v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemplate);
+ v8::Local<v8::FunctionTemplate> interface_template = {{v8_class}}::wrapperTypeInfo.domTemplate(isolate, world);
+ v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_template);
ALLOW_UNUSED_LOCAL(signature);
{# TODO(peria): Generate code to install constants. It depends on runtime_enabled_feaure of this interface. #}
@@ -683,12 +694,7 @@ void {{v8_class_or_partial}}::installRuntimeEnabledFeatures(v8::Isolate* isolate
{% endfor %}
{% if iterator_method and iterator_method.runtime_enabled_feature_name %}
- {% filter exposed(iterator_method.exposed_test) %}
- {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %}
- // Runtime enabled iterator (@@iterator)
-#error "{{v8_class_or_partial}} should not have runtime enabled iterators."
- {% endfilter %}
- {% endfilter %}
+#error "{{v8_class_or_partial}} should not have runtime enabled iterator (@@iterator)."
{% endif %}
{% if methods | custom_registration(is_partial) %}
@@ -711,6 +717,110 @@ void {{v8_class_or_partial}}::installRuntimeEnabledFeatures(v8::Isolate* isolate
{% endif %}
}
+void {{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesOnTemplate(
Yuki 2017/06/21 09:23:21 Probably we could land this change separately in a
peria 2017/06/23 02:22:05 Yes, of course, will do. It is included in this ch
+ v8::Isolate* isolate,
+ const DOMWrapperWorld& world,
+ v8::Local<v8::FunctionTemplate> interface_template) {
+ {% if runtime_enabled_feature_name %}
+#error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to have InstallRuntimeEnabledFeaturesOnTemplate()."
+ {% endif %}
+
+ {% if is_partial %}
+ {{v8_class}}::InstallRuntimeEnabledFeaturesOnTemplate(isolate, world, interface_template);
+ {% endif %}
+
+ v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_template);
+ ALLOW_UNUSED_LOCAL(signature);
+ v8::Local<v8::ObjectTemplate> instance_template = interface_template->InstanceTemplate();
+ ALLOW_UNUSED_LOCAL(instance_template);
+ v8::Local<v8::ObjectTemplate> prototype_template = interface_template->PrototypeTemplate();
+ ALLOW_UNUSED_LOCAL(prototype_template);
+
+ // Register DOM constants, attributes and operations.
Yuki 2017/06/21 09:23:21 nit: s/DOM/IDL/
peria 2017/06/23 02:22:05 Done.
+ {% for feature_name, constants_list in constants | selectattr('runtime_enabled_feature_name') | groupby('runtime_enabled_feature_name') %}
+ {% filter runtime_enabled(feature_name) %}
+ static const V8DOMConfiguration::ConstantConfiguration constant_configurations = {
+ {% for constant in constants_list %}
+ {{constant_configuration(constant) | indent(6)}},
+ {% endfor %}
+ }
+ V8DOMConfiguration::InstallConstants(
+ isolate, interface_template, prototype_template,
+ constant_configurations, WTF_ARRAY_LENGTH(constant_configurations));
+ {% endfilter %}
+ {% endfor %}
+
+ {% for feature_name, attribute_list in runtime_enabled_attributes | selectattr('is_data_type_property') | groupby('runtime_enabled_feature_name') %}
+ {% filter runtime_enabled(feature_name) %}
+ static const V8DOMConfiguration::AttributeConfiguration attribute_configurations[] = {
+ {% for attribute in attribute_list | sort %}
+ {{attribute_configuration(attribute) | indent(6)}},
+ {% endfor %}
+ };
+ V8DOMConfiguration::InstallAttributes(
+ isolate, world, instance_template, prototype_template,
+ attribute_configurations, WTF_ARRAY_LENGTH(attribute_configurations));
+ {% endfilter %}
+ {% endfor %}
+
+ {% for feature_name, attribute_list in runtime_enabled_attributes | selectattr('is_data_type_property', 'equalto', False) | groupby('runtime_enabled_feature_name') %}
+ {% filter runtime_enabled(feature_name) %}
+ static const V8DOMConfiguration::AccessorConfiguration accessor_configurations[] = {
+ {% for attribute in attribute_list | sort %}
+ {{accessor_configuration(attribute) | indent(6)}},
+ {% endfor %}
+ };
+ V8DOMConfiguration::InstallAccessors(
+ isolate, world, instance_template, prototype_template, interface_template,
+ signature, accessor_configurations,
+ WTF_ARRAY_LENGTH(accessor_configurations));
+ {% endfilter %}
+ {% endfor %}
+
+ {% if iterator_method and iterator_method.runtime_enabled_feature_name %}
+ {% filter exposed(iterator_method.exposed_test) %}
+ {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %}
+ {% set symbol_alias = '"%s"' % iterator_method_alias
+ if iterator_method_alias else 'nullptr' %}
+ // Iterator (@@iterator)
+ static const V8DOMConfiguration::SymbolKeyedMethodConfiguration
+ symbol_keyed_iterator_configuration = {
+ v8::Symbol::GetIterator,
+ {{symbol_alias}},
+ {{v8_class_or_partial}}::iteratorMethodCallback,
+ 0,
+ v8::DontEnum,
+ V8DOMConfiguration::kOnPrototype,
+ V8DOMConfiguration::kCheckHolder,
+ V8DOMConfiguration::kDoNotCheckAccess
+ };
+ V8DOMConfiguration::InstallMethod(
+ isolate, world, prototype_template, signature,
+ symbol_keyed_iterator_configuration);
+ {% endfilter %}
+ {% endfilter %}
+ {% endif %}
+
+ {% if methods | custom_registration(is_partial) %}
+ {% for method in methods | custom_registration(is_partial) %}
+ {% filter exposed(method.overloads.exposed_test_all
+ if method.overloads else method.exposed_test) %}
+ {% set feature_name = method.overloads.runtime_enabled_all
+ if method.overloads else method.runtime_enabled_feature_name %}
+ {% if feature_name %}
+ {% filter runtime_enabled(feature_name) %}
+ {% if method.is_cross_origin %}
+ {{install_origin_safe_method(method, 'instance_template', 'prototype_template') | indent(2)}}
+ {% else %}
+ {{install_custom_signature(method, 'instance_template', 'prototype_template', 'interface_template', 'signature') | indent(2)}}
+ {% endif %}
+ {% endfilter %}
+ {% endif %}
+ {% endfilter %}
+ {% endfor %}
+ {% endif %}
+}
+
{% endif %}{# needs_runtime_enabled_installer #}
{% endblock %}
{##############################################################################}

Powered by Google App Engine
This is Rietveld 408576698