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

Side by Side 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 unified diff | Download patch
OLDNEW
1 {% include 'copyright_block.txt' %} 1 {% include 'copyright_block.txt' %}
2 #include "config.h" 2 #include "config.h"
3 {% filter conditional(conditional_string) %} 3 {% filter conditional(conditional_string) %}
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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 v8::Local<v8::Signature> defaultSignature; 294 v8::Local<v8::Signature> defaultSignature;
295 {% set parent_template = 295 {% set parent_template =
296 '%s::domTemplateForNamedPropertiesObject(isolate)' % v8_class 296 '%s::domTemplateForNamedPropertiesObject(isolate)' % v8_class
297 if has_named_properties_object else 297 if has_named_properties_object else
298 'V8%s::domTemplate(isolate)' % parent_interface 298 'V8%s::domTemplate(isolate)' % parent_interface
299 if parent_interface else 'v8::Local<v8::FunctionTemplate>()' %} 299 if parent_interface else 'v8::Local<v8::FunctionTemplate>()' %}
300 {% if runtime_enabled_function %} 300 {% if runtime_enabled_function %}
301 if (!{{runtime_enabled_function}}()) 301 if (!{{runtime_enabled_function}}())
302 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::inter nalFieldCount, 0, 0, 0, 0, 0, 0); 302 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::inter nalFieldCount, 0, 0, 0, 0, 0, 0);
303 else 303 else {
304 {% endif %} 304 {% endif %}
305 {% set runtime_enabled_indent = 4 if runtime_enabled_function else 0 %} 305 {% set runtime_enabled_indent = 4 if runtime_enabled_function else 0 %}
306 {% filter indent(runtime_enabled_indent, true) %} 306 {% filter indent(runtime_enabled_indent, true) %}
307 {% if api_experiment_name %}
308 ExecutionContext* ec = currentExecutionContext(isolate);
309 ALLOW_UNUSED_LOCAL(ec);
310 if (!Experiments::isApiEnabledWithoutMessage(ec, "{{api_experiment_name}}")) {
311 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::inter nalFieldCount, 0, 0, 0, 0, 0, 0);
312 }
313 else
314 {% endif %}
315 {% set api_experiment_enabled_indent = 4 if api_experiment_name else runtime _enabled_indent %}
316 {% filter indent(api_experiment_enabled_indent, true) %}
307 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, func tionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::internalF ieldCount, 317 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, func tionTemplate, "{{interface_name}}", {{parent_template}}, {{v8_class}}::internalF ieldCount,
308 {# Test needed as size 0 arrays definitions are not allowed per standard 318 {# Test needed as size 0 arrays definitions are not allowed per standard
309 (so objects have distinct addresses), which is enforced by MSVC. 319 (so objects have distinct addresses), which is enforced by MSVC.
310 8.5.1 Aggregates [dcl.init.aggr] 320 8.5.1 Aggregates [dcl.init.aggr]
311 An array of unknown size initialized with a brace-enclosed 321 An array of unknown size initialized with a brace-enclosed
312 initializer-list containing n initializer-clauses, where n shall be 322 initializer-list containing n initializer-clauses, where n shall be
313 greater than zero, is defined as having n elements (8.3.4). #} 323 greater than zero, is defined as having n elements (8.3.4). #}
314 {% set attributes_name, attributes_length = 324 {% set attributes_name, attributes_length =
315 ('%sAttributes' % v8_class, 325 ('%sAttributes' % v8_class,
316 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class) 326 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class)
317 if has_attribute_configuration else (0, 0) %} 327 if has_attribute_configuration else (0, 0) %}
318 {% set accessors_name, accessors_length = 328 {% set accessors_name, accessors_length =
319 ('%sAccessors' % v8_class, 329 ('%sAccessors' % v8_class,
320 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class) 330 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class)
321 if has_accessor_configuration else (0, 0) %} 331 if has_accessor_configuration else (0, 0) %}
322 {% set methods_name, methods_length = 332 {% set methods_name, methods_length =
323 ('%sMethods' % v8_class, 333 ('%sMethods' % v8_class,
324 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class) 334 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class)
325 if method_configuration_methods else (0, 0) %} 335 if method_configuration_methods else (0, 0) %}
326 {{attributes_name}}, {{attributes_length}}, 336 {{attributes_name}}, {{attributes_length}},
327 {{accessors_name}}, {{accessors_length}}, 337 {{accessors_name}}, {{accessors_length}},
328 {{methods_name}}, {{methods_length}}); 338 {{methods_name}}, {{methods_length}});
329 {% endfilter %} 339 {% endfilter %}{# api_experiment_enabled_indent #}
340 {% endfilter %}{# runtime_enabled_indent #}
341 {% if runtime_enabled_function %}
342
343 }
344 {% endif %}
330 345
331 {% if constructors or has_custom_constructor or has_event_constructor %} 346 {% if constructors or has_custom_constructor or has_event_constructor %}
332 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback); 347 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback);
333 functionTemplate->SetLength({{interface_length}}); 348 functionTemplate->SetLength({{interface_length}});
334 {% endif %} 349 {% endif %}
335 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate(); 350 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate();
336 ALLOW_UNUSED_LOCAL(instanceTemplate); 351 ALLOW_UNUSED_LOCAL(instanceTemplate);
337 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate(); 352 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate();
338 ALLOW_UNUSED_LOCAL(prototypeTemplate); 353 ALLOW_UNUSED_LOCAL(prototypeTemplate);
339 {% if custom_registration_methods %} 354 {% if custom_registration_methods %}
340 ExecutionContext* context = currentExecutionContext(isolate); 355 ExecutionContext* context = currentExecutionContext(isolate);
341 ALLOW_UNUSED_LOCAL(context); 356 ALLOW_UNUSED_LOCAL(context);
342 {% endif %} 357 {% endif %}
343 {% if has_access_check_callbacks %} 358 {% if has_access_check_callbacks %}
344 instanceTemplate->SetAccessCheckCallback({{cpp_class}}V8Internal::securityCh eck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrap perTypeInfo))); 359 instanceTemplate->SetAccessCheckCallback({{cpp_class}}V8Internal::securityCh eck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrap perTypeInfo)));
345 {% endif %} 360 {% endif %}
346 {% if has_array_iterator %} 361 {% if has_array_iterator %}
347 {% filter runtime_enabled('RuntimeEnabledFeatures::iterableCollectionsEnable d') %} 362 {% filter runtime_enabled('RuntimeEnabledFeatures::iterableCollectionsEnable d') %}
348 {% if is_global %} 363 {% if is_global %}
349 instanceTemplate->SetIntrinsicDataProperty(v8::Symbol::GetIterator(isolate), v8::kArrayProto_values, v8::DontEnum); 364 instanceTemplate->SetIntrinsicDataProperty(v8::Symbol::GetIterator(isolate), v8::kArrayProto_values, v8::DontEnum);
350 {% else %} 365 {% else %}
351 prototypeTemplate->SetIntrinsicDataProperty(v8::Symbol::GetIterator(isolate) , v8::kArrayProto_values, v8::DontEnum); 366 prototypeTemplate->SetIntrinsicDataProperty(v8::Symbol::GetIterator(isolate) , v8::kArrayProto_values, v8::DontEnum);
352 {% endif %} 367 {% endif %}
353 {% endfilter %}{# runtime_enabled() #} 368 {% endfilter %}{# runtime_enabled() #}
354 {% endif %} 369 {% endif %}
355 {% set runtime_enabled_features = dict() %} 370 {% set runtime_enabled_features = dict() %}
371 {% set api_experiment_enabled_features = dict() %}
356 {% for attribute in attributes 372 {% for attribute in attributes
357 if attribute.runtime_enabled_function and 373 if attribute.runtime_enabled_function and
358 not attribute.exposed_test %} 374 not attribute.exposed_test %}
359 {% if attribute.runtime_enabled_function not in runtime_enabled_features %} 375 {% if attribute.runtime_enabled_function not in runtime_enabled_features %}
360 {% set unused = runtime_enabled_features.update({attribute.runtime_e nabled_function: []}) %} 376 {% set unused = runtime_enabled_features.update({attribute.runtime_e nabled_function: []}) %}
361 {% endif %} 377 {% endif %}
362 {% set unused = runtime_enabled_features.get(attribute.runtime_enabled_f unction).append(attribute) %} 378 {% set unused = runtime_enabled_features.get(attribute.runtime_enabled_f unction).append(attribute) %}
363 {% endfor %} 379 {% endfor %}
364 {% for runtime_enabled_feature in runtime_enabled_features | sort %} 380 {% for runtime_enabled_feature in runtime_enabled_features | sort %}
365 if ({{runtime_enabled_feature}}()) { 381 if ({{runtime_enabled_feature}}()) {
(...skipping 21 matching lines...) Expand all
387 {# Special operations #} 403 {# Special operations #}
388 {% if indexed_property_getter %} 404 {% if indexed_property_getter %}
389 {{install_indexed_property_handler('instanceTemplate') | indent}} 405 {{install_indexed_property_handler('instanceTemplate') | indent}}
390 {% endif %} 406 {% endif %}
391 {% if named_property_getter and not has_named_properties_object %} 407 {% if named_property_getter and not has_named_properties_object %}
392 {{install_named_property_handler('instanceTemplate') | indent}} 408 {{install_named_property_handler('instanceTemplate') | indent}}
393 {% endif %} 409 {% endif %}
394 {% if iterator_method %} 410 {% if iterator_method %}
395 {% filter exposed(iterator_method.exposed_test) %} 411 {% filter exposed(iterator_method.exposed_test) %}
396 {% filter runtime_enabled(iterator_method.runtime_enabled_function) %} 412 {% filter runtime_enabled(iterator_method.runtime_enabled_function) %}
413 {% filter api_experiment_enabled(iterator_method.api_experiment_name) %}
397 const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIterator Configuration = { v8::Symbol::GetIterator, {{cpp_class_or_partial}}V8Internal::i teratorMethodCallback, 0, v8::DontDelete, V8DOMConfiguration::ExposedToAllScript s, V8DOMConfiguration::OnPrototype }; 414 const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIterator Configuration = { v8::Symbol::GetIterator, {{cpp_class_or_partial}}V8Internal::i teratorMethodCallback, 0, v8::DontDelete, V8DOMConfiguration::ExposedToAllScript s, V8DOMConfiguration::OnPrototype };
398 V8DOMConfiguration::installMethod(isolate, prototypeTemplate, defaultSignatu re, symbolKeyedIteratorConfiguration); 415 V8DOMConfiguration::installMethod(isolate, prototypeTemplate, defaultSignatu re, symbolKeyedIteratorConfiguration);
416 {% endfilter %}{# api_experiment_enabled() #}
399 {% endfilter %}{# runtime_enabled() #} 417 {% endfilter %}{# runtime_enabled() #}
400 {% endfilter %}{# exposed() #} 418 {% endfilter %}{# exposed() #}
401 {% endif %} 419 {% endif %}
402 {# End special operations #} 420 {# End special operations #}
403 {% if has_custom_legacy_call_as_function %} 421 {% if has_custom_legacy_call_as_function %}
404 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom); 422 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom);
405 {% endif %} 423 {% endif %}
406 {% if interface_name == 'HTMLAllCollection' %} 424 {% if interface_name == 'HTMLAllCollection' %}
407 {# Needed for legacy support of document.all #} 425 {# Needed for legacy support of document.all #}
408 functionTemplate->InstanceTemplate()->MarkAsUndetectable(); 426 functionTemplate->InstanceTemplate()->MarkAsUndetectable();
409 {% endif %} 427 {% endif %}
410 {% for method in custom_registration_methods %} 428 {% for method in custom_registration_methods %}
411 {# install_custom_signature #} 429 {# install_custom_signature #}
412 {% filter conditional(method.conditional_string) %} 430 {% filter conditional(method.conditional_string) %}
413 {% filter exposed(method.overloads.exposed_test_all 431 {% filter exposed(method.overloads.exposed_test_all
414 if method.overloads else 432 if method.overloads else
415 method.exposed_test) %} 433 method.exposed_test) %}
416 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all 434 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
417 if method.overloads else 435 if method.overloads else
418 method.runtime_enabled_function) %} 436 method.runtime_enabled_function) %}
437 {% filter api_experiment_enabled(method.overloads.api_experiment_name_all
438 if method.overloads else
439 method.api_experiment_name) %}
419 {% if method.is_do_not_check_security %} 440 {% if method.is_do_not_check_security %}
420 {{install_do_not_check_security_method(method, '', 'instanceTemplate', 'prot otypeTemplate') | indent}} 441 {{install_do_not_check_security_method(method, '', 'instanceTemplate', 'prot otypeTemplate') | indent}}
421 {% else %}{# is_do_not_check_security #} 442 {% else %}{# is_do_not_check_security #}
422 {% set signature = 'v8::Local<v8::Signature>()' if method.is_do_not_check_si gnature else 'defaultSignature' %} 443 {% set signature = 'v8::Local<v8::Signature>()' if method.is_do_not_check_si gnature else 'defaultSignature' %}
423 {{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'functionTemplate', signature) | indent}} 444 {{install_custom_signature(method, 'instanceTemplate', 'prototypeTemplate', 'functionTemplate', signature) | indent}}
424 {% endif %}{# is_do_not_check_security #} 445 {% endif %}{# is_do_not_check_security #}
446 {% endfilter %}{# api_experiment_enabled() #}
425 {% endfilter %}{# runtime_enabled() #} 447 {% endfilter %}{# runtime_enabled() #}
426 {% endfilter %}{# exposed() #} 448 {% endfilter %}{# exposed() #}
427 {% endfilter %}{# conditional() #} 449 {% endfilter %}{# conditional() #}
428 {% endfor %} 450 {% endfor %}
429 {# Special interfaces #} 451 {# Special interfaces #}
430 {% if not is_partial %} 452 {% if not is_partial %}
431 {% if interface_name == 'Window' %} 453 {% if interface_name == 'Window' %}
432 454
433 instanceTemplate->SetInternalFieldCount(V8Window::internalFieldCount); 455 instanceTemplate->SetInternalFieldCount(V8Window::internalFieldCount);
434 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount); 456 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount);
(...skipping 23 matching lines...) Expand all
458 {% endfor %} 480 {% endfor %}
459 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 481 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
460 {{attribute_getter_implemented_in_private_script(attribute)}} 482 {{attribute_getter_implemented_in_private_script(attribute)}}
461 {% if attribute.has_setter %} 483 {% if attribute.has_setter %}
462 {{attribute_setter_implemented_in_private_script(attribute)}} 484 {{attribute_setter_implemented_in_private_script(attribute)}}
463 {% endif %} 485 {% endif %}
464 {% endfor %} 486 {% endfor %}
465 {% block partial_interface %}{% endblock %} 487 {% block partial_interface %}{% endblock %}
466 } // namespace blink 488 } // namespace blink
467 {% endfilter %} 489 {% endfilter %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698