| 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 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 } | 735 } |
| 736 | 736 |
| 737 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) | 737 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) |
| 738 { | 738 { |
| 739 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 739 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 740 TestInterface* collection = V8TestInterface::toNative(info.Holder()); | 740 TestInterface* collection = V8TestInterface::toNative(info.Holder()); |
| 741 Vector<String> names; | 741 Vector<String> names; |
| 742 collection->namedPropertyEnumerator(names, exceptionState); | 742 collection->namedPropertyEnumerator(names, exceptionState); |
| 743 if (exceptionState.throwIfNeeded()) | 743 if (exceptionState.throwIfNeeded()) |
| 744 return; | 744 return; |
| 745 v8::Handle<v8::Array> v8names = v8::Array::New(names.size()); | 745 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size
()); |
| 746 for (size_t i = 0; i < names.size(); ++i) | 746 for (size_t i = 0; i < names.size(); ++i) |
| 747 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i],
info.GetIsolate())); | 747 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(names[i],
info.GetIsolate())); |
| 748 v8SetReturnValue(info, v8names); | 748 v8SetReturnValue(info, v8names); |
| 749 } | 749 } |
| 750 | 750 |
| 751 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) | 751 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) |
| 752 { | 752 { |
| 753 TestInterface* collection = V8TestInterface::toNative(info.Holder()); | 753 TestInterface* collection = V8TestInterface::toNative(info.Holder()); |
| 754 AtomicString propertyName = toWebCoreAtomicString(name); | 754 AtomicString propertyName = toWebCoreAtomicString(name); |
| 755 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 755 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 756 bool result = collection->namedPropertyQuery(propertyName, exceptionState); | 756 bool result = collection->namedPropertyQuery(propertyName, exceptionState); |
| 757 if (exceptionState.throwIfNeeded()) | 757 if (exceptionState.throwIfNeeded()) |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8
TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate); | 876 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8
TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate); |
| 877 COMPILE_ASSERT(1 == TestImplements::IMPLEMENTSCONSTANT1, TheValueOfTestInter
face_IMPLEMENTSCONSTANT1DoesntMatchWithImplementation); | 877 COMPILE_ASSERT(1 == TestImplements::IMPLEMENTSCONSTANT1, TheValueOfTestInter
face_IMPLEMENTSCONSTANT1DoesntMatchWithImplementation); |
| 878 COMPILE_ASSERT(2 == TestImplements::CONST_IMPL, TheValueOfTestInterface_CONS
T_IMPLDoesntMatchWithImplementation); | 878 COMPILE_ASSERT(2 == TestImplements::CONST_IMPL, TheValueOfTestInterface_CONS
T_IMPLDoesntMatchWithImplementation); |
| 879 COMPILE_ASSERT(1 == TestPartialInterface::SUPPLEMENTALCONSTANT1, TheValueOfT
estInterface_SUPPLEMENTALCONSTANT1DoesntMatchWithImplementation); | 879 COMPILE_ASSERT(1 == TestPartialInterface::SUPPLEMENTALCONSTANT1, TheValueOfT
estInterface_SUPPLEMENTALCONSTANT1DoesntMatchWithImplementation); |
| 880 COMPILE_ASSERT(2 == TestPartialInterface::CONST_IMPL, TheValueOfTestInterfac
e_CONST_IMPLDoesntMatchWithImplementation); | 880 COMPILE_ASSERT(2 == TestPartialInterface::CONST_IMPL, TheValueOfTestInterfac
e_CONST_IMPLDoesntMatchWithImplementation); |
| 881 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestInterfaceV
8Internal::namedPropertyGetterCallback, TestInterfaceV8Internal::namedPropertySe
tterCallback, TestInterfaceV8Internal::namedPropertyQueryCallback, 0, TestInterf
aceV8Internal::namedPropertyEnumeratorCallback); | 881 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestInterfaceV
8Internal::namedPropertyGetterCallback, TestInterfaceV8Internal::namedPropertySe
tterCallback, TestInterfaceV8Internal::namedPropertyQueryCallback, 0, TestInterf
aceV8Internal::namedPropertyEnumeratorCallback); |
| 882 | 882 |
| 883 // Custom Signature 'implementsMethod2' | 883 // Custom Signature 'implementsMethod2' |
| 884 const int implementsMethod2Argc = 2; | 884 const int implementsMethod2Argc = 2; |
| 885 v8::Handle<v8::FunctionTemplate> implementsMethod2Argv[implementsMethod2Argc
] = { v8::Handle<v8::FunctionTemplate>(), V8PerIsolateData::from(isolate)->rawTe
mplate(&V8TestObject::wrapperTypeInfo, currentWorldType) }; | 885 v8::Handle<v8::FunctionTemplate> implementsMethod2Argv[implementsMethod2Argc
] = { v8::Handle<v8::FunctionTemplate>(), V8PerIsolateData::from(isolate)->rawTe
mplate(&V8TestObject::wrapperTypeInfo, currentWorldType) }; |
| 886 v8::Handle<v8::Signature> implementsMethod2Signature = v8::Signature::New(fu
nctionTemplate, implementsMethod2Argc, implementsMethod2Argv); | 886 v8::Handle<v8::Signature> implementsMethod2Signature = v8::Signature::New(is
olate, functionTemplate, implementsMethod2Argc, implementsMethod2Argv); |
| 887 prototypeTemplate->Set(v8::String::NewSymbol("implementsMethod2"), v8::Funct
ionTemplate::New(TestInterfaceV8Internal::implementsMethod2MethodCallback, v8Und
efined(), implementsMethod2Signature, 2)); | 887 prototypeTemplate->Set(v8::String::NewFromUtf8(isolate, "implementsMethod2",
v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, TestInterf
aceV8Internal::implementsMethod2MethodCallback, v8Undefined(), implementsMethod2
Signature, 2)); |
| 888 functionTemplate->Set(v8::String::NewSymbol("implementsMethod4"), v8::Functi
onTemplate::New(TestInterfaceV8Internal::implementsMethod4MethodCallback, v8Unde
fined(), v8::Local<v8::Signature>(), 0)); | 888 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "implementsMethod4",
v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, TestInterfa
ceV8Internal::implementsMethod4MethodCallback, v8Undefined(), v8::Local<v8::Sign
ature>(), 0)); |
| 889 #if ENABLE(Condition11) || ENABLE(Condition12) | 889 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 890 | 890 |
| 891 // Custom Signature 'supplementalMethod2' | 891 // Custom Signature 'supplementalMethod2' |
| 892 const int supplementalMethod2Argc = 2; | 892 const int supplementalMethod2Argc = 2; |
| 893 v8::Handle<v8::FunctionTemplate> supplementalMethod2Argv[supplementalMethod2
Argc] = { v8::Handle<v8::FunctionTemplate>(), V8PerIsolateData::from(isolate)->r
awTemplate(&V8TestObject::wrapperTypeInfo, currentWorldType) }; | 893 v8::Handle<v8::FunctionTemplate> supplementalMethod2Argv[supplementalMethod2
Argc] = { v8::Handle<v8::FunctionTemplate>(), V8PerIsolateData::from(isolate)->r
awTemplate(&V8TestObject::wrapperTypeInfo, currentWorldType) }; |
| 894 v8::Handle<v8::Signature> supplementalMethod2Signature = v8::Signature::New(
functionTemplate, supplementalMethod2Argc, supplementalMethod2Argv); | 894 v8::Handle<v8::Signature> supplementalMethod2Signature = v8::Signature::New(
isolate, functionTemplate, supplementalMethod2Argc, supplementalMethod2Argv); |
| 895 prototypeTemplate->Set(v8::String::NewSymbol("supplementalMethod2"), v8::Fun
ctionTemplate::New(TestInterfaceV8Internal::supplementalMethod2MethodCallback, v
8Undefined(), supplementalMethod2Signature, 2)); | 895 prototypeTemplate->Set(v8::String::NewFromUtf8(isolate, "supplementalMethod2
", v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, TestInte
rfaceV8Internal::supplementalMethod2MethodCallback, v8Undefined(), supplementalM
ethod2Signature, 2)); |
| 896 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 896 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 897 #if ENABLE(Condition11) || ENABLE(Condition12) | 897 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 898 functionTemplate->Set(v8::String::NewSymbol("supplementalMethod4"), v8::Func
tionTemplate::New(TestInterfaceV8Internal::supplementalMethod4MethodCallback, v8
Undefined(), v8::Local<v8::Signature>(), 0)); | 898 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "supplementalMethod4"
, v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, TestInter
faceV8Internal::supplementalMethod4MethodCallback, v8Undefined(), v8::Local<v8::
Signature>(), 0)); |
| 899 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 899 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 900 functionTemplate->SetNativeDataProperty(v8::String::NewSymbol("implementsSta
ticReadOnlyAttr"), TestInterfaceV8Internal::implementsStaticReadOnlyAttrAttribut
eGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::PropertyAttri
bute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessCont
rol>(v8::DEFAULT)); | 900 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "im
plementsStaticReadOnlyAttr", v8::String::kInternalizedString), TestInterfaceV8In
ternal::implementsStaticReadOnlyAttrAttributeGetterCallback, 0, v8::External::Ne
w(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Acce
ssorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); |
| 901 functionTemplate->SetNativeDataProperty(v8::String::NewSymbol("implementsSta
ticAttr"), TestInterfaceV8Internal::implementsStaticAttrAttributeGetterCallback,
TestInterfaceV8Internal::implementsStaticAttrAttributeSetterCallback, v8::Exter
nal::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v
8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); | 901 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "im
plementsStaticAttr", v8::String::kInternalizedString), TestInterfaceV8Internal::
implementsStaticAttrAttributeGetterCallback, TestInterfaceV8Internal::implements
StaticAttrAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8
::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast
<v8::AccessControl>(v8::DEFAULT)); |
| 902 #if ENABLE(Condition11) || ENABLE(Condition12) | 902 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 903 functionTemplate->SetNativeDataProperty(v8::String::NewSymbol("supplementalS
taticReadOnlyAttr"), TestInterfaceV8Internal::supplementalStaticReadOnlyAttrAttr
ibuteGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::PropertyA
ttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::Access
Control>(v8::DEFAULT)); | 903 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "su
pplementalStaticReadOnlyAttr", v8::String::kInternalizedString), TestInterfaceV8
Internal::supplementalStaticReadOnlyAttrAttributeGetterCallback, 0, v8::External
::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::
AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); |
| 904 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 904 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 905 #if ENABLE(Condition11) || ENABLE(Condition12) | 905 #if ENABLE(Condition11) || ENABLE(Condition12) |
| 906 functionTemplate->SetNativeDataProperty(v8::String::NewSymbol("supplementalS
taticAttr"), TestInterfaceV8Internal::supplementalStaticAttrAttributeGetterCallb
ack, TestInterfaceV8Internal::supplementalStaticAttrAttributeSetterCallback, v8:
:External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Ha
ndle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); | 906 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "su
pplementalStaticAttr", v8::String::kInternalizedString), TestInterfaceV8Internal
::supplementalStaticAttrAttributeGetterCallback, TestInterfaceV8Internal::supple
mentalStaticAttrAttributeSetterCallback, v8::External::New(isolate, 0), static_c
ast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), stati
c_cast<v8::AccessControl>(v8::DEFAULT)); |
| 907 #endif // ENABLE(Condition11) || ENABLE(Condition12) | 907 #endif // ENABLE(Condition11) || ENABLE(Condition12) |
| 908 | 908 |
| 909 // Custom toString template | 909 // Custom toString template |
| 910 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c
urrent()->toStringTemplate()); | 910 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); |
| 911 return functionTemplate; | 911 return functionTemplate; |
| 912 } | 912 } |
| 913 | 913 |
| 914 v8::Handle<v8::FunctionTemplate> V8TestInterface::GetTemplate(v8::Isolate* isola
te, WrapperWorldType currentWorldType) | 914 v8::Handle<v8::FunctionTemplate> V8TestInterface::GetTemplate(v8::Isolate* isola
te, WrapperWorldType currentWorldType) |
| 915 { | 915 { |
| 916 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 916 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 917 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 917 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); |
| 918 if (result != data->templateMap(currentWorldType).end()) | 918 if (result != data->templateMap(currentWorldType).end()) |
| 919 return result->value.newLocal(isolate); | 919 return result->value.newLocal(isolate); |
| 920 | 920 |
| 921 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 921 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 922 v8::HandleScope handleScope(isolate); | 922 v8::EscapableHandleScope handleScope(isolate); |
| 923 v8::Handle<v8::FunctionTemplate> templ = | 923 v8::Local<v8::FunctionTemplate> templ = |
| 924 ConfigureV8TestInterfaceTemplate(data->rawTemplate(&wrapperTypeInfo, cur
rentWorldType), isolate, currentWorldType); | 924 ConfigureV8TestInterfaceTemplate(data->rawTemplate(&wrapperTypeInfo, cur
rentWorldType), isolate, currentWorldType); |
| 925 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 925 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 926 return handleScope.Close(templ); | 926 return handleScope.Escape(templ); |
| 927 } | 927 } |
| 928 | 928 |
| 929 bool V8TestInterface::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* is
olate, WrapperWorldType currentWorldType) | 929 bool V8TestInterface::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* is
olate, WrapperWorldType currentWorldType) |
| 930 { | 930 { |
| 931 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | 931 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); |
| 932 } | 932 } |
| 933 | 933 |
| 934 bool V8TestInterface::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::I
solate* isolate) | 934 bool V8TestInterface::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::I
solate* isolate) |
| 935 { | 935 { |
| 936 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, MainWorld) | 936 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, MainWorld) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 } | 989 } |
| 990 | 990 |
| 991 template<> | 991 template<> |
| 992 v8::Handle<v8::Value> toV8NoInline(TestInterface* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) | 992 v8::Handle<v8::Value> toV8NoInline(TestInterface* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) |
| 993 { | 993 { |
| 994 return toV8(impl, creationContext, isolate); | 994 return toV8(impl, creationContext, isolate); |
| 995 } | 995 } |
| 996 | 996 |
| 997 } // namespace WebCore | 997 } // namespace WebCore |
| 998 #endif // ENABLE(Condition1) || ENABLE(Condition2) | 998 #endif // ENABLE(Condition1) || ENABLE(Condition2) |
| OLD | NEW |