Commit aa5a228e authored by peria's avatar peria Committed by Commit bot

Implement installRuntimeEnabledFeatures method

on V8{Window,HTMLDocument,Document,Node,EventTarget}.

It installs runtime enabled features on instances,
and its use case is limited to those classes.

BUG=617892

Review-Url: https://codereview.chromium.org/2622153002
Cr-Commit-Position: refs/heads/master@{#442939}
parent ed3c9754
......@@ -254,6 +254,10 @@ def interface_context(interface, interfaces):
cpp_class_name_or_partial = cpp_name_or_partial(interface)
v8_class_name_or_partial = v8_utilities.v8_class_name_or_partial(interface)
# TODO(peria): Generate the target list from 'Window' and 'HTMLDocument'.
needs_runtime_enabled_installer = v8_class_name in [
'V8Window', 'V8HTMLDocument', 'V8Document', 'V8Node', 'V8EventTarget']
context = {
'cpp_class': cpp_class_name,
'cpp_class_or_partial': cpp_class_name_or_partial,
......@@ -279,6 +283,7 @@ def interface_context(interface, interfaces):
'is_typed_array_type': is_typed_array_type,
'lifetime': 'Dependent' if (has_visit_dom_wrapper or is_dependent_lifetime) else 'Independent',
'measure_as': v8_utilities.measure_as(interface, None), # [MeasureAs]
'needs_runtime_enabled_installer': needs_runtime_enabled_installer,
'origin_trial_enabled_function': v8_utilities.origin_trial_enabled_function_name(interface),
'parent_interface': parent_interface,
'pass_cpp_type': cpp_name(interface) + '*',
......
......@@ -150,6 +150,15 @@ class {{v8_class}} {
{% endfor %}
{% endif %}
{% if needs_runtime_enabled_installer %}
{{exported}}static void installRuntimeEnabledFeatures(
v8::Isolate* isolate,
const DOMWrapperWorld& world,
v8::Local<v8::Object> instance,
v8::Local<v8::Object> prototype,
v8::Local<v8::Function> interface);
{% endif %}
{% for feature in origin_trial_features %}
static void install{{feature.name}}(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface);
......
......@@ -527,6 +527,71 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo
{% endif %}{# not is_array_buffer_or_view #}
{% endblock %}
{##############################################################################}
{% block install_runtime_enabled %}
{% if needs_runtime_enabled_installer %}
{% from 'attributes.cpp.tmpl' import 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) {
{% 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);
{% endif %}
v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeInfo.domTemplate(isolate, world);
v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemplate);
ALLOW_UNUSED_LOCAL(signature);
{# TODO(peria): Generate code to install constants. It depends on runtime_enabled_feaure of this interface. #}
{% for feature_name, attrs in runtime_enabled_attributes | groupby('runtime_enabled_feature_name') %}
{% filter runtime_enabled(feature_name) %}
{% for attribute in attrs | unique_by('name') | sort %}
{% if attribute.is_data_type_property %}
const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Configuration = {{attribute_configuration(attribute)}};
V8DOMConfiguration::installAttribute(isolate, world, instance, prototype, attribute{{attribute.name}}Configuration);
{% else %}
const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Configuration = {{attribute_configuration(attribute)}};
V8DOMConfiguration::installAccessor(isolate, world, instance, prototype, interface, signature, accessor{{attribute.name}}Configuration);
{% endif %}
{% endfor %}
{% 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) %}
// Runtime enabled iterator (@@iterator)
#error "{{v8_class_or_partial}} should not have runtime enabled iterators."
{% 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 %}
#error "{{v8_class_or_partial}} should not have runtime enabled and cross origin methods."
{% else %}
{{install_custom_signature(method, 'instance', 'prototype', 'interface', 'signature') | indent(2)}}
{% endif %}
{% endfilter %}
{% endif %}
{% endfilter %}
{% endfor %}
{% endif %}
}
{% endif %}{# needs_runtime_enabled_installer #}
{% endblock %}
{##############################################################################}
{% block origin_trials %}
{% from 'attributes.cpp.tmpl' import attribute_configuration with context %}
{% from 'constants.cpp.tmpl' import constant_configuration with context %}
......
......@@ -42,6 +42,15 @@ class {{v8_class_or_partial}} {
{% endif %}
{% endfor %}
{% if needs_runtime_enabled_installer %}
static void installRuntimeEnabledFeatures(
v8::Isolate* isolate,
const DOMWrapperWorld& world,
v8::Local<v8::Object> instance,
v8::Local<v8::Object> prototype,
v8::Local<v8::Function> interface);
{% endif %}
private:
static void install{{v8_class}}Template(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment