OLD | NEW |
---|---|
1 {% extends 'interface_base.cpp' %} | 1 {% extends 'interface_base.cpp' %} |
2 | 2 |
3 | 3 |
4 {##############################################################################} | 4 {##############################################################################} |
5 {% block security_check_functions %} | 5 {% block security_check_functions %} |
6 {% if has_access_check_callbacks %} | 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>) | 7 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>) |
8 { | 8 { |
9 {{cpp_class}}* impl = {{v8_class}}::toImpl(host); | 9 {{cpp_class}}* impl = {{v8_class}}::toImpl(host); |
10 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError); | 10 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), impl->frame(), DoNotReportSecurityError); |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
739 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} | 739 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} |
740 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration = { | 740 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration = { |
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, | 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, |
742 }; | 742 }; |
743 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate); | 743 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate); |
744 {%- endmacro %} | 744 {%- endmacro %} |
745 | 745 |
746 | 746 |
747 {##############################################################################} | 747 {##############################################################################} |
748 {% block get_dom_template %} | 748 {% block get_dom_template %} |
749 {% if is_v8object %} | |
749 v8::Handle<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate) | 750 v8::Handle<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate) |
750 { | 751 { |
751 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), install{{v8_class}}Template); | 752 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), install{{v8_class}}Template); |
752 } | 753 } |
753 | 754 |
755 {% endif %} | |
754 {% endblock %} | 756 {% endblock %} |
755 | 757 |
756 | 758 |
757 {##############################################################################} | 759 {##############################################################################} |
758 {% block has_instance %} | 760 {% block has_instance %} |
759 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isola te) | 761 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isola te) |
760 { | 762 { |
763 {% if is_v8object %} | |
761 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e); | 764 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e); |
765 {% else %} | |
766 return v8Value->Is{{interface_name}}(); | |
767 {% endif %} | |
762 } | 768 } |
763 | 769 |
770 {% if is_v8object %} | |
764 v8::Handle<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Handle<v8: :Value> v8Value, v8::Isolate* isolate) | 771 v8::Handle<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Handle<v8: :Value> v8Value, v8::Isolate* isolate) |
765 { | 772 { |
766 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe rTypeInfo, v8Value); | 773 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe rTypeInfo, v8Value); |
767 } | 774 } |
768 | 775 |
776 {% endif %} | |
769 {% endblock %} | 777 {% endblock %} |
770 | 778 |
771 | 779 |
780 {##############################################################################} | |
781 {% block to_impl %} | |
782 {% if interface_name == 'ArrayBuffer' %} | |
haraken
2014/10/14 15:11:18
Can we add a run-binding-test for ArrayBuffer inte
Yuki
2014/10/15 09:35:23
Will do.
| |
783 DOMArrayBuffer* V8ArrayBuffer::toImpl(v8::Handle<v8::Object> object) | |
784 { | |
785 ASSERT(object->IsArrayBuffer()); | |
786 v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>(); | |
787 if (v8buffer->IsExternal()) { | |
788 RELEASE_ASSERT(toWrapperTypeInfo(object)->ginEmbedder == gin::kEmbedderB link); | |
789 return blink::toScriptWrappableBase(object)->toImpl<DOMArrayBuffer>(); | |
790 } | |
791 | |
792 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); | |
793 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength() , 0); | |
794 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(contents); | |
795 buffer->associateWithWrapper(buffer->wrapperTypeInfo(), object, v8::Isolate: :GetCurrent()); | |
796 | |
797 return blink::toScriptWrappableBase(object)->toImpl<DOMArrayBuffer>(); | |
798 } | |
799 {% elif interface_name == 'ArrayBufferView' %} | |
800 DOMArrayBufferView* V8ArrayBufferView::toImpl(v8::Handle<v8::Object> object) | |
801 { | |
802 ASSERT(object->IsArrayBufferView()); | |
803 ScriptWrappableBase* internalPointer = blink::toScriptWrappableBase(object); | |
804 if (internalPointer) | |
805 return internalPointer->toImpl<DOMArrayBufferView>(); | |
806 | |
807 if (object->IsInt8Array()) | |
808 return V8Int8Array::toImpl(object); | |
809 if (object->IsInt16Array()) | |
810 return V8Int16Array::toImpl(object); | |
811 if (object->IsInt32Array()) | |
812 return V8Int32Array::toImpl(object); | |
813 if (object->IsUint8Array()) | |
814 return V8Uint8Array::toImpl(object); | |
815 if (object->IsUint8ClampedArray()) | |
816 return V8Uint8ClampedArray::toImpl(object); | |
817 if (object->IsUint16Array()) | |
818 return V8Uint16Array::toImpl(object); | |
819 if (object->IsUint32Array()) | |
820 return V8Uint32Array::toImpl(object); | |
821 if (object->IsFloat32Array()) | |
822 return V8Float32Array::toImpl(object); | |
823 if (object->IsFloat64Array()) | |
824 return V8Float64Array::toImpl(object); | |
825 if (object->IsDataView()) | |
826 return V8DataView::toImpl(object); | |
827 | |
828 ASSERT_NOT_REACHED(); | |
829 return 0; | |
830 } | |
831 {% elif is_array_type %} | |
832 {{cpp_class}}* {{v8_class}}::toImpl(v8::Handle<v8::Object> object) | |
833 { | |
834 ASSERT(object->Is{{interface_name}}()); | |
835 ScriptWrappableBase* internalPointer = blink::toScriptWrappableBase(object); | |
836 if (internalPointer) | |
haraken
2014/10/14 15:11:18
Just help me understand: In what scenario can the
Yuki
2014/10/15 09:35:23
There are cases that JS code (i.e. V8) creates an
| |
837 return internalPointer->toImpl<{{cpp_class}}>(); | |
838 | |
839 v8::Handle<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}} >(); | |
840 RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toIm pl(v8View->Buffer()), v8View->ByteOffset(), v8View->{% if interface_name == 'Dat aView' %}Byte{% endif %}Length()); | |
841 typedArray->associateWithWrapper(typedArray->wrapperTypeInfo(), object, v8:: Isolate::GetCurrent()); | |
haraken
2014/10/14 15:11:18
We should pass |isolate| to toImpl() and avoid cal
| |
842 | |
843 internalPointer = blink::toScriptWrappableBase(object); | |
844 ASSERT(internalPointer); | |
845 return internalPointer->toImpl<{{cpp_class}}>(); | |
846 } | |
847 {% endif %} | |
848 | |
849 {% endblock %} | |
850 | |
851 | |
772 {##############################################################################} | 852 {##############################################################################} |
773 {% block to_impl_with_type_check %} | 853 {% block to_impl_with_type_check %} |
774 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl e<v8::Value> value) | 854 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl e<v8::Value> value) |
775 { | 855 { |
776 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle <v8::Object>::Cast(value))->toImpl<{{cpp_class}}>() : 0; | 856 return hasInstance(value, isolate) ? toImpl(v8::Handle<v8::Object>::Cast(val ue)) : 0; |
777 } | 857 } |
778 | 858 |
779 {% endblock %} | 859 {% endblock %} |
780 | 860 |
781 | 861 |
782 {##############################################################################} | 862 {##############################################################################} |
783 {% block install_conditional_attributes %} | 863 {% block install_conditional_attributes %} |
784 {% if has_conditional_attributes %} | 864 {% if is_v8object and has_conditional_attributes %} |
785 void {{v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::Object> instanceObject, v8::Isolate* isolate) | 865 void {{v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::Object> instanceObject, v8::Isolate* isolate) |
786 { | 866 { |
787 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instance Object->GetPrototype()); | 867 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instance Object->GetPrototype()); |
788 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext()); | 868 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext()); |
789 | 869 |
790 {% for attribute in attributes if attribute.per_context_enabled_function or attribute.exposed_test %} | 870 {% for attribute in attributes if attribute.per_context_enabled_function or attribute.exposed_test %} |
791 {% filter per_context_enabled(attribute.per_context_enabled_function) %} | 871 {% filter per_context_enabled(attribute.per_context_enabled_function) %} |
792 {% filter exposed(attribute.exposed_test) %} | 872 {% filter exposed(attribute.exposed_test) %} |
793 static const V8DOMConfiguration::AttributeConfiguration attributeConfigurati on =\ | 873 static const V8DOMConfiguration::AttributeConfiguration attributeConfigurati on =\ |
794 {{attribute_configuration(attribute)}}; | 874 {{attribute_configuration(attribute)}}; |
795 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attrib uteConfiguration, isolate); | 875 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attrib uteConfiguration, isolate); |
796 {% endfilter %} | 876 {% endfilter %} |
797 {% endfilter %} | 877 {% endfilter %} |
798 {% endfor %} | 878 {% endfor %} |
799 } | 879 } |
800 | 880 |
801 {% endif %} | 881 {% endif %} |
802 {% endblock %} | 882 {% endblock %} |
803 | 883 |
804 | 884 |
805 {##############################################################################} | 885 {##############################################################################} |
806 {% block install_conditional_methods %} | 886 {% block install_conditional_methods %} |
807 {% if conditionally_enabled_methods %} | 887 {% if is_v8object and conditionally_enabled_methods %} |
808 void {{v8_class}}::installConditionallyEnabledMethods(v8::Handle<v8::Object> pro totypeObject, v8::Isolate* isolate) | 888 void {{v8_class}}::installConditionallyEnabledMethods(v8::Handle<v8::Object> pro totypeObject, v8::Isolate* isolate) |
809 { | 889 { |
810 {# Define per-context enabled operations #} | 890 {# Define per-context enabled operations #} |
811 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate)); | 891 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate)); |
812 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext()); | 892 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext()); |
813 ASSERT(context); | 893 ASSERT(context); |
814 | 894 |
815 {% for method in conditionally_enabled_methods %} | 895 {% for method in conditionally_enabled_methods %} |
816 {% filter per_context_enabled(method.per_context_enabled_function) %} | 896 {% filter per_context_enabled(method.per_context_enabled_function) %} |
817 {% filter exposed(method.exposed_test) %} | 897 {% filter exposed(method.exposed_test) %} |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
960 {% endif %} | 1040 {% endif %} |
961 } | 1041 } |
962 | 1042 |
963 template<> | 1043 template<> |
964 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) | 1044 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) |
965 { | 1045 { |
966 return toV8(impl, creationContext, isolate); | 1046 return toV8(impl, creationContext, isolate); |
967 } | 1047 } |
968 | 1048 |
969 {% endblock %} | 1049 {% endblock %} |
OLD | NEW |