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

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

Issue 1386843002: bindings: Implements the named properties object (WindowProperties). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated IDL test results. Created 5 years, 2 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' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% block indexed_property_getter %} 5 {% block indexed_property_getter %}
6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
7 {% set getter = indexed_property_getter %} 7 {% set getter = indexed_property_getter %}
8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
9 { 9 {
10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} 639 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %}
640 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' if method.is_do_not _check_signature else 'V8DOMConfiguration::CheckHolder' %} 640 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' if method.is_do_not _check_signature else 'V8DOMConfiguration::CheckHolder' %}
641 const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSafeAttrib uteConfiguration = { 641 const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSafeAttrib uteConfiguration = {
642 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, &{{v8_class}}::wrapperT ypeInfo, v8::ALL_CAN_READ, {{property_attribute}}, {{only_exposed_to_private_scr ipt}}, {{property_location(method)}}, {{holder_check}}, 642 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, &{{v8_class}}::wrapperT ypeInfo, v8::ALL_CAN_READ, {{property_attribute}}, {{only_exposed_to_private_scr ipt}}, {{property_location(method)}}, {{holder_check}},
643 }; 643 };
644 V8DOMConfiguration::installAttribute(isolate, {{instance_template}}, {{prototype _template}}, {{method.name}}OriginSafeAttributeConfiguration); 644 V8DOMConfiguration::installAttribute(isolate, {{instance_template}}, {{prototype _template}}, {{method.name}}OriginSafeAttributeConfiguration);
645 {%- endmacro %} 645 {%- endmacro %}
646 646
647 647
648 {##############################################################################} 648 {##############################################################################}
649 {% macro install_indexed_property_handler(target) %}
650 {% set indexed_property_getter_callback =
651 '%sV8Internal::indexedPropertyGetterCallback' % cpp_class %}
652 {% set indexed_property_setter_callback =
653 '%sV8Internal::indexedPropertySetterCallback' % cpp_class
654 if indexed_property_setter else '0' %}
655 {% set indexed_property_query_callback = '0' %}{# Unused #}
656 {% set indexed_property_deleter_callback =
657 '%sV8Internal::indexedPropertyDeleterCallback' % cpp_class
658 if indexed_property_deleter else '0' %}
659 {% set indexed_property_enumerator_callback =
660 'indexedPropertyEnumerator<%s>' % cpp_class
661 if indexed_property_getter.is_enumerable else '0' %}
662 {% set property_handler_flags =
663 'v8::PropertyHandlerFlags::kAllCanRead'
664 if indexed_property_getter.do_not_check_security
665 else 'v8::PropertyHandlerFlags::kNone' %}
666 v8::IndexedPropertyHandlerConfiguration indexedPropertyHandlerConfig({{indexed_p roperty_getter_callback}}, {{indexed_property_setter_callback}}, {{indexed_prope rty_query_callback}}, {{indexed_property_deleter_callback}}, {{indexed_property_ enumerator_callback}}, v8::Local<v8::Value>(), {{property_handler_flags}});
667 {{target}}->SetHandler(indexedPropertyHandlerConfig);
668 {%- endmacro %}
669
670
671 {##############################################################################}
672 {% macro install_named_property_handler(target) %}
673 {% set named_property_getter_callback =
674 '%sV8Internal::namedPropertyGetterCallback' % cpp_class %}
675 {% set named_property_setter_callback =
676 '%sV8Internal::namedPropertySetterCallback' % cpp_class
677 if named_property_setter else '0' %}
678 {% set named_property_query_callback =
679 '%sV8Internal::namedPropertyQueryCallback' % cpp_class
680 if named_property_getter.is_enumerable else '0' %}
681 {% set named_property_deleter_callback =
682 '%sV8Internal::namedPropertyDeleterCallback' % cpp_class
683 if named_property_deleter else '0' %}
684 {% set named_property_enumerator_callback =
685 '%sV8Internal::namedPropertyEnumeratorCallback' % cpp_class
686 if named_property_getter.is_enumerable else '0' %}
687 {% set property_handler_flags_list =
688 ['int(v8::PropertyHandlerFlags::kOnlyInterceptStrings)'] %}
689 {% if named_property_getter.do_not_check_security %}
690 {% set property_handler_flags_list =
691 property_handler_flags_list + ['int(v8::PropertyHandlerFlags::kAllCanRead )'] %}
692 {% endif %}
693 {% if not is_override_builtins %}
694 {% set property_handler_flags_list =
695 property_handler_flags_list + ['int(v8::PropertyHandlerFlags::kNonMasking )'] %}
696 {% endif %}
697 {% set property_handler_flags =
698 'static_cast<v8::PropertyHandlerFlags>(%s)' %
699 ' | '.join(property_handler_flags_list) %}
700 v8::NamedPropertyHandlerConfiguration namedPropertyHandlerConfig({{named_propert y_getter_callback}}, {{named_property_setter_callback}}, {{named_property_query_ callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator_cal lback}}, v8::Local<v8::Value>(), {{property_handler_flags}});
701 {{target}}->SetHandler(namedPropertyHandlerConfig);
702 {%- endmacro %}
703
704
705 {##############################################################################}
649 {% block get_dom_template %} 706 {% block get_dom_template %}
650 {% if not is_array_buffer_or_view %} 707 {% if not is_array_buffer_or_view %}
651 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate) 708 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate)
652 { 709 {
653 {% if has_partial_interface %} 710 {% if has_partial_interface %}
654 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class , v8_class) %} 711 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class , v8_class) %}
655 ASSERT({{installTemplateFunction}} != {{v8_class}}::install{{v8_class}}Templ ate); 712 ASSERT({{installTemplateFunction}} != {{v8_class}}::install{{v8_class}}Templ ate);
656 {% else %} 713 {% else %}
657 {% set installTemplateFunction = 'install%sTemplate' % v8_class %} 714 {% set installTemplateFunction = 'install%sTemplate' % v8_class %}
658 {% endif %} 715 {% endif %}
659 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class, v8 _class) if has_partial_interface else 'install%sTemplate' % v8_class %} 716 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class, v8 _class) if has_partial_interface else 'install%sTemplate' % v8_class %}
660 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), {{installTemplateFunction}}); 717 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), {{installTemplateFunction}});
661 } 718 }
662 719
663 {% endif %} 720 {% endif %}
664 {% endblock %} 721 {% endblock %}
665 722
666 723
667 {##############################################################################} 724 {##############################################################################}
725 {% block get_dom_template_for_named_properties_object %}
726 {% if has_named_properties_object %}
727 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplateForNamedPropertiesObjec t(v8::Isolate* isolate)
728 {
729 v8::Local<v8::FunctionTemplate> parentTemplate = V8{{parent_interface}}::dom Template(isolate);
730
731 v8::Local<v8::FunctionTemplate> namedPropertiesObjectFunctionTemplate = v8:: FunctionTemplate::New(isolate);
732 namedPropertiesObjectFunctionTemplate->SetClassName(v8AtomicString(isolate, "{{interface_name}}Properties"));
733 namedPropertiesObjectFunctionTemplate->Inherit(parentTemplate);
734
735 v8::Local<v8::ObjectTemplate> namedPropertiesObjectTemplate = namedPropertie sObjectFunctionTemplate->PrototypeTemplate();
736 namedPropertiesObjectTemplate->SetInternalFieldCount({{v8_class}}::internalF ieldCount);
737 {{install_named_property_handler('namedPropertiesObjectTemplate') | indent}}
738
739 return namedPropertiesObjectFunctionTemplate;
740 }
741
742 {% endif %}
743 {% endblock %}
744
745
746 {##############################################################################}
668 {% block has_instance %} 747 {% block has_instance %}
669 bool {{v8_class}}::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolat e) 748 bool {{v8_class}}::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolat e)
670 { 749 {
671 {% if is_array_buffer_or_view %} 750 {% if is_array_buffer_or_view %}
672 return v8Value->Is{{interface_name}}(); 751 return v8Value->Is{{interface_name}}();
673 {% else %} 752 {% else %}
674 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e); 753 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e);
675 {% endif %} 754 {% endif %}
676 } 755 }
677 756
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction; 974 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction;
896 if (preparePrototypeAndInterfaceObjectFunction) 975 if (preparePrototypeAndInterfaceObjectFunction)
897 {{v8_class}}::wrapperTypeInfo.preparePrototypeAndInterfaceObjectFunction = preparePrototypeAndInterfaceObjectFunction; 976 {{v8_class}}::wrapperTypeInfo.preparePrototypeAndInterfaceObjectFunction = preparePrototypeAndInterfaceObjectFunction;
898 } 977 }
899 978
900 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 979 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
901 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) 980 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
902 { 981 {
903 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 982 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
904 } 983 }
984
905 {% endfor %} 985 {% endfor %}
906 {% endif %} 986 {% endif %}
907 {% endblock %} 987 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698