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

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

Issue 2970003002: Add code generation for ConditionalFeatures bindings code (Closed)
Patch Set: Clean up Created 3 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/ConditionalFeaturesForCore.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/core/v8/ConditionalFeaturesForCore.cpp b/third_party/WebKit/Source/bindings/templates/ConditionalFeaturesForCore.cpp.tmpl
similarity index 73%
rename from third_party/WebKit/Source/bindings/core/v8/ConditionalFeaturesForCore.cpp
rename to third_party/WebKit/Source/bindings/templates/ConditionalFeaturesForCore.cpp.tmpl
index 986b764e20eb7f68c5a8b279fbf66de4a18c7311..4f60264e41f66c952517ac31123e97541b1b674f 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ConditionalFeaturesForCore.cpp
+++ b/third_party/WebKit/Source/bindings/templates/ConditionalFeaturesForCore.cpp.tmpl
@@ -4,16 +4,9 @@
#include "bindings/core/v8/ConditionalFeaturesForCore.h"
-#include "bindings/core/v8/V8Document.h"
-#include "bindings/core/v8/V8HTMLLinkElement.h"
-#include "bindings/core/v8/V8Navigator.h"
-#include "bindings/core/v8/V8Window.h"
-#include "core/context_features/ContextFeatureSettings.h"
-#include "core/dom/ExecutionContext.h"
-#include "core/frame/Frame.h"
-#include "core/origin_trials/OriginTrials.h"
-#include "platform/bindings/ConditionalFeatures.h"
-#include "platform/bindings/ScriptState.h"
+{% for include in includes %}
+#include "{{ include }}"
+{% endfor %}
namespace blink {
@@ -31,14 +24,13 @@ void InstallConditionalFeaturesCore(const WrapperTypeInfo* wrapper_type_info,
(*g_old_install_conditional_features_function)(
wrapper_type_info, script_state, prototype_object, interface_object);
- // TODO(iclelland): Generate all of this logic at compile-time, based on the
- // configuration of origin trial enabled attributes and interfaces in IDL
- // files. (crbug.com/615060)
ExecutionContext* execution_context = ExecutionContext::From(script_state);
if (!execution_context)
return;
v8::Isolate* isolate = script_state->GetIsolate();
const DOMWrapperWorld& world = script_state->World();
+ // TODO(iclelland): Unify ContextFeatureSettings with the rest of the
+ // conditional features.
if (wrapper_type_info == &V8Window::wrapperTypeInfo) {
auto* settings = ContextFeatureSettings::From(
execution_context,
@@ -49,37 +41,45 @@ void InstallConditionalFeaturesCore(const WrapperTypeInfo* wrapper_type_info,
V8Window::installMojoJS(isolate, world, instance_object, prototype_object,
interface_object);
}
- } else if (wrapper_type_info == &V8HTMLLinkElement::wrapperTypeInfo) {
- if (OriginTrials::linkServiceWorkerEnabled(execution_context)) {
- V8HTMLLinkElement::installLinkServiceWorker(
+ }
+ {% for interface in installers_by_interface %}
+ if (wrapper_type_info == &{{ interface.class }}::wrapperTypeInfo) {
+ {% for installer in interface.installers %}
chasej 2017/07/11 20:12:31 Will this code generation properly handle global o
iclelland 2017/07/12 17:23:20 That's a good point, we've never defined a trial i
chasej 2017/07/12 19:53:41 Actually, the Long Task Observer trial required in
+ if ({{ installer.condition }}(execution_context)) {
+ {{ installer.class }}::{{ installer.install_method }}(
isolate, world, v8::Local<v8::Object>(), prototype_object,
interface_object);
}
+ {% endfor %}
}
+ {% endfor %}
}
void InstallPendingConditionalFeatureCore(const String& feature,
chasej 2017/07/11 20:12:32 Ditto. Should be "...ForCore" to be consistent wit
iclelland 2017/07/12 17:23:20 Yes, this was a holdover from the handwritten code
const ScriptState* script_state) {
(*g_old_install_pending_conditional_feature_function)(feature, script_state);
- // TODO(iclelland): Generate all of this logic at compile-time, based on the
- // configuration of origin trial enabled attributes and interfaces in IDL
- // files. (crbug.com/615060)
+ {% if installers_by_feature %}
v8::Local<v8::Object> prototype_object;
v8::Local<v8::Function> interface_object;
v8::Isolate* isolate = script_state->GetIsolate();
const DOMWrapperWorld& world = script_state->World();
V8PerContextData* context_data = script_state->PerContextData();
- if (feature == "ForeignFetch") {
+ {% for feature in installers_by_feature %}
+ if (feature == "{{ feature.name }}") {
+ {% for installer in feature.installers %}
if (context_data->GetExistingConstructorAndPrototypeForType(
- &V8HTMLLinkElement::wrapperTypeInfo, &prototype_object,
+ &{{ installer.class }}::wrapperTypeInfo, &prototype_object,
&interface_object)) {
- V8HTMLLinkElement::installLinkServiceWorker(
+ {{ installer.class_or_partial }}::{{ installer.install_method }}(
isolate, world, v8::Local<v8::Object>(), prototype_object,
interface_object);
}
+ {% endfor %}
return;
}
+ {% endfor %}
+ {% endif %}
}
void InstallConditionalFeaturesOnWindow(const ScriptState* script_state) {

Powered by Google App Engine
This is Rietveld 408576698