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

Unified 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: Move signature creation out of for loop 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 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 7e559ae43d0eb6d0757b276e027fb41cf0a6ff5f..3667d4dc27029ad8a066780d08431fd6ceed18fe 100644
--- a/third_party/WebKit/Source/bindings/templates/interface_base.cpp
+++ b/third_party/WebKit/Source/bindings/templates/interface_base.cpp
@@ -365,13 +365,18 @@ static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo
{##############################################################################}
{% block origin_trials %}
{% from 'attributes.cpp' import attribute_configuration with context %}
-{% for group in attributes|origin_trial_enabled_attributes|groupby('origin_trial_feature_name') %}{{newline}}
-void {{v8_class_or_partial}}::install{{group.grouper}}(ScriptState* scriptState, v8::Local<v8::Object> instance)
+{% from 'constants.cpp' import constant_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)
{
v8::Local<v8::Object> prototype = instance->GetPrototype()->ToObject(scriptState->isolate());
- v8::Local<v8::Signature> signature;
+ {# Origin-Trial-enabled attributes #}
+ {% if attributes | for_origin_trial_feature(origin_trial_feature_name) %}
+ V8PerIsolateData* perIsolateData = V8PerIsolateData::from(scriptState->isolate());
+ v8::Local<v8::FunctionTemplate> interfaceTemplate = perIsolateData->findInterfaceTemplate(scriptState->world(), &{{v8_class}}::wrapperTypeInfo);
+ v8::Local<v8::Signature> signature = v8::Signature::New(scriptState->isolate(), interfaceTemplate);
ALLOW_UNUSED_LOCAL(signature);
- {% for attribute in group.list | unique_by('name') | sort %}
+ {% 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)}};
@@ -382,6 +387,18 @@ void {{v8_class_or_partial}}::install{{group.grouper}}(ScriptState* scriptState,
V8DOMConfiguration::installAccessor(scriptState->isolate(), scriptState->world(), instance, prototype, v8::Local<v8::Function>(), signature, accessor{{attribute.name}}Configuration);
{% endif %}
{% endfor %}
+ {% endif %}
+
+ {# Origin-Trial-enabled constants #}
+ {% if constants | for_origin_trial_feature(origin_trial_feature_name) %}
+ V8PerContextData* perContextData = V8PerContextData::from(scriptState->context());
+ v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8_class}}::wrapperTypeInfo);
+ {% 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 %}
+ {% endif %}
}
{% endfor %}
{% endblock %}

Powered by Google App Engine
This is Rietveld 408576698