| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re
lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(
), WrapperConfiguration::Dependent); | 85 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re
lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(
), WrapperConfiguration::Dependent); |
| 86 v8SetReturnValue(info, wrapper); | 86 v8SetReturnValue(info, wrapper); |
| 87 } | 87 } |
| 88 | 88 |
| 89 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) | 89 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 90 { | 90 { |
| 91 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor", info.Holder(), info.GetIsolate()); | 91 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor", info.Holder(), info.GetIsolate()); |
| 92 V8TRYCATCH_VOID(double, doubleArg, static_cast<double>(info[0]->NumberValue(
))); | 92 V8TRYCATCH_VOID(double, doubleArg, static_cast<double>(info[0]->NumberValue(
))); |
| 93 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[1])
; | 93 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[1])
; |
| 94 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE
mpty::hasInstance(info[2], info.GetIsolate(), worldType(info.GetIsolate())) ? V8
TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[2])) : 0); | 94 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE
mpty::hasInstance(info[2], info.GetIsolate()) ? V8TestInterfaceEmpty::toNative(v
8::Handle<v8::Object>::Cast(info[2])) : 0); |
| 95 V8TRYCATCH_VOID(Dictionary, dictionaryArg, Dictionary(info[3], info.GetIsola
te())); | 95 V8TRYCATCH_VOID(Dictionary, dictionaryArg, Dictionary(info[3], info.GetIsola
te())); |
| 96 if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) { | 96 if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) { |
| 97 exceptionState.throwTypeError("parameter 4 ('dictionaryArg') is not an o
bject."); | 97 exceptionState.throwTypeError("parameter 4 ('dictionaryArg') is not an o
bject."); |
| 98 exceptionState.throwIfNeeded(); | 98 exceptionState.throwIfNeeded(); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 V8TRYCATCH_VOID(Vector<String>, sequenceStringArg, toNativeArray<String>(inf
o[4], 5, info.GetIsolate())); | 101 V8TRYCATCH_VOID(Vector<String>, sequenceStringArg, toNativeArray<String>(inf
o[4], 5, info.GetIsolate())); |
| 102 V8TRYCATCH_VOID(Dictionary, optionalDictionaryArg, Dictionary(info[5], info.
GetIsolate())); | 102 V8TRYCATCH_VOID(Dictionary, optionalDictionaryArg, Dictionary(info[5], info.
GetIsolate())); |
| 103 if (!optionalDictionaryArg.isUndefinedOrNull() && !optionalDictionaryArg.isO
bject()) { | 103 if (!optionalDictionaryArg.isUndefinedOrNull() && !optionalDictionaryArg.isO
bject()) { |
| 104 exceptionState.throwTypeError("parameter 6 ('optionalDictionaryArg') is
not an object."); | 104 exceptionState.throwTypeError("parameter 6 ('optionalDictionaryArg') is
not an object."); |
| 105 exceptionState.throwIfNeeded(); | 105 exceptionState.throwIfNeeded(); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 V8TRYCATCH_VOID(TestInterfaceEmpty*, optionalTestInterfaceEmptyArg, V8TestIn
terfaceEmpty::hasInstance(info[6], info.GetIsolate(), worldType(info.GetIsolate(
))) ? V8TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[6])) : 0)
; | 108 V8TRYCATCH_VOID(TestInterfaceEmpty*, optionalTestInterfaceEmptyArg, V8TestIn
terfaceEmpty::hasInstance(info[6], info.GetIsolate()) ? V8TestInterfaceEmpty::to
Native(v8::Handle<v8::Object>::Cast(info[6])) : 0); |
| 109 ExecutionContext* context = getExecutionContext(); | 109 ExecutionContext* context = getExecutionContext(); |
| 110 Document& document = *toDocument(getExecutionContext()); | 110 Document& document = *toDocument(getExecutionContext()); |
| 111 RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(con
text, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequ
enceStringArg, optionalDictionaryArg, optionalTestInterfaceEmptyArg, exceptionSt
ate); | 111 RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(con
text, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequ
enceStringArg, optionalDictionaryArg, optionalTestInterfaceEmptyArg, exceptionSt
ate); |
| 112 v8::Handle<v8::Object> wrapper = info.Holder(); | 112 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 113 if (exceptionState.throwIfNeeded()) | 113 if (exceptionState.throwIfNeeded()) |
| 114 return; | 114 return; |
| 115 | 115 |
| 116 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re
lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(
), WrapperConfiguration::Dependent); | 116 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re
lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(
), WrapperConfiguration::Dependent); |
| 117 v8SetReturnValue(info, wrapper); | 117 v8SetReturnValue(info, wrapper); |
| 118 } | 118 } |
| 119 | 119 |
| 120 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | 120 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 121 { | 121 { |
| 122 if (((info.Length() == 0))) { | 122 if (((info.Length() == 0))) { |
| 123 TestInterfaceConstructorV8Internal::constructor1(info); | 123 TestInterfaceConstructorV8Internal::constructor1(info); |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 if (((info.Length() == 5) && (V8TestInterfaceEmpty::hasInstance(info[2], inf
o.GetIsolate(), worldType(info.GetIsolate()))) && (info[3]->IsObject()) && (info
[4]->IsArray())) || ((info.Length() == 6) && (V8TestInterfaceEmpty::hasInstance(
info[2], info.GetIsolate(), worldType(info.GetIsolate()))) && (info[3]->IsObject
()) && (info[4]->IsArray()) && (info[5]->IsObject())) || ((info.Length() == 7) &
& (V8TestInterfaceEmpty::hasInstance(info[2], info.GetIsolate(), worldType(info.
GetIsolate()))) && (info[3]->IsObject()) && (info[4]->IsArray()) && (info[5]->Is
Object()) && (V8TestInterfaceEmpty::hasInstance(info[6], info.GetIsolate(), worl
dType(info.GetIsolate()))))) { | 126 if (((info.Length() == 5) && (V8TestInterfaceEmpty::hasInstance(info[2], inf
o.GetIsolate())) && (info[3]->IsObject()) && (info[4]->IsArray())) || ((info.Len
gth() == 6) && (V8TestInterfaceEmpty::hasInstance(info[2], info.GetIsolate())) &
& (info[3]->IsObject()) && (info[4]->IsArray()) && (info[5]->IsObject())) || ((i
nfo.Length() == 7) && (V8TestInterfaceEmpty::hasInstance(info[2], info.GetIsolat
e())) && (info[3]->IsObject()) && (info[4]->IsArray()) && (info[5]->IsObject())
&& (V8TestInterfaceEmpty::hasInstance(info[6], info.GetIsolate())))) { |
| 127 TestInterfaceConstructorV8Internal::constructor2(info); | 127 TestInterfaceConstructorV8Internal::constructor2(info); |
| 128 return; | 128 return; |
| 129 } | 129 } |
| 130 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstructo
r", "No matching constructor signature."), info.GetIsolate()); | 130 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstructo
r", "No matching constructor signature."), info.GetIsolate()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace TestInterfaceConstructorV8Internal | 133 } // namespace TestInterfaceConstructorV8Internal |
| 134 | 134 |
| 135 void V8TestInterfaceConstructor::constructorCallback(const v8::FunctionCallbackI
nfo<v8::Value>& info) | 135 void V8TestInterfaceConstructor::constructorCallback(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 136 { | 136 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return result->value.newLocal(isolate); | 176 return result->value.newLocal(isolate); |
| 177 | 177 |
| 178 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 178 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 179 v8::EscapableHandleScope handleScope(isolate); | 179 v8::EscapableHandleScope handleScope(isolate); |
| 180 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); | 180 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
| 181 configureV8TestInterfaceConstructorTemplate(templ, isolate, currentWorldType
); | 181 configureV8TestInterfaceConstructorTemplate(templ, isolate, currentWorldType
); |
| 182 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 182 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 183 return handleScope.Escape(templ); | 183 return handleScope.Escape(templ); |
| 184 } | 184 } |
| 185 | 185 |
| 186 bool V8TestInterfaceConstructor::hasInstance(v8::Handle<v8::Value> jsValue, v8::
Isolate* isolate, WrapperWorldType currentWorldType) | 186 bool V8TestInterfaceConstructor::hasInstance(v8::Handle<v8::Value> jsValue, v8::
Isolate* isolate) |
| 187 { | 187 { |
| 188 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | 188 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) |
| 189 } | 189 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); |
| 190 | |
| 191 bool V8TestInterfaceConstructor::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsV
alue, v8::Isolate* isolate) | |
| 192 { | |
| 193 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, MainWorld) | |
| 194 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, IsolatedWorld) | |
| 195 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, WorkerWorld); | |
| 196 } | 190 } |
| 197 | 191 |
| 198 v8::Handle<v8::Object> V8TestInterfaceConstructor::createWrapper(PassRefPtr<Test
InterfaceConstructor> impl, v8::Handle<v8::Object> creationContext, v8::Isolate*
isolate) | 192 v8::Handle<v8::Object> V8TestInterfaceConstructor::createWrapper(PassRefPtr<Test
InterfaceConstructor> impl, v8::Handle<v8::Object> creationContext, v8::Isolate*
isolate) |
| 199 { | 193 { |
| 200 ASSERT(impl); | 194 ASSERT(impl); |
| 201 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor>(impl.get()
, isolate)); | 195 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor>(impl.get()
, isolate)); |
| 202 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 196 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
| 203 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | 197 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); |
| 204 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | 198 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have |
| 205 // the same object de-ref functions, though, so use that as the basis of
the check. | 199 // the same object de-ref functions, though, so use that as the basis of
the check. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 220 fromInternalPointer(object)->deref(); | 214 fromInternalPointer(object)->deref(); |
| 221 } | 215 } |
| 222 | 216 |
| 223 template<> | 217 template<> |
| 224 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor* impl, v8::Handle<v8
::Object> creationContext, v8::Isolate* isolate) | 218 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor* impl, v8::Handle<v8
::Object> creationContext, v8::Isolate* isolate) |
| 225 { | 219 { |
| 226 return toV8(impl, creationContext, isolate); | 220 return toV8(impl, creationContext, isolate); |
| 227 } | 221 } |
| 228 | 222 |
| 229 } // namespace WebCore | 223 } // namespace WebCore |
| OLD | NEW |