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

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

Issue 1531443003: [bindings] Implement an ExperimentEnabled IDL extended attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Less hacky and less lines. Created 5 years 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 22102d8796868d8ad8c07e5265562e0feb5022a6..b7c0b601af447556d656108112b01887c7525a89 100644
--- a/third_party/WebKit/Source/bindings/templates/interface_base.cpp
+++ b/third_party/WebKit/Source/bindings/templates/interface_base.cpp
@@ -300,10 +300,20 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function
{% if runtime_enabled_function %}
if (!{{runtime_enabled_function}}())
defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::internalFieldCount, 0, 0, 0, 0, 0, 0);
- else
+ else {
{% endif %}
{% set runtime_enabled_indent = 4 if runtime_enabled_function else 0 %}
{% filter indent(runtime_enabled_indent, true) %}
+ {% if api_experiment_name %}
+ ExecutionContext* ec = currentExecutionContext(isolate);
+ ALLOW_UNUSED_LOCAL(ec);
+ if (!Experiments::isApiEnabledWithoutMessage(ec, "{{api_experiment_name}}")) {
+ defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::internalFieldCount, 0, 0, 0, 0, 0, 0);
+ }
+ else
+ {% endif %}
+ {% set api_experiment_enabled_indent = 4 if api_experiment_name else runtime_enabled_indent %}
+ {% filter indent(api_experiment_enabled_indent, true) %}
defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::internalFieldCount,
{# Test needed as size 0 arrays definitions are not allowed per standard
(so objects have distinct addresses), which is enforced by MSVC.
@@ -326,7 +336,12 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function
{{attributes_name}}, {{attributes_length}},
{{accessors_name}}, {{accessors_length}},
{{methods_name}}, {{methods_length}});
- {% endfilter %}
+ {% endfilter %}{# api_experiment_enabled_indent #}
+ {% endfilter %}{# runtime_enabled_indent #}
+ {% if runtime_enabled_function %}
+
+ }
+ {% endif %}
{% if constructors or has_custom_constructor or has_event_constructor %}
functionTemplate->SetCallHandler({{v8_class}}::constructorCallback);
@@ -353,6 +368,7 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function
{% endfilter %}{# runtime_enabled() #}
{% endif %}
{% set runtime_enabled_features = dict() %}
+ {% set api_experiment_enabled_features = dict() %}
{% for attribute in attributes
if attribute.runtime_enabled_function and
not attribute.exposed_test %}
@@ -394,8 +410,10 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function
{% if iterator_method %}
{% filter exposed(iterator_method.exposed_test) %}
{% filter runtime_enabled(iterator_method.runtime_enabled_function) %}
+ {% filter api_experiment_enabled(iterator_method.api_experiment_name) %}
const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, {{cpp_class_or_partial}}V8Internal::iteratorMethodCallback, 0, v8::DontDelete, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype };
V8DOMConfiguration::installMethod(isolate, prototypeTemplate, defaultSignature, symbolKeyedIteratorConfiguration);
+ {% endfilter %}{# api_experiment_enabled() #}
{% endfilter %}{# runtime_enabled() #}
{% endfilter %}{# exposed() #}
{% endif %}
@@ -416,12 +434,16 @@ static void install{{v8_class}}Template(v8::Local<v8::FunctionTemplate> function
{% filter runtime_enabled(method.overloads.runtime_enabled_function_all
if method.overloads else
method.runtime_enabled_function) %}
+ {% filter api_experiment_enabled(method.overloads.api_experiment_name_all
+ if method.overloads else
+ method.api_experiment_name) %}
{% if method.is_do_not_check_security %}
{{install_do_not_check_security_method(method, '', 'instanceTemplate', 'prototypeTemplate') | indent}}
{% else %}{# is_do_not_check_security #}
{% set signature = 'v8::Local<v8::Signature>()' if method.is_do_not_check_signature else 'defaultSignature' %}
{{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'functionTemplate', signature) | indent}}
{% endif %}{# is_do_not_check_security #}
+ {% endfilter %}{# api_experiment_enabled() #}
{% endfilter %}{# runtime_enabled() #}
{% endfilter %}{# exposed() #}
{% endfilter %}{# conditional() #}

Powered by Google App Engine
This is Rietveld 408576698