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

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

Issue 2837923003: Make NodeFilter a legacy callback interface. (Closed)
Patch Set: templates.gni, etc. Created 3 years, 8 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/legacy_callback_interface.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/legacy_callback_interface.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/legacy_callback_interface.cpp.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..8a2d17cea8aff4439c7597c3ebec55e95b5a7c67
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/templates/legacy_callback_interface.cpp.tmpl
@@ -0,0 +1,78 @@
+{% filter format_blink_cpp_source_code %}
+
+{% include 'copyright_block.txt' %}
+#include "{{v8_class}}.h"
+
+{% for filename in cpp_includes %}
+#include "{{filename}}"
+{% endfor %}
+
+namespace blink {
+
+// Suppress warning: global constructors, because struct WrapperTypeInfo is
+// trivial and does not depend on another global objects.
+#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+#endif
+const WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = {
+ gin::kEmbedderBlink,
+ {{v8_class}}::DomTemplate,
+ nullptr,
+ nullptr,
+ nullptr,
+ "{{interface_name}}",
+ nullptr,
+ WrapperTypeInfo::kWrapperTypeNoPrototype,
+ WrapperTypeInfo::kObjectClassId,
+ WrapperTypeInfo::kNotInheritFromActiveScriptWrappable,
+ WrapperTypeInfo::kDependent
+};
+#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
+#pragma clang diagnostic pop
+#endif
+
+void {{v8_class}}::TypeErrorConstructorCallback(
+ const v8::FunctionCallbackInfo<v8::Value>& info) {
+ V8ThrowException::ThrowTypeError(info.GetIsolate(),
+ "Illegal constructor: {{interface_name}}");
+}
+
+{% from 'constants.cpp.tmpl' import install_constants with context %}
+static void Install{{v8_class}}Template(
+ v8::Isolate* isolate,
+ const DOMWrapperWorld& world,
+ v8::Local<v8::FunctionTemplate> interfaceTemplate) {
+ // Legacy callback interface must not have a prototype object.
+ interfaceTemplate->RemovePrototype();
+
+ // Initialize the interface object's template.
+ V8DOMConfiguration::InitializeDOMInterfaceTemplate(isolate, interfaceTemplate,
+ {{v8_class}}::wrapperTypeInfo.interface_name, v8::Local<v8::FunctionTemplate>(),
+ kV8DefaultWrapperInternalFieldCount);
+ interfaceTemplate->SetCallHandler({{v8_class}}::TypeErrorConstructorCallback);
+ interfaceTemplate->SetLength(0);
+
+ v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemplate);
+ ALLOW_UNUSED_LOCAL(signature);
+ v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTemplate();
+ ALLOW_UNUSED_LOCAL(instanceTemplate);
+ v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->PrototypeTemplate();
+ ALLOW_UNUSED_LOCAL(prototypeTemplate);
+
+ // Register DOM constants.
+ {{install_constants() | indent(2)}}
+}
+
+v8::Local<v8::FunctionTemplate> {{v8_class}}::DomTemplate(v8::Isolate* isolate,
+ const DOMWrapperWorld& world) {
+ return V8DOMConfiguration::DomClassTemplate(
+ isolate,
+ world,
+ const_cast<WrapperTypeInfo*>(&wrapperTypeInfo),
+ Install{{v8_class}}Template);
+}
+
+} // namespace blink
+
+{% endfilter %}{# format_blink_cpp_source_code #}

Powered by Google App Engine
This is Rietveld 408576698