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

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

Issue 1531443003: [bindings] Implement an ExperimentEnabled IDL extended attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %} 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro attribute_getter(attribute, world_suffix) %} 5 {% macro attribute_getter(attribute, world_suffix) %}
6 {% filter conditional(attribute.conditional_string) %} 6 {% filter conditional(attribute.conditional_string) %}
7 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 7 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
8 {%- if attribute.is_data_type_property %} 8 {%- if attribute.is_data_type_property %}
9 const v8::PropertyCallbackInfo<v8::Value>& info 9 const v8::PropertyCallbackInfo<v8::Value>& info
10 {%- else %} 10 {%- else %}
11 const v8::FunctionCallbackInfo<v8::Value>& info 11 const v8::FunctionCallbackInfo<v8::Value>& info
12 {%- endif %}) 12 {%- endif %})
13 { 13 {
14 {% if attribute.experimental_api_name %}
15 String errorMessage;
haraken 2015/12/16 02:16:41 What is this errorMessage for?
Daniel Nishi 2015/12/16 21:42:02 It explains why an experiment may have failed. Wh
16 if (!Experiments::isApiEnabled(currentExecutionContext(info.GetIsolate()), " {{ attribute.experimental_api_name }}", errorMessage)) {
haraken 2015/12/16 02:16:41 Do you have a CL to implement the isAPIEnabled? I
Daniel Nishi 2015/12/16 21:42:02 https://code.google.com/p/chromium/codesearch#chro
17 v8SetReturnValue(info, v8::Undefined(info.GetIsolate()));
18 return;
19 }
20 {% endif %}
14 {% if attribute.is_reflect and not attribute.is_url 21 {% if attribute.is_reflect and not attribute.is_url
15 and attribute.idl_type == 'DOMString' and is_node 22 and attribute.idl_type == 'DOMString' and is_node
16 and not attribute.is_implemented_in_private_script %} 23 and not attribute.is_implemented_in_private_script %}
17 {% set cpp_class, v8_class = 'Element', 'V8Element' %} 24 {% set cpp_class, v8_class = 'Element', 'V8Element' %}
18 {% endif %} 25 {% endif %}
19 {# holder #} 26 {# holder #}
20 {% if not attribute.is_static %} 27 {% if not attribute.is_static %}
21 {% if attribute.is_lenient_this %} 28 {% if attribute.is_lenient_this %}
22 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in fo.This(), info.GetIsolate()); 29 v8::Local<v8::Object> holder = {{v8_class}}::findInstanceInPrototypeChain(in fo.This(), info.GetIsolate());
23 if (holder.IsEmpty()) 30 if (holder.IsEmpty())
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 {% endmacro %} 468 {% endmacro %}
462 469
463 470
464 {##############################################################################} 471 {##############################################################################}
465 {% macro attribute_configuration(attribute) %} 472 {% macro attribute_configuration(attribute) %}
466 {% from 'conversions.cpp' import property_location %} 473 {% from 'conversions.cpp' import property_location %}
467 {% if attribute.constructor_type %} 474 {% if attribute.constructor_type %}
468 {% set getter_callback = 475 {% set getter_callback =
469 '%sV8Internal::%sConstructorGetterCallback' % (cpp_class_or_partial, attr ibute.name) 476 '%sV8Internal::%sConstructorGetterCallback' % (cpp_class_or_partial, attr ibute.name)
470 if attribute.needs_constructor_getter_callback else 477 if attribute.needs_constructor_getter_callback else
471 'v8ConstructorAttributeGetter' %} 478 'is%sExperimentallyEnabled' % attribute.name if attribute.experimental_ap i_name else 'v8ConstructorAttributeGetter' %}
haraken 2015/12/16 02:16:41 Avoid using "if ... else ... if ... else".
Daniel Nishi 2015/12/16 21:42:02 I've removed this by eliminating is%sExperimentall
472 {% set setter_callback = 479 {% set setter_callback =
473 '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_or_partial, attrib ute.name) 480 '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_or_partial, attrib ute.name)
474 if attribute.needs_constructor_setter_callback else 481 if attribute.needs_constructor_setter_callback else
475 '%sV8Internal::%sConstructorAttributeSetterCallback' % (cpp_class_or_part ial, cpp_class) %} 482 '%sV8Internal::%sConstructorAttributeSetterCallback' % (cpp_class_or_part ial, cpp_class) %}
476 {% else %}{# regular attributes #} 483 {% else %}{# regular attributes #}
477 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' % 484 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' %
478 (cpp_class_or_partial, attribute.name) %} 485 (cpp_class_or_partial, attribute.name) %}
479 {% set setter_callback = '%sV8Internal::%sAttributeSetterCallback' % 486 {% set setter_callback = '%sV8Internal::%sAttributeSetterCallback' %
480 (cpp_class_or_partial, attribute.name) 487 (cpp_class_or_partial, attribute.name)
481 if attribute.has_setter else '0' %} 488 if attribute.has_setter else '0' %}
(...skipping 30 matching lines...) Expand all
512 setter_callback_for_main_world, 519 setter_callback_for_main_world,
513 wrapper_type_info, 520 wrapper_type_info,
514 access_control, 521 access_control,
515 property_attribute, 522 property_attribute,
516 only_exposed_to_private_script, 523 only_exposed_to_private_script,
517 property_location(attribute), 524 property_location(attribute),
518 holder_check, 525 holder_check,
519 ] %} 526 ] %}
520 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 527 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
521 {%- endmacro %} 528 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698