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

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

Issue 2454133002: [Bindings] Reformat template files for Interface (1/4) (Closed)
Patch Set: Rebase Created 4 years, 1 month 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_or_partial}}.h" 4 #include "{{v8_class_or_partial}}.h"
5 5
6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 {% if not attribute.has_custom_setter %} 112 {% if not attribute.has_custom_setter %}
113 {{attribute_setter(attribute, world_suffix)}} 113 {{attribute_setter(attribute, world_suffix)}}
114 {% endif %} 114 {% endif %}
115 {{attribute_setter_callback(attribute, world_suffix)}} 115 {{attribute_setter_callback(attribute, world_suffix)}}
116 {% endif %} 116 {% endif %}
117 {% endfor %} 117 {% endfor %}
118 {% endfor %} 118 {% endfor %}
119 {##############################################################################} 119 {##############################################################################}
120 {% block security_check_functions %} 120 {% block security_check_functions %}
121 {% if has_access_check_callbacks and not is_partial %} 121 {% if has_access_check_callbacks and not is_partial %}
122 bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object > accessedObject, v8::Local<v8::Value> data) 122 bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object > accessedObject, v8::Local<v8::Value> data) {
123 { 123 {% if interface_name == 'Window' %}
124 {% if interface_name == 'Window' %} 124 v8::Isolate* isolate = v8::Isolate::GetCurrent();
125 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 125 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(accessed Object, isolate);
126 v8::Local<v8::Object> window = V8Window::findInstanceInPrototypeChain(access edObject, isolate); 126 if (window.IsEmpty())
127 if (window.IsEmpty()) 127 return false; // the frame is gone.
128 return false; // the frame is gone.
129 128
130 const DOMWindow* targetWindow = V8Window::toImpl(window); 129 const DOMWindow* targetWindow = V8Window::toImpl(window);
131 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acc essingContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport); 130 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), targetWindow, BindingSecurity::ErrorReportOption::DoNotReport);
132 {% else %}{# if interface_name == 'Window' #} 131 {% else %}{# if interface_name == 'Window' #}
133 {# Not 'Window' means it\'s Location. #} 132 {# Not 'Window' means it\'s Location. #}
134 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); 133 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject);
135 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acc essingContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport); 134 return BindingSecurity::shouldAllowAccessTo(toLocalDOMWindow(toDOMWindow(acces singContext)), impl, BindingSecurity::ErrorReportOption::DoNotReport);
136 {% endif %}{# if interface_name == 'Window' #} 135 {% endif %}{# if interface_name == 'Window' #}
137 } 136 }
138 137
139 {% endif %} 138 {% endif %}
140 {% endblock %} 139 {% endblock %}
141 {##############################################################################} 140 {##############################################################################}
142 {# Methods #} 141 {# Methods #}
143 {% from 'methods.cpp.tmpl' import generate_method, overload_resolution_method, 142 {% from 'methods.cpp.tmpl' import generate_method, overload_resolution_method,
144 method_callback, origin_safe_method_getter, generate_constructor, 143 method_callback, origin_safe_method_getter, generate_constructor,
145 method_implemented_in_private_script, generate_post_message_impl, 144 method_implemented_in_private_script, generate_post_message_impl,
146 runtime_determined_length_method, runtime_determined_maxarg_method 145 runtime_determined_length_method, runtime_determined_maxarg_method
(...skipping 12 matching lines...) Expand all
159 {% endif %} 158 {% endif %}
160 {% if method.overloads.runtime_determined_maxargs %} 159 {% if method.overloads.runtime_determined_maxargs %}
161 {{runtime_determined_maxarg_method(method.overloads)}} 160 {{runtime_determined_maxarg_method(method.overloads)}}
162 {% endif %} 161 {% endif %}
163 {{overload_resolution_method(method.overloads, world_suffix)}} 162 {{overload_resolution_method(method.overloads, world_suffix)}}
164 {% endif %} 163 {% endif %}
165 {% if not method.overload_index or method.overloads %} 164 {% if not method.overload_index or method.overloads %}
166 {# Document about the following condition: #} 165 {# Document about the following condition: #}
167 {# https://docs.google.com/document/d/1qBC7Therp437Jbt_QYAtNYMZs6zQ_7_tnMkNUG_AC qs/edit?usp=sharing #} 166 {# https://docs.google.com/document/d/1qBC7Therp437Jbt_QYAtNYMZs6zQ_7_tnMkNUG_AC qs/edit?usp=sharing #}
168 {% if (method.overloads and method.overloads.visible and 167 {% if (method.overloads and method.overloads.visible and
169 (not method.overloads.has_partial_overloads or not is_partial)) or 168 (not method.overloads.has_partial_overloads or not is_partial)) or
170 (not method.overloads and method.visible) %} 169 (not method.overloads and method.visible) %}
171 {# A single callback is generated for overloaded methods #} 170 {# A single callback is generated for overloaded methods #}
172 {# with considering partial overloads #} 171 {# with considering partial overloads #}
173 {{method_callback(method, world_suffix)}} 172 {{method_callback(method, world_suffix)}}
174 {% endif %} 173 {% endif %}
175 {% endif %} 174 {% endif %}
176 {% if method.is_do_not_check_security and method.visible %} 175 {% if method.is_do_not_check_security and method.visible %}
177 {{origin_safe_method_getter(method, world_suffix)}} 176 {{origin_safe_method_getter(method, world_suffix)}}
178 {% endif %} 177 {% endif %}
179 {% endfor %} 178 {% endfor %}
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 {% block named_constructor %}{% endblock %} 258 {% block named_constructor %}{% endblock %}
260 {% block constructor_callback %}{% endblock %} 259 {% block constructor_callback %}{% endblock %}
261 {##############################################################################} 260 {##############################################################################}
262 {% block install_dom_template %} 261 {% block install_dom_template %}
263 {% if not is_array_buffer_or_view %} 262 {% if not is_array_buffer_or_view %}
264 {% from 'methods.cpp.tmpl' import install_custom_signature with context %} 263 {% from 'methods.cpp.tmpl' import install_custom_signature with context %}
265 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %} 264 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %}
266 {% from 'constants.cpp.tmpl' import install_constants with context %} 265 {% from 'constants.cpp.tmpl' import install_constants with context %}
267 {% from 'methods.cpp.tmpl' import method_configuration with context %} 266 {% from 'methods.cpp.tmpl' import method_configuration with context %}
268 {% if has_partial_interface or is_partial %} 267 {% if has_partial_interface or is_partial %}
269 void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) 268 void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
270 {% else %} 269 {% else %}
271 static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo rld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) 270 static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo rld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
272 {% endif %} 271 {% endif %}
273 { 272 {% set newline = '' %}
274 {% set newline = '' %} 273 // Initialize the interface object's template.
275 // Initialize the interface object's template. 274 {% if is_partial %}
276 {% if is_partial %} 275 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate);
277 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate) ; 276 {% else %}
277 {% set parent_interface_template =
278 '%s::domTemplateForNamedPropertiesObject(isolate, world)' % v8_class
279 if has_named_properties_object else
280 'V8%s::domTemplate(isolate, world)' % parent_interface
281 if parent_interface else
282 'v8::Local<v8::FunctionTemplate>()' %}
283 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate, {{v8_class}}::wrapperTypeInfo.interfaceName, {{parent_interface_template}}, {{v 8_class}}::internalFieldCount);
284 {% if constructors or has_custom_constructor or has_event_constructor or has_h tml_constructor %}
285 interfaceTemplate->SetCallHandler({{v8_class}}::constructorCallback);
286 interfaceTemplate->SetLength({{interface_length}});
287 {% endif %}
288 {% endif %}{# is_partial #}
289 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
290 ALLOW_UNUSED_LOCAL(signature);
291 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe mplate();
292 ALLOW_UNUSED_LOCAL(instanceTemplate);
293 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype Template();
294 ALLOW_UNUSED_LOCAL(prototypeTemplate);
295
296 {%- if interface_name == 'Window' and not is_partial %}{{newline}}
297 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount);
298 {% endif %}
299
300 // Register DOM constants, attributes and operations.
301 {% filter runtime_enabled(runtime_enabled_function) %}
302 {% if constants %}
303 {{install_constants() | indent(2)}}
304 {% endif %}
305 {% if attributes | has_attribute_configuration %}
306 V8DOMConfiguration::installAttributes(isolate, world, instanceTemplate, protot ypeTemplate, {{'%sAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class}});
307 {% endif %}
308 {% if attributes | has_accessor_configuration %}
309 V8DOMConfiguration::installAccessors(isolate, world, instanceTemplate, prototy peTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF_A RRAY_LENGTH(%sAccessors)' % v8_class}});
310 {% endif %}
311 {% if methods | has_method_configuration(is_partial) %}
312 V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototype Template, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARRAY _LENGTH(%sMethods)' % v8_class}});
313 {% endif %}
314 {% endfilter %}
315 {%- if has_access_check_callbacks and not is_partial %}{{newline}}
316 // Cross-origin access check
317 instanceTemplate->SetAccessCheckCallback({{cpp_class}}V8Internal::securityChec k, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrappe rTypeInfo)));
318 {% endif %}
319
320 {%- for group in attributes | purely_runtime_enabled_attributes | groupby('run time_feature_name') %}{{newline}}
321 if ({{group.list[0].runtime_enabled_function}}()) {
322 {% for attribute in group.list | unique_by('name') | sort %}
323 {% if attribute.is_data_type_property %}
324 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}} Configuration = {{attribute_configuration(attribute)}};
325 V8DOMConfiguration::installAttribute(isolate, world, instanceTemplate, proto typeTemplate, attribute{{attribute.name}}Configuration);
278 {% else %} 326 {% else %}
279 {% set parent_interface_template = 327 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co nfiguration = {{attribute_configuration(attribute)}};
280 '%s::domTemplateForNamedPropertiesObject(isolate, world)' % v8_class 328 V8DOMConfiguration::installAccessor(isolate, world, instanceTemplate, protot ypeTemplate, interfaceTemplate, signature, accessor{{attribute.name}}Configurati on);
281 if has_named_properties_object else
282 'V8%s::domTemplate(isolate, world)' % parent_interface
283 if parent_interface else
284 'v8::Local<v8::FunctionTemplate>()' %}
285 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplat e, {{v8_class}}::wrapperTypeInfo.interfaceName, {{parent_interface_template}}, { {v8_class}}::internalFieldCount);
286 {% if constructors or has_custom_constructor or has_event_constructor or has _html_constructor %}
287 interfaceTemplate->SetCallHandler({{v8_class}}::constructorCallback);
288 interfaceTemplate->SetLength({{interface_length}});
289 {% endif %} 329 {% endif %}
290 {% endif %}{# is_partial #} 330 {% endfor %}
291 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTe mplate); 331 }
292 ALLOW_UNUSED_LOCAL(signature); 332 {% endfor %}
293 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->Instance Template();
294 ALLOW_UNUSED_LOCAL(instanceTemplate);
295 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototy peTemplate();
296 ALLOW_UNUSED_LOCAL(prototypeTemplate);
297 333
298 {%- if interface_name == 'Window' and not is_partial %}{{newline}} 334 {% if (indexed_property_getter or named_property_getter) and not is_partial %}
299 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount); 335 // Indexed properties
300 {% endif %} 336 {{install_indexed_property_handler('instanceTemplate') | indent(2)}}
337 {% endif %}
338 {% if named_property_getter and not is_partial and not has_named_properties_ob ject %}
339 // Named properties
340 {{install_named_property_handler('instanceTemplate') | indent(2)}}
341 {% endif %}
301 342
302 // Register DOM constants, attributes and operations. 343 {% if has_array_iterator and not is_partial %}
303 {% filter runtime_enabled(runtime_enabled_function) %} 344 // Array iterator (@@iterator)
304 {% if constants %} 345 {%+ if is_global %}instanceTemplate{% else %}prototypeTemplate{% endif %}->Set IntrinsicDataProperty(v8::Symbol::GetIterator(isolate), v8::kArrayProto_values, v8::DontEnum);
305 {{install_constants() | indent}} 346 {% endif %}
306 {% endif %}
307 {% if attributes | has_attribute_configuration %}
308 V8DOMConfiguration::installAttributes(isolate, world, instanceTemplate, prot otypeTemplate, {{'%sAttributes' % v8_class}}, {{'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class}});
309 {% endif %}
310 {% if attributes | has_accessor_configuration %}
311 V8DOMConfiguration::installAccessors(isolate, world, instanceTemplate, proto typeTemplate, interfaceTemplate, signature, {{'%sAccessors' % v8_class}}, {{'WTF _ARRAY_LENGTH(%sAccessors)' % v8_class}});
312 {% endif %}
313 {% if methods | has_method_configuration(is_partial) %}
314 V8DOMConfiguration::installMethods(isolate, world, instanceTemplate, prototy peTemplate, interfaceTemplate, signature, {{'%sMethods' % v8_class}}, {{'WTF_ARR AY_LENGTH(%sMethods)' % v8_class}});
315 {% endif %}
316 {% endfilter %}
317 {%- if has_access_check_callbacks and not is_partial %}{{newline}}
318 // Cross-origin access check
319 instanceTemplate->SetAccessCheckCallback({{cpp_class}}V8Internal::securityCh eck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrap perTypeInfo)));
320 {% endif %}
321 347
322 {%- for group in attributes | purely_runtime_enabled_attributes | groupby('r untime_feature_name') %}{{newline}} 348 {% if iterator_method %}
323 if ({{group.list[0].runtime_enabled_function}}()) { 349 {% filter exposed(iterator_method.exposed_test) %}
324 {% for attribute in group.list | unique_by('name') | sort %} 350 {% filter runtime_enabled(iterator_method.runtime_enabled_function) %}
325 {% if attribute.is_data_type_property %} 351 // Iterator (@@iterator)
326 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.na me}}Configuration = \ 352 const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorCo nfiguration = { v8::Symbol::GetIterator, {{cpp_class_or_partial}}V8Internal::ite ratorMethodCallback, 0, v8::DontEnum, V8DOMConfiguration::ExposedToAllScripts, V 8DOMConfiguration::OnPrototype };
327 {{attribute_configuration(attribute)}}; 353 V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signature , symbolKeyedIteratorConfiguration);
328 V8DOMConfiguration::installAttribute(isolate, world, instanceTemplate, p rototypeTemplate, attribute{{attribute.name}}Configuration); 354 {% endfilter %}
329 {% else %} 355 {% endfilter %}
330 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name }}Configuration = \ 356 {% endif %}
331 {{attribute_configuration(attribute)}};
332 V8DOMConfiguration::installAccessor(isolate, world, instanceTemplate, pr ototypeTemplate, interfaceTemplate, signature, accessor{{attribute.name}}Configu ration);
333 {% endif %}
334 {% endfor %}
335 }
336 {% endfor %}
337 357
338 {% if (indexed_property_getter or named_property_getter) and not is_partial %} 358 {%- if has_custom_legacy_call_as_function and not is_partial %}{{newline}}
339 // Indexed properties 359 instanceTemplate->SetCallAsFunctionHandler({{v8_class}}::legacyCallCustom);
340 {{install_indexed_property_handler('instanceTemplate') | indent}} 360 {% endif %}
341 {% endif %}
342 {% if named_property_getter and not is_partial and not has_named_properties_ object %}
343 // Named properties
344 {{install_named_property_handler('instanceTemplate') | indent}}
345 {% endif %}
346 361
347 {% if has_array_iterator and not is_partial %} 362 {%- if interface_name == 'HTMLAllCollection' and not is_partial %}{{newline}}
348 // Array iterator (@@iterator) 363 // Needed for legacy support of document.all
349 {%+ if is_global %}instanceTemplate{% else %}prototypeTemplate{% endif %}->S etIntrinsicDataProperty(v8::Symbol::GetIterator(isolate), v8::kArrayProto_values , v8::DontEnum); 364 instanceTemplate->MarkAsUndetectable();
350 {% endif %} 365 {% endif %}
351 366
352 {% if iterator_method %} 367 {%- if methods | custom_registration(is_partial) %}{{newline}}
353 {% filter exposed(iterator_method.exposed_test) %} 368 {% for method in methods | custom_registration(is_partial) %}
354 {% filter runtime_enabled(iterator_method.runtime_enabled_function) %} 369 {# install_custom_signature #}
355 // Iterator (@@iterator) 370 {% filter exposed(method.overloads.exposed_test_all
356 const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIterator Configuration = { v8::Symbol::GetIterator, {{cpp_class_or_partial}}V8Internal::i teratorMethodCallback, 0, v8::DontEnum, V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype }; 371 if method.overloads else method.exposed_test) %}
357 V8DOMConfiguration::installMethod(isolate, world, prototypeTemplate, signatu re, symbolKeyedIteratorConfiguration); 372 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
358 {% endfilter %} 373 if method.overloads else method.runtime_enabled_func tion) %}
359 {% endfilter %} 374 {% if method.is_do_not_check_security %}
360 {% endif %} 375 {{install_do_not_check_security_method(method, '', 'instanceTemplate', 'protot ypeTemplate') | indent(2)}}
361 376 {% else %}
362 {%- if has_custom_legacy_call_as_function and not is_partial %}{{newline}} 377 {{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'i nterfaceTemplate', 'signature') | indent(2)}}
363 instanceTemplate->SetCallAsFunctionHandler({{v8_class}}::legacyCallCustom); 378 {% endif %}
364 {% endif %} 379 {% endfilter %}
365 380 {% endfilter %}
366 {%- if interface_name == 'HTMLAllCollection' and not is_partial %}{{newline} } 381 {% endfor %}
367 // Needed for legacy support of document.all 382 {% endif %}
368 instanceTemplate->MarkAsUndetectable();
369 {% endif %}
370
371 {%- if methods | custom_registration(is_partial) %}{{newline}}
372 {% for method in methods | custom_registration(is_partial) %}
373 {# install_custom_signature #}
374 {% filter exposed(method.overloads.exposed_test_all
375 if method.overloads else
376 method.exposed_test) %}
377 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
378 if method.overloads else
379 method.runtime_enabled_function) %}
380 {% if method.is_do_not_check_security %}
381 {{install_do_not_check_security_method(method, '', 'instanceTemplate', 'prot otypeTemplate') | indent}}
382 {% else %}
383 {{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'interfaceTemplate', 'signature') | indent}}
384 {% endif %}
385 {% endfilter %}
386 {% endfilter %}
387 {% endfor %}
388 {% endif %}
389 } 383 }
390 384
391 {% endif %}{# not is_array_buffer_or_view #} 385 {% endif %}{# not is_array_buffer_or_view #}
392 {% endblock %} 386 {% endblock %}
393 {##############################################################################} 387 {##############################################################################}
394 {% block origin_trials %} 388 {% block origin_trials %}
395 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %} 389 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %}
396 {% from 'constants.cpp.tmpl' import constant_configuration with context %} 390 {% from 'constants.cpp.tmpl' import constant_configuration with context %}
397 {% from 'methods.cpp.tmpl' import method_configuration with context %} 391 {% from 'methods.cpp.tmpl' import method_configuration with context %}
398 {% for origin_trial_feature in origin_trial_features %}{{newline}} 392 {% for origin_trial_feature in origin_trial_features %}{{newline}}
399 void {{v8_class_or_partial}}::install{{origin_trial_feature.name}}(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local <v8::Object> prototype, v8::Local<v8::Function> interface) 393 void {{v8_class_or_partial}}::install{{origin_trial_feature.name}}(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local <v8::Object> prototype, v8::Local<v8::Function> interface) {
400 { 394 {% if attributes | for_origin_trial_feature(origin_trial_feature.name) or
401 {% if attributes | for_origin_trial_feature(origin_trial_feature.name) or 395 methods | method_for_origin_trial_feature(origin_trial_feature.name, is_ partial) %}
402 methods | method_for_origin_trial_feature(origin_trial_feature.name, i s_partial) %} 396 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI nfo.domTemplate(isolate, world);
403 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTyp eInfo.domTemplate(isolate, world); 397 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
404 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTe mplate); 398 ALLOW_UNUSED_LOCAL(signature);
405 ALLOW_UNUSED_LOCAL(signature); 399 {% endif %}
406 {% endif %} 400 {# Origin-Trial-enabled attributes #}
407 {# Origin-Trial-enabled attributes #} 401 {% for attribute in attributes | for_origin_trial_feature(origin_trial_feature .name) | unique_by('name') | sort %}
408 {% for attribute in attributes | for_origin_trial_feature(origin_trial_featu re.name) | unique_by('name') | sort %} 402 {% if attribute.is_data_type_property %}
409 {% if attribute.is_data_type_property %} 403 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}}Co nfiguration = {{attribute_configuration(attribute)}};
410 const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.name}} Configuration = \ 404 V8DOMConfiguration::installAttribute(isolate, world, instance, prototype, attr ibute{{attribute.name}}Configuration);
411 {{attribute_configuration(attribute)}}; 405 {% else %}
412 V8DOMConfiguration::installAttribute(isolate, world, instance, prototype, at tribute{{attribute.name}}Configuration); 406 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Conf iguration = {{attribute_configuration(attribute)}};
413 {% else %} 407 V8DOMConfiguration::installAccessor(isolate, world, instance, prototype, inter face, signature, accessor{{attribute.name}}Configuration);
414 const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.name}}Co nfiguration = \ 408 {% endif %}
415 {{attribute_configuration(attribute)}}; 409 {% endfor %}
416 V8DOMConfiguration::installAccessor(isolate, world, instance, prototype, int erface, signature, accessor{{attribute.name}}Configuration); 410 {# Origin-Trial-enabled constants #}
417 {% endif %} 411 {% for constant in constants | for_origin_trial_feature(origin_trial_feature.n ame) | unique_by('name') | sort %}
418 {% endfor %} 412 {% set constant_name = constant.name.title().replace('_', '') %}
419 {# Origin-Trial-enabled constants #} 413 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Confi guration = {{constant_configuration(constant)}};
420 {% for constant in constants | for_origin_trial_feature(origin_trial_feature .name) | unique_by('name') | sort %} 414 V8DOMConfiguration::installConstant(isolate, interface, prototype, constant{{c onstant_name}}Configuration);
421 {% set constant_name = constant.name.title().replace('_', '') %} 415 {% endfor %}
422 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Con figuration = {{constant_configuration(constant)}}; 416 {# Origin-Trial-enabled methods (no overloads) #}
423 V8DOMConfiguration::installConstant(isolate, interface, prototype, constant{ {constant_name}}Configuration); 417 {% for method in methods | method_for_origin_trial_feature(origin_trial_featur e.name, is_partial) | unique_by('name') | sort %}
424 {% endfor %} 418 {% set method_name = method.name.title().replace('_', '') %}
425 {# Origin-Trial-enabled methods (no overloads) #} 419 const V8DOMConfiguration::MethodConfiguration method{{method_name}}Configurati on = {{method_configuration(method)}};
426 {% for method in methods | method_for_origin_trial_feature(origin_trial_feat ure.name, is_partial) | unique_by('name') | sort %} 420 V8DOMConfiguration::installMethod(isolate, world, instance, prototype, interfa ce, signature, method{{method_name}}Configuration);
427 {% set method_name = method.name.title().replace('_', '') %} 421 {% endfor %}
428 const V8DOMConfiguration::MethodConfiguration method{{method_name}}Configura tion = {{method_configuration(method)}};
429 V8DOMConfiguration::installMethod(isolate, world, instance, prototype, inter face, signature, method{{method_name}}Configuration);
430 {% endfor %}
431 } 422 }
432 423
433 void {{v8_class_or_partial}}::install{{origin_trial_feature.name}}(ScriptState* scriptState, v8::Local<v8::Object> instance) 424 void {{v8_class_or_partial}}::install{{origin_trial_feature.name}}(ScriptState* scriptState, v8::Local<v8::Object> instance) {
434 { 425 V8PerContextData* perContextData = V8PerContextData::from(scriptState->context ());
435 V8PerContextData* perContextData = V8PerContextData::from(scriptState->conte xt()); 426 v8::Local<v8::Object> prototype = perContextData->prototypeForType(&{{v8_class }}::wrapperTypeInfo);
436 v8::Local<v8::Object> prototype = perContextData->prototypeForType(&{{v8_cla ss}}::wrapperTypeInfo); 427 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8_c lass}}::wrapperTypeInfo);
437 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8 _class}}::wrapperTypeInfo); 428 ALLOW_UNUSED_LOCAL(interface);
438 ALLOW_UNUSED_LOCAL(interface); 429 install{{origin_trial_feature.name}}(scriptState->isolate(), scriptState->worl d(), instance, prototype, interface);
439 install{{origin_trial_feature.name}}(scriptState->isolate(), scriptState->wo rld(), instance, prototype, interface);
440 } 430 }
441 {% if not origin_trial_feature.needs_instance %} 431 {% if not origin_trial_feature.needs_instance %}
442 432
443 void {{v8_class_or_partial}}::install{{origin_trial_feature.name}}(ScriptState* scriptState) 433 void {{v8_class_or_partial}}::install{{origin_trial_feature.name}}(ScriptState* scriptState) {
444 { 434 install{{origin_trial_feature.name}}(scriptState, v8::Local<v8::Object>());
445 install{{origin_trial_feature.name}}(scriptState, v8::Local<v8::Object>());
446 } 435 }
447 {% endif %} 436 {% endif %}
448 {% endfor %} 437 {% endfor %}
449 {% endblock %} 438 {% endblock %}
450 {##############################################################################} 439 {##############################################################################}
451 {% block get_dom_template %}{% endblock %} 440 {% block get_dom_template %}{% endblock %}
452 {% block get_dom_template_for_named_properties_object %}{% endblock %} 441 {% block get_dom_template_for_named_properties_object %}{% endblock %}
453 {% block has_instance %}{% endblock %} 442 {% block has_instance %}{% endblock %}
454 {% block to_impl %}{% endblock %} 443 {% block to_impl %}{% endblock %}
455 {% block to_impl_with_type_check %}{% endblock %} 444 {% block to_impl_with_type_check %}{% endblock %}
456 {##############################################################################} 445 {##############################################################################}
457 {% block prepare_prototype_and_interface_object %}{% endblock %} 446 {% block prepare_prototype_and_interface_object %}{% endblock %}
458 {##############################################################################} 447 {##############################################################################}
459 {% for method in methods if method.is_implemented_in_private_script and method.v isible %} 448 {% for method in methods if method.is_implemented_in_private_script and method.v isible %}
460 {{method_implemented_in_private_script(method)}} 449 {{method_implemented_in_private_script(method)}}
461 {% endfor %} 450 {% endfor %}
462 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 451 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
463 {{attribute_getter_implemented_in_private_script(attribute)}} 452 {{attribute_getter_implemented_in_private_script(attribute)}}
464 {% if attribute.has_setter %} 453 {% if attribute.has_setter %}
465 {{attribute_setter_implemented_in_private_script(attribute)}} 454 {{attribute_setter_implemented_in_private_script(attribute)}}
466 {% endif %} 455 {% endif %}
467 {% endfor %} 456 {% endfor %}
468 {% block partial_interface %}{% endblock %} 457 {% block partial_interface %}{% endblock %}
469 } // namespace blink 458 } // namespace blink
470 459
471 {% endfilter %}{# format_blink_cpp_source_code #} 460 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698