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

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

Issue 618373003: [bindings] partial interfaces should not violate componentization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added --target-component instead of --genearte-partial Created 6 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 | Annotate | Revision Log
OLDNEW
1 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% block security_check_functions %}
6 {% if has_access_check_callbacks %}
7 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>)
8 {
9 {{cpp_class}}* impl = {{v8_class}}::toImpl(host);
10 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
11 }
12
13 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>)
14 {
15 {{cpp_class}}* impl = {{v8_class}}::toImpl(host);
16 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError);
17 }
18
19 {% endif %}
20 {% endblock %}
21
22
23 {##############################################################################}
24 {% block indexed_property_getter %} 5 {% block indexed_property_getter %}
25 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
26 {% set getter = indexed_property_getter %} 7 {% set getter = indexed_property_getter %}
27 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)
28 { 9 {
29 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
30 {% if getter.is_raises_exception %} 11 {% if getter.is_raises_exception %}
31 ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "{{inter face_name}}", info.Holder(), info.GetIsolate()); 12 ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "{{inter face_name}}", info.Holder(), info.GetIsolate());
32 {% endif %} 13 {% endif %}
33 {% set getter_name = getter.name or 'anonymousIndexedGetter' %} 14 {% set getter_name = getter.name or 'anonymousIndexedGetter' %}
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 420 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
440 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, info); 421 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, info);
441 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 422 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
442 } 423 }
443 424
444 {% endif %} 425 {% endif %}
445 {% endblock %} 426 {% endblock %}
446 427
447 428
448 {##############################################################################} 429 {##############################################################################}
430 {% block named_constructor %}
449 {% from 'methods.cpp' import generate_constructor with context %} 431 {% from 'methods.cpp' import generate_constructor with context %}
450 {% block named_constructor %}
451 {% if named_constructor %} 432 {% if named_constructor %}
452 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class 433 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class
453 if is_active_dom_object else '0' %} 434 if is_active_dom_object else '0' %}
454 {% set to_event_target = '%s::toEventTarget' % v8_class 435 {% set to_event_target = '%s::toEventTarget' % v8_class
455 if is_event_target else '0' %} 436 if is_event_target else '0' %}
456 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::refObject, {{v8_clas s}}::derefObject, {{v8_class}}::createPersistentHandle, {{to_active_dom_object}} , {{to_event_target}}, 0, {{v8_class}}::installConditionallyEnabledMethods, {{v8 _class}}::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperType ObjectPrototype, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{lifet ime}}, WrapperTypeInfo::{{gc_type}} }; 437 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::refObject, {{v8_clas s}}::derefObject, {{v8_class}}::createPersistentHandle, {{to_active_dom_object}} , {{to_event_target}}, 0, {{v8_class}}::installConditionallyEnabledMethods, {{v8 _class}}::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperType ObjectPrototype, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{lifet ime}}, WrapperTypeInfo::{{gc_type}} };
457 438
458 {{generate_constructor(named_constructor)}} 439 {{generate_constructor(named_constructor)}}
459 v8::Handle<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolat e* isolate) 440 v8::Handle<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolat e* isolate)
460 { 441 {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 } 594 }
614 {% endif %} 595 {% endif %}
615 setObjectGroup(internalPointer, wrapper, isolate); 596 setObjectGroup(internalPointer, wrapper, isolate);
616 } 597 }
617 598
618 {% endif %} 599 {% endif %}
619 {% endblock %} 600 {% endblock %}
620 601
621 602
622 {##############################################################################} 603 {##############################################################################}
604 {% block shadow_attributes %}
623 {% from 'attributes.cpp' import attribute_configuration with context %} 605 {% from 'attributes.cpp' import attribute_configuration with context %}
624 {% block shadow_attributes %}
625 {% if interface_name == 'Window' %} 606 {% if interface_name == 'Window' %}
626 static const V8DOMConfiguration::AttributeConfiguration shadowAttributes[] = { 607 static const V8DOMConfiguration::AttributeConfiguration shadowAttributes[] = {
627 {% for attribute in attributes if attribute.is_unforgeable and attribute.sho uld_be_exposed_to_script %} 608 {% for attribute in attributes if attribute.is_unforgeable and attribute.sho uld_be_exposed_to_script %}
628 {{attribute_configuration(attribute)}}, 609 {{attribute_configuration(attribute)}},
629 {% endfor %} 610 {% endfor %}
630 }; 611 };
631 612
632 {% endif %} 613 {% endif %}
633 {% endblock %} 614 {% endblock %}
634 615
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 "{{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}}, V8DOMConfiguration::OnInstance, 722 "{{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}}, V8DOMConfiguration::OnInstance,
742 }; 723 };
743 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate); 724 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate);
744 {%- endmacro %} 725 {%- endmacro %}
745 726
746 727
747 {##############################################################################} 728 {##############################################################################}
748 {% block get_dom_template %} 729 {% block get_dom_template %}
749 v8::Handle<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate) 730 v8::Handle<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate)
750 { 731 {
751 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), install{{v8_class}}Template); 732 {% if has_partial_interface %}
733 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class , v8_class) %}
734 ASSERT({{installTemplateFunction}} != {{actual_v8_class}}::install{{v8_class }}Template);
735 {% else %}
736 {% set installTemplateFunction = 'install%sTemplate' % v8_class %}
737 {% endif %}
738 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class, v8 _class) if has_partial_interface else 'install%sTemplate' % v8_class %}
739 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), {{installTemplateFunction}});
752 } 740 }
753 741
754 {% endblock %} 742 {% endblock %}
755 743
756 744
757 {##############################################################################} 745 {##############################################################################}
758 {% block has_instance %} 746 {% block has_instance %}
759 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isola te) 747 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isola te)
760 { 748 {
761 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e); 749 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e);
(...skipping 11 matching lines...) Expand all
773 {% block to_impl_with_type_check %} 761 {% block to_impl_with_type_check %}
774 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl e<v8::Value> value) 762 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl e<v8::Value> value)
775 { 763 {
776 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle <v8::Object>::Cast(value))->toImpl<{{cpp_class}}>() : 0; 764 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle <v8::Object>::Cast(value))->toImpl<{{cpp_class}}>() : 0;
777 } 765 }
778 766
779 {% endblock %} 767 {% endblock %}
780 768
781 769
782 {##############################################################################} 770 {##############################################################################}
783 {% block install_conditional_attributes %}
784 {% if has_conditional_attributes %}
785 void {{v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::Object> instanceObject, v8::Isolate* isolate)
786 {
787 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instance Object->GetPrototype());
788 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext());
789
790 {% for attribute in attributes if attribute.per_context_enabled_function or attribute.exposed_test %}
791 {% filter per_context_enabled(attribute.per_context_enabled_function) %}
792 {% filter exposed(attribute.exposed_test) %}
793 static const V8DOMConfiguration::AttributeConfiguration attributeConfigurati on =\
794 {{attribute_configuration(attribute)}};
795 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attrib uteConfiguration, isolate);
796 {% endfilter %}
797 {% endfilter %}
798 {% endfor %}
799 }
800
801 {% endif %}
802 {% endblock %}
803
804
805 {##############################################################################}
806 {% block install_conditional_methods %}
807 {% if conditionally_enabled_methods %}
808 void {{v8_class}}::installConditionallyEnabledMethods(v8::Handle<v8::Object> pro totypeObject, v8::Isolate* isolate)
809 {
810 {# Define per-context enabled operations #}
811 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate));
812 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext());
813 ASSERT(context);
814
815 {% for method in conditionally_enabled_methods %}
816 {% filter per_context_enabled(method.per_context_enabled_function) %}
817 {% filter exposed(method.exposed_test) %}
818 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio nTemplate::New(isolate, {{cpp_class}}V8Internal::{{method.name}}MethodCallback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})->GetFu nction());
819 {% endfilter %}
820 {% endfilter %}
821 {% endfor %}
822 }
823
824 {% endif %}
825 {% endblock %}
826
827
828 {##############################################################################}
829 {% block to_active_dom_object %} 771 {% block to_active_dom_object %}
830 {% if is_active_dom_object %} 772 {% if is_active_dom_object %}
831 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper) 773 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper)
832 { 774 {
833 return toImpl(wrapper); 775 return toImpl(wrapper);
834 } 776 }
835 777
836 {% endif %} 778 {% endif %}
837 {% endblock %} 779 {% endblock %}
838 780
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 {% endif %} 902 {% endif %}
961 } 903 }
962 904
963 template<> 905 template<>
964 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 906 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
965 { 907 {
966 return toV8(impl, creationContext, isolate); 908 return toV8(impl, creationContext, isolate);
967 } 909 }
968 910
969 {% endblock %} 911 {% endblock %}
912
913 {##############################################################################}
914 {% block partial_interface %}
915 {% if has_partial_interface %}
916 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template;
917
918 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate Function, InstallConditionallyEnabledMethodsFunction installConditionallyEnabled MethodsFunction)
919 {
920 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction;
921 if (installConditionallyEnabledMethodsFunction)
922 {{v8_class}}::wrapperTypeInfo.installConditionallyEnabledMethodsFunction = installConditionallyEnabledMethodsFunction;
923 }
924
925 {% for method in methods %}
bashi 2014/10/15 05:29:23 nit: you can merge "for" and "if" like above.
tasak 2014/10/15 11:24:19 Done.
926 {% if method.overloads and method.overloads.has_partial_overloads %}
927 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
928 {
929 {{actual_cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = m ethod;
930 }
931 {% endif %}
932 {% endfor %}
933 {% endif %}
934 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698