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

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

Issue 2873543002: First implementation of lazily cached accessor for DOM attributes. (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 {% extends 'interface_base.cpp.tmpl' %} 1 {% extends 'interface_base.cpp.tmpl' %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% block indexed_property_getter %} 4 {% block indexed_property_getter %}
5 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 5 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
6 {% set getter = indexed_property_getter %} 6 {% set getter = indexed_property_getter %}
7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) { 7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) {
8 {% if getter.is_raises_exception %} 8 {% if getter.is_raises_exception %}
9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedGette rContext, "{{interface_name}}"); 9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kIndexedGette rContext, "{{interface_name}}");
10 {% endif %} 10 {% endif %}
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 if not method.is_unforgeable else 'nullptr' %} 671 if not method.is_unforgeable else 'nullptr' %}
672 {% set property_attribute = 672 {% set property_attribute =
673 'static_cast<v8::PropertyAttribute>(%s)' % 673 'static_cast<v8::PropertyAttribute>(%s)' %
674 ' | '.join(method.property_attributes or ['v8::None']) %} 674 ' | '.join(method.property_attributes or ['v8::None']) %}
675 {% set holder_check = 'V8DOMConfiguration::kCheckHolder' %} 675 {% set holder_check = 'V8DOMConfiguration::kCheckHolder' %}
676 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration[] = { 676 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration[] = {
677 {% if method.is_per_world_bindings %} 677 {% if method.is_per_world_bindings %}
678 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %} 678 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %}
679 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback 679 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback
680 if not method.is_unforgeable else 'nullptr' %} 680 if not method.is_unforgeable else 'nullptr' %}
681 {"{{method.name}}", {{getter_callback_for_main_world}}, {{setter_callback_fo r_main_world}}, nullptr, &{{v8_class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}}, {{holder_check}}, V8DOMConfiguration::MainWorld} , 681 {"{{method.name}}", {{getter_callback_for_main_world}}, {{setter_callback_fo r_main_world}}, &{{v8_class}}::wrapperTypeInfo, {{property_attribute}}, {{proper ty_location(method)}}, {{holder_check}}, V8DOMConfiguration::MainWorld},
682 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, nullptr, &{{v8 _class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}} , {{holder_check}}, V8DOMConfiguration::NonMainWorlds}} 682 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, &{{v8_class}}: :wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}}, {{holde r_check}}, V8DOMConfiguration::NonMainWorlds}}
683 {% else %} 683 {% else %}
684 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, nullptr, &{{v8 _class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}} , {{holder_check}}, V8DOMConfiguration::kAllWorlds} 684 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, &{{v8_class}}: :wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}}, {{holde r_check}}, V8DOMConfiguration::kAllWorlds}
685 {% endif %} 685 {% endif %}
686 }; 686 };
687 for (const auto& attributeConfig : {{method.name}}OriginSafeAttributeConfigurati on) 687 for (const auto& attributeConfig : {{method.name}}OriginSafeAttributeConfigurati on)
688 V8DOMConfiguration::InstallAttribute(isolate, world, {{instance_template}}, {{ prototype_template}}, attributeConfig); 688 V8DOMConfiguration::InstallAttribute(isolate, world, {{instance_template}}, {{ prototype_template}}, attributeConfig);
689 {%- endmacro %} 689 {%- endmacro %}
690 690
691 691
692 {##############################################################################} 692 {##############################################################################}
693 {% macro install_indexed_property_handler(target) %} 693 {% macro install_indexed_property_handler(target) %}
694 {% set indexed_property_getter_callback = 694 {% set indexed_property_getter_callback =
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 {{cpp_class}}* nativeValue = {{v8_class}}::toImplWithTypeCheck(isolate, value) ; 895 {{cpp_class}}* nativeValue = {{v8_class}}::toImplWithTypeCheck(isolate, value) ;
896 if (!nativeValue) { 896 if (!nativeValue) {
897 exceptionState.ThrowTypeError(ExceptionMessages::FailedToConvertJSValue( 897 exceptionState.ThrowTypeError(ExceptionMessages::FailedToConvertJSValue(
898 "{{interface_name}}")); 898 "{{interface_name}}"));
899 } 899 }
900 return nativeValue; 900 return nativeValue;
901 } 901 }
902 902
903 {% endblock %} 903 {% endblock %}
904 904
905
906 {##############################################################################} 905 {##############################################################################}
907 {% block partial_interface %} 906 {% block partial_interface %}
908 {% if has_partial_interface %} 907 {% if has_partial_interface %}
909 {% if needs_runtime_enabled_installer %} 908 {% if needs_runtime_enabled_installer %}
910 InstallRuntimeEnabledFunction {{v8_class}}::install{{v8_class}}RuntimeEnabledFun ction = 909 InstallRuntimeEnabledFunction {{v8_class}}::install{{v8_class}}RuntimeEnabledFun ction =
911 &{{v8_class}}::installRuntimeEnabledFeatures; 910 &{{v8_class}}::installRuntimeEnabledFeatures;
912 {% endif %} 911 {% endif %}
913 912
914 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = 913 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction =
915 &{{v8_class}}::install{{v8_class}}Template; 914 &{{v8_class}}::install{{v8_class}}Template;
(...skipping 18 matching lines...) Expand all
934 } 933 }
935 934
936 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 935 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
937 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { 936 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) {
938 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 937 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
939 } 938 }
940 939
941 {% endfor %} 940 {% endfor %}
942 {% endif %} 941 {% endif %}
943 {% endblock %} 942 {% endblock %}
943
Yuki 2017/05/09 06:06:31 nit: Remove this empty line.
nverne 2017/05/10 02:11:49 Done
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698