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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/callback_interface.cpp.tmpl

Issue 2837923003: Make NodeFilter a legacy callback interface. (Closed)
Patch Set: . Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 {% filter format_blink_cpp_source_code %} 1 {% filter format_blink_cpp_source_code %}
2 2
3 {% include 'copyright_block.txt' %} 3 {% include 'copyright_block.txt' %}
4 #include "{{v8_class}}.h" 4 #include "{{v8_class}}.h"
5 5
6 {% for filename in cpp_includes %} 6 {% for filename in cpp_includes %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
11 11
12 {% if is_legacy %}
bashi 2017/04/27 08:49:49 It seems that we should have a new template file (
tkent 2017/04/27 09:15:12 IMO, we should not have a separated template. Idea
bashi 2017/04/27 23:12:32 How much code you are expecting to have overlaps b
tkent 2017/04/28 00:09:43 Well, suppose that: A: Code amount to support non-
bashi 2017/04/28 00:59:09 Still I'd prefer having separate templates. Ration
tkent 2017/04/28 06:13:36 ok, done in Patch Set 2.
13 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv ial
bashi 2017/04/27 08:49:49 nit: Wrap to 80 columns?
tkent 2017/04/28 06:13:36 Done.
14 // and does not depend on another global objects.
15 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
16 #pragma clang diagnostic push
17 #pragma clang diagnostic ignored "-Wglobal-constructors"
18 #endif
19 const WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = {
20 gin::kEmbedderBlink,
21 {{v8_class}}::DomTemplate,
22 nullptr,
23 nullptr,
24 nullptr,
25 "{{interface_name}}",
26 nullptr,
27 WrapperTypeInfo::kWrapperTypeNoPrototype,
28 WrapperTypeInfo::kObjectClassId,
29 WrapperTypeInfo::kNotInheritFromActiveScriptWrappable,
30 WrapperTypeInfo::kDependent
31 };
32 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
33 #pragma clang diagnostic pop
34 #endif
35
36 static void
37 TypeErrorConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
Yuki 2017/04/27 12:18:29 Due to the snapshot project, I think that this nee
peria 2017/04/27 13:14:49 Yes, it should. The project is still under constru
tkent 2017/04/28 06:13:36 Done.
38 V8ThrowException::ThrowTypeError(info.GetIsolate(), "Illegal constructor: {{in terface_name}}");
39 }
40
41 {% from 'constants.cpp.tmpl' import install_constants with context %}
42 static void Install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo rld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
43 // Legacy callback interface doesn't need prototype.
Yuki 2017/04/27 12:18:29 nit: s/doesn't need prototype/must not have a prot
tkent 2017/04/28 06:13:36 Done.
44 interfaceTemplate->RemovePrototype();
45
46 // Initialize the interface object's template.
47 V8DOMConfiguration::InitializeDOMInterfaceTemplate(isolate, interfaceTemplate,
48 {{v8_class}}::wrapperTypeInfo.interface_name, v8::Local<v8::FunctionTempla te>(),
49 {{v8_class}}::internalFieldCount);
50 interfaceTemplate->SetCallHandler(TypeErrorConstructorCallback);
51 //interfaceTemplate->SetLength({{interface_length}});
bashi 2017/04/27 08:49:49 Remove?
Yuki 2017/04/27 12:18:29 Should be explicitly set to zero because the spec
tkent 2017/04/28 06:13:36 Done. Set 0 explicitly.
52
53 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
54 ALLOW_UNUSED_LOCAL(signature);
55 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe mplate();
56 ALLOW_UNUSED_LOCAL(instanceTemplate);
57 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype Template();
58 ALLOW_UNUSED_LOCAL(prototypeTemplate);
59
60 // Register DOM constants.
61 {{install_constants() | indent(2)}}
62 }
63
64 v8::Local<v8::FunctionTemplate> {{v8_class}}::DomTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world) {
65 return V8DOMConfiguration::DomClassTemplate(isolate, world, const_cast<Wrapper TypeInfo*>(&wrapperTypeInfo), Install{{v8_class}}Template);
66 }
67
68 {% else %} {# is_legacy #}
69
12 {{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, ScriptState* script State) 70 {{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, ScriptState* script State)
13 : m_scriptState(scriptState) { 71 : m_scriptState(scriptState) {
14 m_callback.Set(scriptState->GetIsolate(), callback); 72 m_callback.Set(scriptState->GetIsolate(), callback);
15 } 73 }
16 74
17 {{v8_class}}::~{{v8_class}}() {} 75 {{v8_class}}::~{{v8_class}}() {}
18 76
19 DEFINE_TRACE({{v8_class}}) { 77 DEFINE_TRACE({{v8_class}}) {
20 {{cpp_class}}::Trace(visitor); 78 {{cpp_class}}::Trace(visitor);
21 } 79 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate), 122 V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate),
65 ExecutionContext::From(m_scriptState.Get()), 123 ExecutionContext::From(m_scriptState.Get()),
66 {{this_handle_parameter}}, 124 {{this_handle_parameter}},
67 {{method.arguments | length}}, 125 {{method.arguments | length}},
68 argv, 126 argv,
69 isolate); 127 isolate);
70 {% endif %} 128 {% endif %}
71 } 129 }
72 130
73 {% endfor %} 131 {% endfor %}
132
133 {% endif %} {# is_legacy #}
134
74 } // namespace blink 135 } // namespace blink
75 136
76 {% endfilter %}{# format_blink_cpp_source_code #} 137 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698