OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 } | 781 } |
782 | 782 |
783 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { | 783 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { |
784 v8SetReturnValue(info, info.Holder()); | 784 v8SetReturnValue(info, info.Holder()); |
785 return; | 785 return; |
786 } | 786 } |
787 | 787 |
788 TestInterfaceV8Internal::constructor(info); | 788 TestInterfaceV8Internal::constructor(info); |
789 } | 789 } |
790 | 790 |
791 static void configureV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> fu
nctionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType) | 791 static void configureV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> fu
nctionTemplate, v8::Isolate* isolate) |
792 { | 792 { |
793 functionTemplate->ReadOnlyPrototype(); | 793 functionTemplate->ReadOnlyPrototype(); |
794 | 794 |
795 v8::Local<v8::Signature> defaultSignature; | 795 v8::Local<v8::Signature> defaultSignature; |
796 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterface", v8::Local<v8::FunctionTemplate>(), V8TestInterface::intern
alFieldCount, | 796 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterface", v8::Local<v8::FunctionTemplate>(), V8TestInterface::intern
alFieldCount, |
797 V8TestInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceAttributes), | 797 V8TestInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceAttributes), |
798 0, 0, | 798 0, 0, |
799 V8TestInterfaceMethods, WTF_ARRAY_LENGTH(V8TestInterfaceMethods), | 799 V8TestInterfaceMethods, WTF_ARRAY_LENGTH(V8TestInterfaceMethods), |
800 isolate, currentWorldType); | 800 isolate); |
801 functionTemplate->SetCallHandler(V8TestInterface::constructorCallback); | 801 functionTemplate->SetCallHandler(V8TestInterface::constructorCallback); |
802 functionTemplate->SetLength(1); | 802 functionTemplate->SetLength(1); |
803 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 803 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
804 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 804 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
805 if (RuntimeEnabledFeatures::implementsFeatureNameEnabled()) { | 805 if (RuntimeEnabledFeatures::implementsFeatureNameEnabled()) { |
806 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu
ration =\ | 806 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu
ration =\ |
807 {"implementsRuntimeEnabledNodeAttribute", TestInterfaceV8Internal::imple
mentsRuntimeEnabledNodeAttributeAttributeGetterCallback, TestInterfaceV8Internal
::implementsRuntimeEnabledNodeAttributeAttributeSetterCallback, 0, 0, 0, static_
cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::Non
e), 0 /* on instance */}; | 807 {"implementsRuntimeEnabledNodeAttribute", TestInterfaceV8Internal::imple
mentsRuntimeEnabledNodeAttributeAttributeGetterCallback, TestInterfaceV8Internal
::implementsRuntimeEnabledNodeAttributeAttributeSetterCallback, 0, 0, 0, static_
cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::Non
e), 0 /* on instance */}; |
808 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate
, attributeConfiguration, isolate, currentWorldType); | 808 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate
, attributeConfiguration, isolate); |
809 } | 809 } |
810 #if ENABLE(CONDITION_PARTIAL) | 810 #if ENABLE(CONDITION_PARTIAL) |
811 if (RuntimeEnabledFeatures::condition13Enabled()) { | 811 if (RuntimeEnabledFeatures::condition13Enabled()) { |
812 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu
ration =\ | 812 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu
ration =\ |
813 {"Node13", TestInterfaceV8Internal::Node13AttributeGetterCallback, TestI
nterfaceV8Internal::Node13AttributeSetterCallback, 0, 0, 0, static_cast<v8::Acce
ssControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on i
nstance */}; | 813 {"Node13", TestInterfaceV8Internal::Node13AttributeGetterCallback, TestI
nterfaceV8Internal::Node13AttributeSetterCallback, 0, 0, 0, static_cast<v8::Acce
ssControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on i
nstance */}; |
814 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate
, attributeConfiguration, isolate, currentWorldType); | 814 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate
, attributeConfiguration, isolate); |
815 } | 815 } |
816 #endif // ENABLE(CONDITION_PARTIAL) | 816 #endif // ENABLE(CONDITION_PARTIAL) |
817 static const V8DOMConfiguration::ConstantConfiguration V8TestInterfaceConsta
nts[] = { | 817 static const V8DOMConfiguration::ConstantConfiguration V8TestInterfaceConsta
nts[] = { |
818 {"IMPLEMENTS_CONSTANT_1", 1}, | 818 {"IMPLEMENTS_CONSTANT_1", 1}, |
819 {"IMPLEMENTS_CONSTANT_2", 2}, | 819 {"IMPLEMENTS_CONSTANT_2", 2}, |
820 {"SUPPLEMENTALCONSTANT1", 1}, | 820 {"SUPPLEMENTALCONSTANT1", 1}, |
821 {"SUPPLEMENTALCONSTANT2", 2}, | 821 {"SUPPLEMENTALCONSTANT2", 2}, |
822 }; | 822 }; |
823 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8
TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate); | 823 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8
TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate); |
824 COMPILE_ASSERT(1 == TestImplements::IMPLEMENTS_CONSTANT_1, TheValueOfTestInt
erface_IMPLEMENTS_CONSTANT_1DoesntMatchWithImplementation); | 824 COMPILE_ASSERT(1 == TestImplements::IMPLEMENTS_CONSTANT_1, TheValueOfTestInt
erface_IMPLEMENTS_CONSTANT_1DoesntMatchWithImplementation); |
(...skipping 11 matching lines...) Expand all Loading... |
836 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "supplementa
lStaticReadOnlyAttr"), TestInterfaceV8Internal::supplementalStaticReadOnlyAttrAt
tributeGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::Propert
yAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::Acce
ssControl>(v8::DEFAULT)); | 836 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "supplementa
lStaticReadOnlyAttr"), TestInterfaceV8Internal::supplementalStaticReadOnlyAttrAt
tributeGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::Propert
yAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::Acce
ssControl>(v8::DEFAULT)); |
837 #endif // ENABLE(CONDITION_PARTIAL) | 837 #endif // ENABLE(CONDITION_PARTIAL) |
838 #if ENABLE(CONDITION_PARTIAL) | 838 #if ENABLE(CONDITION_PARTIAL) |
839 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "supplementa
lStaticAttr"), TestInterfaceV8Internal::supplementalStaticAttrAttributeGetterCal
lback, TestInterfaceV8Internal::supplementalStaticAttrAttributeSetterCallback, v
8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::
Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); | 839 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "supplementa
lStaticAttr"), TestInterfaceV8Internal::supplementalStaticAttrAttributeGetterCal
lback, TestInterfaceV8Internal::supplementalStaticAttrAttributeSetterCallback, v
8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::
Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); |
840 #endif // ENABLE(CONDITION_PARTIAL) | 840 #endif // ENABLE(CONDITION_PARTIAL) |
841 | 841 |
842 // Custom toString template | 842 // Custom toString template |
843 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | 843 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); |
844 } | 844 } |
845 | 845 |
846 v8::Handle<v8::FunctionTemplate> V8TestInterface::domTemplate(v8::Isolate* isola
te, WrapperWorldType currentWorldType) | 846 v8::Handle<v8::FunctionTemplate> V8TestInterface::domTemplate(v8::Isolate* isola
te) |
847 { | 847 { |
848 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 848 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
849 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 849 V8PerIsolateData::TemplateMap::iterator result = data->templateMap().find(&w
rapperTypeInfo); |
850 if (result != data->templateMap(currentWorldType).end()) | 850 if (result != data->templateMap().end()) |
851 return result->value.newLocal(isolate); | 851 return result->value.newLocal(isolate); |
852 | 852 |
853 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 853 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
854 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); | 854 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
855 configureV8TestInterfaceTemplate(templ, isolate, currentWorldType); | 855 configureV8TestInterfaceTemplate(templ, isolate); |
856 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 856 data->templateMap().add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTempl
ate>(isolate, templ)); |
857 return templ; | 857 return templ; |
858 } | 858 } |
859 | 859 |
860 bool V8TestInterface::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* is
olate) | 860 bool V8TestInterface::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* is
olate) |
861 { | 861 { |
862 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); | 862 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); |
863 } | 863 } |
864 | 864 |
865 v8::Handle<v8::Object> V8TestInterface::findInstanceInPrototypeChain(v8::Handle<
v8::Value> jsValue, v8::Isolate* isolate) | 865 v8::Handle<v8::Object> V8TestInterface::findInstanceInPrototypeChain(v8::Handle<
v8::Value> jsValue, v8::Isolate* isolate) |
866 { | 866 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 } | 913 } |
914 | 914 |
915 template<> | 915 template<> |
916 v8::Handle<v8::Value> toV8NoInline(TestInterface* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) | 916 v8::Handle<v8::Value> toV8NoInline(TestInterface* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) |
917 { | 917 { |
918 return toV8(impl, creationContext, isolate); | 918 return toV8(impl, creationContext, isolate); |
919 } | 919 } |
920 | 920 |
921 } // namespace WebCore | 921 } // namespace WebCore |
922 #endif // ENABLE(Condition1) || ENABLE(Condition2) | 922 #endif // ENABLE(Condition1) || ENABLE(Condition2) |
OLD | NEW |