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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/templates/interface_base.cpp
diff --git a/third_party/WebKit/Source/bindings/templates/interface_base.cpp b/third_party/WebKit/Source/bindings/templates/interface_base.cpp
index 7f93dd3159ad842faaa9cd1cf495aafe4d43fdb0..61f832f677a4da30a48d1660825e288062afd4a5 100644
--- a/third_party/WebKit/Source/bindings/templates/interface_base.cpp
+++ b/third_party/WebKit/Source/bindings/templates/interface_base.cpp
@@ -368,23 +368,21 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo
{% from 'attributes.cpp' import attribute_configuration with context %}
{% from 'constants.cpp' import constant_configuration with context %}
{% from 'methods.cpp' import method_configuration with context %}
-{% for origin_trial_feature_name in origin_trial_feature_names %}{{newline}}
-void {{v8_class_or_partial}}::install{{origin_trial_feature_name}}(ScriptState* scriptState, v8::Local<v8::Object> instance)
+{% for origin_trial_feature in origin_trial_features %}{{newline}}
+void {{v8_class_or_partial}}::install{{origin_trial_feature.name}}(ScriptState* scriptState, v8::Local<v8::Object> instance)
{
- v8::Local<v8::Object> prototype = instance->GetPrototype()->ToObject(scriptState->isolate());
-
- {# Origin-Trial-enabled attributes #}
- {% if attributes | for_origin_trial_feature(origin_trial_feature_name) or
- methods | method_for_origin_trial_feature(origin_trial_feature_name, is_partial) %}
- V8PerIsolateData* perIsolateData = V8PerIsolateData::from(scriptState->isolate());
- v8::Local<v8::FunctionTemplate> interfaceTemplate = perIsolateData->findInterfaceTemplate(scriptState->world(), &{{v8_class}}::wrapperTypeInfo);
+ {% if attributes | for_origin_trial_feature(origin_trial_feature.name) or
+ methods | method_for_origin_trial_feature(origin_trial_feature.name, is_partial) %}
+ v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeInfo.domTemplate(scriptState->isolate(), scriptState->world());
v8::Local<v8::Signature> signature = v8::Signature::New(scriptState->isolate(), interfaceTemplate);
ALLOW_UNUSED_LOCAL(signature);
{% endif %}
V8PerContextData* perContextData = V8PerContextData::from(scriptState->context());
+ v8::Local<v8::Object> prototype = perContextData->prototypeForType(&{{v8_class}}::wrapperTypeInfo);
v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8_class}}::wrapperTypeInfo);
ALLOW_UNUSED_LOCAL(interface);
- {% for attribute in attributes | for_origin_trial_feature(origin_trial_feature_name) | unique_by('name') | sort %}
+ {# Origin-Trial-enabled attributes #}
+ {% for attribute in attributes | for_origin_trial_feature(origin_trial_feature.name) | unique_by('name') | sort %}
{% if attribute.is_data_type_property %}
const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Configuration = \
{{attribute_configuration(attribute)}};
@@ -396,18 +394,25 @@ void {{v8_class_or_partial}}::install{{origin_trial_feature_name}}(ScriptState*
{% endif %}
{% endfor %}
{# Origin-Trial-enabled constants #}
- {% for constant in constants | for_origin_trial_feature(origin_trial_feature_name) | unique_by('name') | sort %}
+ {% for constant in constants | for_origin_trial_feature(origin_trial_feature.name) | unique_by('name') | sort %}
{% set constant_name = constant.name.title().replace('_', '') %}
const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Configuration = {{constant_configuration(constant)}};
V8DOMConfiguration::installConstant(scriptState->isolate(), interface, prototype, constant{{constant_name}}Configuration);
{% endfor %}
{# Origin-Trial-enabled methods (no overloads) #}
- {% for method in methods | method_for_origin_trial_feature(origin_trial_feature_name, is_partial) | unique_by('name') | sort %}
+ {% for method in methods | method_for_origin_trial_feature(origin_trial_feature.name, is_partial) | unique_by('name') | sort %}
{% set method_name = method.name.title().replace('_', '') %}
const V8DOMConfiguration::MethodConfiguration method{{method_name}}Configuration = {{method_configuration(method)}};
V8DOMConfiguration::installMethod(scriptState->isolate(), scriptState->world(), instance, prototype, interface, signature, method{{method_name}}Configuration);
{% endfor %}
}
+{% if not origin_trial_feature.needs_instance %}
+
+void {{v8_class_or_partial}}::install{{origin_trial_feature.name}}(ScriptState* scriptState)
+{
+ install{{origin_trial_feature.name}}(scriptState, v8::Local<v8::Object>());
+}
+{% endif %}
{% endfor %}
{% endblock %}
{##############################################################################}

Powered by Google App Engine
This is Rietveld 408576698