OLD | NEW |
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 return; | 415 return; |
416 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); | 416 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); |
417 v8::String::Utf8Value attributeName(name); | 417 v8::String::Utf8Value attributeName(name); |
418 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"{{interface_name}}", info.Holder(), info.GetIsolate()); | 418 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName,
"{{interface_name}}", info.Holder(), info.GetIsolate()); |
419 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 419 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
420 exceptionState.throwIfNeeded(); | 420 exceptionState.throwIfNeeded(); |
421 return; | 421 return; |
422 } | 422 } |
423 | 423 |
424 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha
ndle if info.This() is an Object. #} | 424 {# The findInstanceInPrototypeChain() call above only returns a non-empty ha
ndle if info.This() is an Object. #} |
425 V8HiddenValue::setHiddenValue(info.GetIsolate(), v8::Handle<v8::Object>::Cas
t(info.This()), name, v8Value); | 425 V8HiddenValue::setHiddenValue(info.GetIsolate(), v8::Local<v8::Object>::Cast
(info.This()), name, v8Value); |
426 } | 426 } |
427 | 427 |
428 static void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::String> na
me, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) | 428 static void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::String> na
me, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
429 { | 429 { |
430 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); | 430 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); |
431 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value,
info); | 431 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value,
info); |
432 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 432 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
433 } | 433 } |
434 | 434 |
435 {% endif %} | 435 {% endif %} |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 {% endif %} | 682 {% endif %} |
683 } | 683 } |
684 | 684 |
685 {% endif %} | 685 {% endif %} |
686 {% endblock %} | 686 {% endblock %} |
687 | 687 |
688 | 688 |
689 {##############################################################################} | 689 {##############################################################################} |
690 {% block configure_shadow_object_template %} | 690 {% block configure_shadow_object_template %} |
691 {% if interface_name == 'Window' %} | 691 {% if interface_name == 'Window' %} |
692 static void configureShadowObjectTemplate(v8::Handle<v8::ObjectTemplate> templ,
v8::Isolate* isolate) | 692 static void configureShadowObjectTemplate(v8::Local<v8::ObjectTemplate> templ, v
8::Isolate* isolate) |
693 { | 693 { |
694 V8DOMConfiguration::installAttributes(isolate, templ, v8::Handle<v8::ObjectT
emplate>(), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes)); | 694 V8DOMConfiguration::installAttributes(isolate, templ, v8::Local<v8::ObjectTe
mplate>(), shadowAttributes, WTF_ARRAY_LENGTH(shadowAttributes)); |
695 | 695 |
696 // Install a security handler with V8. | 696 // Install a security handler with V8. |
697 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window:
:indexedSecurityCheckCustom, v8::External::New(isolate, const_cast<WrapperTypeIn
fo*>(&V8Window::wrapperTypeInfo))); | 697 templ->SetAccessCheckCallbacks(V8Window::namedSecurityCheckCustom, V8Window:
:indexedSecurityCheckCustom, v8::External::New(isolate, const_cast<WrapperTypeIn
fo*>(&V8Window::wrapperTypeInfo))); |
698 templ->SetInternalFieldCount(V8Window::internalFieldCount); | 698 templ->SetInternalFieldCount(V8Window::internalFieldCount); |
699 } | 699 } |
700 | 700 |
701 {% endif %} | 701 {% endif %} |
702 {% endblock %} | 702 {% endblock %} |
703 | 703 |
704 | 704 |
(...skipping 17 matching lines...) Expand all Loading... |
722 {% set getter_callback_for_main_world = '0' %} | 722 {% set getter_callback_for_main_world = '0' %} |
723 {% set setter_callback_for_main_world = '0' %} | 723 {% set setter_callback_for_main_world = '0' %} |
724 {% endif %} | 724 {% endif %} |
725 {% set property_attribute = | 725 {% set property_attribute = |
726 'static_cast<v8::PropertyAttribute>(%s)' % | 726 'static_cast<v8::PropertyAttribute>(%s)' % |
727 ' | '.join(method.property_attributes or ['v8::DontDelete']) %} | 727 ' | '.join(method.property_attributes or ['v8::DontDelete']) %} |
728 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 728 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
729 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf
eAttributeConfiguration = { | 729 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf
eAttributeConfiguration = { |
730 "{{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, | 730 "{{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, |
731 }; | 731 }; |
732 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8
::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate); | 732 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Local<v8:
:ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate); |
733 {%- endmacro %} | 733 {%- endmacro %} |
734 | 734 |
735 | 735 |
736 {##############################################################################} | 736 {##############################################################################} |
737 {% block get_dom_template %} | 737 {% block get_dom_template %} |
738 {% if not is_array_buffer_or_view %} | 738 {% if not is_array_buffer_or_view %} |
739 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate) | 739 v8::Local<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate) |
740 { | 740 { |
741 {% if has_partial_interface %} | 741 {% if has_partial_interface %} |
742 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class
, v8_class) %} | 742 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class
, v8_class) %} |
743 ASSERT({{installTemplateFunction}} != {{v8_class}}::install{{v8_class}}Templ
ate); | 743 ASSERT({{installTemplateFunction}} != {{v8_class}}::install{{v8_class}}Templ
ate); |
744 {% else %} | 744 {% else %} |
745 {% set installTemplateFunction = 'install%sTemplate' % v8_class %} | 745 {% set installTemplateFunction = 'install%sTemplate' % v8_class %} |
746 {% endif %} | 746 {% endif %} |
747 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class, v8
_class) if has_partial_interface else 'install%sTemplate' % v8_class %} | 747 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class, v8
_class) if has_partial_interface else 'install%sTemplate' % v8_class %} |
748 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI
nfo*>(&wrapperTypeInfo), {{installTemplateFunction}}); | 748 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI
nfo*>(&wrapperTypeInfo), {{installTemplateFunction}}); |
749 } | 749 } |
750 | 750 |
751 {% endif %} | 751 {% endif %} |
752 {% endblock %} | 752 {% endblock %} |
753 | 753 |
754 | 754 |
755 {##############################################################################} | 755 {##############################################################################} |
756 {% block has_instance %} | 756 {% block has_instance %} |
757 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isola
te) | 757 bool {{v8_class}}::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolat
e) |
758 { | 758 { |
759 {% if is_array_buffer_or_view %} | 759 {% if is_array_buffer_or_view %} |
760 return v8Value->Is{{interface_name}}(); | 760 return v8Value->Is{{interface_name}}(); |
761 {% else %} | 761 {% else %} |
762 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); | 762 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); |
763 {% endif %} | 763 {% endif %} |
764 } | 764 } |
765 | 765 |
766 {% if not is_array_buffer_or_view %} | 766 {% if not is_array_buffer_or_view %} |
767 v8::Handle<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Handle<v8:
:Value> v8Value, v8::Isolate* isolate) | 767 v8::Local<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Local<v8::V
alue> v8Value, v8::Isolate* isolate) |
768 { | 768 { |
769 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | 769 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); |
770 } | 770 } |
771 | 771 |
772 {% endif %} | 772 {% endif %} |
773 {% endblock %} | 773 {% endblock %} |
774 | 774 |
775 | 775 |
776 {##############################################################################} | 776 {##############################################################################} |
777 {% block to_impl %} | 777 {% block to_impl %} |
778 {% if interface_name == 'ArrayBuffer' %} | 778 {% if interface_name == 'ArrayBuffer' %} |
779 {{cpp_class}}* V8ArrayBuffer::toImpl(v8::Handle<v8::Object> object) | 779 {{cpp_class}}* V8ArrayBuffer::toImpl(v8::Local<v8::Object> object) |
780 { | 780 { |
781 ASSERT(object->IsArrayBuffer()); | 781 ASSERT(object->IsArrayBuffer()); |
782 v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>(); | 782 v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>(); |
783 if (v8buffer->IsExternal()) { | 783 if (v8buffer->IsExternal()) { |
784 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); | 784 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); |
785 RELEASE_ASSERT(wrapperTypeInfo); | 785 RELEASE_ASSERT(wrapperTypeInfo); |
786 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); | 786 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); |
787 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); | 787 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); |
788 } | 788 } |
789 | 789 |
790 // Transfer the ownership of the allocated memory to an ArrayBuffer without | 790 // Transfer the ownership of the allocated memory to an ArrayBuffer without |
791 // copying. | 791 // copying. |
792 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); | 792 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); |
793 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, 0); | 793 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, 0); |
794 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents); | 794 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents); |
795 // Since this transfer doesn't allocate new memory, do not call | 795 // Since this transfer doesn't allocate new memory, do not call |
796 // DOMArrayBufferDeallocationObserver::blinkAllocatedMemory. | 796 // DOMArrayBufferDeallocationObserver::blinkAllocatedMemory. |
797 buffer->buffer()->setDeallocationObserverWithoutAllocationNotification( | 797 buffer->buffer()->setDeallocationObserverWithoutAllocationNotification( |
798 DOMArrayBufferDeallocationObserver::instance()); | 798 DOMArrayBufferDeallocationObserver::instance()); |
799 buffer->associateWithWrapper(v8::Isolate::GetCurrent(), buffer->wrapperTypeI
nfo(), object); | 799 buffer->associateWithWrapper(v8::Isolate::GetCurrent(), buffer->wrapperTypeI
nfo(), object); |
800 | 800 |
801 return buffer.get(); | 801 return buffer.get(); |
802 } | 802 } |
803 | 803 |
804 {% elif interface_name == 'ArrayBufferView' %} | 804 {% elif interface_name == 'ArrayBufferView' %} |
805 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Handle<v8::Object> object) | 805 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) |
806 { | 806 { |
807 ASSERT(object->IsArrayBufferView()); | 807 ASSERT(object->IsArrayBufferView()); |
808 ScriptWrappable* scriptWrappable = toScriptWrappable(object); | 808 ScriptWrappable* scriptWrappable = toScriptWrappable(object); |
809 if (scriptWrappable) | 809 if (scriptWrappable) |
810 return scriptWrappable->toImpl<{{cpp_class}}>(); | 810 return scriptWrappable->toImpl<{{cpp_class}}>(); |
811 | 811 |
812 if (object->IsInt8Array()) | 812 if (object->IsInt8Array()) |
813 return V8Int8Array::toImpl(object); | 813 return V8Int8Array::toImpl(object); |
814 if (object->IsInt16Array()) | 814 if (object->IsInt16Array()) |
815 return V8Int16Array::toImpl(object); | 815 return V8Int16Array::toImpl(object); |
(...skipping 12 matching lines...) Expand all Loading... |
828 if (object->IsFloat64Array()) | 828 if (object->IsFloat64Array()) |
829 return V8Float64Array::toImpl(object); | 829 return V8Float64Array::toImpl(object); |
830 if (object->IsDataView()) | 830 if (object->IsDataView()) |
831 return V8DataView::toImpl(object); | 831 return V8DataView::toImpl(object); |
832 | 832 |
833 ASSERT_NOT_REACHED(); | 833 ASSERT_NOT_REACHED(); |
834 return 0; | 834 return 0; |
835 } | 835 } |
836 | 836 |
837 {% elif is_array_buffer_or_view %} | 837 {% elif is_array_buffer_or_view %} |
838 {{cpp_class}}* {{v8_class}}::toImpl(v8::Handle<v8::Object> object) | 838 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) |
839 { | 839 { |
840 ASSERT(object->Is{{interface_name}}()); | 840 ASSERT(object->Is{{interface_name}}()); |
841 ScriptWrappable* scriptWrappable = toScriptWrappable(object); | 841 ScriptWrappable* scriptWrappable = toScriptWrappable(object); |
842 if (scriptWrappable) | 842 if (scriptWrappable) |
843 return scriptWrappable->toImpl<{{cpp_class}}>(); | 843 return scriptWrappable->toImpl<{{cpp_class}}>(); |
844 | 844 |
845 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>
(); | 845 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>
(); |
846 RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toIm
pl(v8View->Buffer()), v8View->ByteOffset(), v8View->{% if interface_name == 'Dat
aView' %}Byte{% endif %}Length()); | 846 RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toIm
pl(v8View->Buffer()), v8View->ByteOffset(), v8View->{% if interface_name == 'Dat
aView' %}Byte{% endif %}Length()); |
847 typedArray->associateWithWrapper(v8::Isolate::GetCurrent(), typedArray->wrap
perTypeInfo(), object); | 847 typedArray->associateWithWrapper(v8::Isolate::GetCurrent(), typedArray->wrap
perTypeInfo(), object); |
848 | 848 |
849 return typedArray->toImpl<{{cpp_class}}>(); | 849 return typedArray->toImpl<{{cpp_class}}>(); |
850 } | 850 } |
851 | 851 |
852 {% endif %} | 852 {% endif %} |
853 {% endblock %} | 853 {% endblock %} |
854 | 854 |
855 | 855 |
856 {##############################################################################} | 856 {##############################################################################} |
857 {% block to_impl_with_type_check %} | 857 {% block to_impl_with_type_check %} |
858 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl
e<v8::Value> value) | 858 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local
<v8::Value> value) |
859 { | 859 { |
860 return hasInstance(value, isolate) ? toImpl(v8::Handle<v8::Object>::Cast(val
ue)) : 0; | 860 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(valu
e)) : 0; |
861 } | 861 } |
862 | 862 |
863 {% endblock %} | 863 {% endblock %} |
864 | 864 |
865 | 865 |
866 {##############################################################################} | 866 {##############################################################################} |
867 {% block install_conditional_attributes %} | 867 {% block install_conditional_attributes %} |
868 {% from 'attributes.cpp' import attribute_configuration with context %} | 868 {% from 'attributes.cpp' import attribute_configuration with context %} |
869 {% if has_conditional_attributes %} | 869 {% if has_conditional_attributes %} |
870 void {{v8_class}}::installConditionallyEnabledProperties(v8::Local<v8::Object> i
nstanceObject, v8::Isolate* isolate) | 870 void {{v8_class}}::installConditionallyEnabledProperties(v8::Local<v8::Object> i
nstanceObject, v8::Isolate* isolate) |
(...skipping 12 matching lines...) Expand all Loading... |
883 {% endfor %} | 883 {% endfor %} |
884 } | 884 } |
885 | 885 |
886 {% endif %} | 886 {% endif %} |
887 {% endblock %} | 887 {% endblock %} |
888 | 888 |
889 | 889 |
890 {##############################################################################} | 890 {##############################################################################} |
891 {% block to_active_dom_object %} | 891 {% block to_active_dom_object %} |
892 {% if is_active_dom_object %} | 892 {% if is_active_dom_object %} |
893 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper) | 893 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Local<v8::Object> wrapper) |
894 { | 894 { |
895 return toImpl(wrapper); | 895 return toImpl(wrapper); |
896 } | 896 } |
897 | 897 |
898 {% endif %} | 898 {% endif %} |
899 {% endblock %} | 899 {% endblock %} |
900 | 900 |
901 | 901 |
902 {##############################################################################} | 902 {##############################################################################} |
903 {% block get_shadow_object_template %} | 903 {% block get_shadow_object_template %} |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 } | 970 } |
971 | 971 |
972 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} | 972 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} |
973 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) | 973 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) |
974 { | 974 { |
975 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | 975 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
976 } | 976 } |
977 {% endfor %} | 977 {% endfor %} |
978 {% endif %} | 978 {% endif %} |
979 {% endblock %} | 979 {% endblock %} |
OLD | NEW |