| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultNullStringOp
tionalstringArg, argumentOrNull(info, 4)); | 132 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultNullStringOp
tionalstringArg, argumentOrNull(info, 4)); |
| 133 RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::
createForJSConstructor(*document, stringArg, defaultUndefinedOptionalBooleanArg,
defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNull
StringOptionalstringArg, exceptionState); | 133 RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::
createForJSConstructor(*document, stringArg, defaultUndefinedOptionalBooleanArg,
defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNull
StringOptionalstringArg, exceptionState); |
| 134 v8::Handle<v8::Object> wrapper = info.Holder(); | 134 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 135 if (exceptionState.throwIfNeeded()) | 135 if (exceptionState.throwIfNeeded()) |
| 136 return; | 136 return; |
| 137 | 137 |
| 138 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor>(im
pl.release(), &V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrap
per, info.GetIsolate(), WrapperConfiguration::Dependent); | 138 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceNamedConstructor>(im
pl.release(), &V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrap
per, info.GetIsolate(), WrapperConfiguration::Dependent); |
| 139 v8SetReturnValue(info, wrapper); | 139 v8SetReturnValue(info, wrapper); |
| 140 } | 140 } |
| 141 | 141 |
| 142 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructorConstructor::dom
Template(v8::Isolate* isolate, WrapperWorldType currentWorldType) | 142 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructorConstructor::dom
Template(v8::Isolate* isolate) |
| 143 { | 143 { |
| 144 static int domTemplateKey; // This address is used for a key to look up the
dom template. | 144 static int domTemplateKey; // This address is used for a key to look up the
dom template. |
| 145 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 145 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 146 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(currentWo
rldType, &domTemplateKey); | 146 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl
ateKey); |
| 147 if (!result.IsEmpty()) | 147 if (!result.IsEmpty()) |
| 148 return result; | 148 return result; |
| 149 | 149 |
| 150 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 150 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 151 v8::EscapableHandleScope scope(isolate); | 151 v8::EscapableHandleScope scope(isolate); |
| 152 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructorC
onstructorCallback); | 152 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructorC
onstructorCallback); |
| 153 | 153 |
| 154 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); | 154 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); |
| 155 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor::int
ernalFieldCount); | 155 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor::int
ernalFieldCount); |
| 156 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor"
)); | 156 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor"
)); |
| 157 result->Inherit(V8TestInterfaceNamedConstructor::domTemplate(isolate, curren
tWorldType)); | 157 result->Inherit(V8TestInterfaceNamedConstructor::domTemplate(isolate)); |
| 158 data->setDOMTemplate(currentWorldType, &domTemplateKey, result); | 158 data->setDOMTemplate(&domTemplateKey, result); |
| 159 | |
| 160 return scope.Escape(result); | 159 return scope.Escape(result); |
| 161 } | 160 } |
| 162 | 161 |
| 163 static void configureV8TestInterfaceNamedConstructorTemplate(v8::Handle<v8::Func
tionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWo
rldType) | 162 static void configureV8TestInterfaceNamedConstructorTemplate(v8::Handle<v8::Func
tionTemplate> functionTemplate, v8::Isolate* isolate) |
| 164 { | 163 { |
| 165 functionTemplate->ReadOnlyPrototype(); | 164 functionTemplate->ReadOnlyPrototype(); |
| 166 | 165 |
| 167 v8::Local<v8::Signature> defaultSignature; | 166 v8::Local<v8::Signature> defaultSignature; |
| 168 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestI
nterfaceNamedConstructor::internalFieldCount, | 167 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestI
nterfaceNamedConstructor::internalFieldCount, |
| 169 V8TestInterfaceNamedConstructorAttributes, WTF_ARRAY_LENGTH(V8TestInterf
aceNamedConstructorAttributes), | 168 V8TestInterfaceNamedConstructorAttributes, WTF_ARRAY_LENGTH(V8TestInterf
aceNamedConstructorAttributes), |
| 170 0, 0, | 169 0, 0, |
| 171 0, 0, | 170 0, 0, |
| 172 isolate, currentWorldType); | 171 isolate); |
| 173 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 172 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
| 174 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 173 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
| 175 | 174 |
| 176 // Custom toString template | 175 // Custom toString template |
| 177 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | 176 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); |
| 178 } | 177 } |
| 179 | 178 |
| 180 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor::domTemplate(v8
::Isolate* isolate, WrapperWorldType currentWorldType) | 179 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor::domTemplate(v8
::Isolate* isolate) |
| 181 { | 180 { |
| 182 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 181 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 183 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 182 V8PerIsolateData::TemplateMap::iterator result = data->templateMap().find(&w
rapperTypeInfo); |
| 184 if (result != data->templateMap(currentWorldType).end()) | 183 if (result != data->templateMap().end()) |
| 185 return result->value.newLocal(isolate); | 184 return result->value.newLocal(isolate); |
| 186 | 185 |
| 187 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 186 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 188 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); | 187 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
| 189 configureV8TestInterfaceNamedConstructorTemplate(templ, isolate, currentWorl
dType); | 188 configureV8TestInterfaceNamedConstructorTemplate(templ, isolate); |
| 190 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 189 data->templateMap().add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTempl
ate>(isolate, templ)); |
| 191 return templ; | 190 return templ; |
| 192 } | 191 } |
| 193 | 192 |
| 194 bool V8TestInterfaceNamedConstructor::hasInstance(v8::Handle<v8::Value> jsValue,
v8::Isolate* isolate) | 193 bool V8TestInterfaceNamedConstructor::hasInstance(v8::Handle<v8::Value> jsValue,
v8::Isolate* isolate) |
| 195 { | 194 { |
| 196 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); | 195 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); |
| 197 } | 196 } |
| 198 | 197 |
| 199 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor::findInstanceInPrototypeC
hain(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate) | 198 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor::findInstanceInPrototypeC
hain(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate) |
| 200 { | 199 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 fromInternalPointer(object)->deref(); | 235 fromInternalPointer(object)->deref(); |
| 237 } | 236 } |
| 238 | 237 |
| 239 template<> | 238 template<> |
| 240 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Hand
le<v8::Object> creationContext, v8::Isolate* isolate) | 239 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Hand
le<v8::Object> creationContext, v8::Isolate* isolate) |
| 241 { | 240 { |
| 242 return toV8(impl, creationContext, isolate); | 241 return toV8(impl, creationContext, isolate); |
| 243 } | 242 } |
| 244 | 243 |
| 245 } // namespace WebCore | 244 } // namespace WebCore |
| OLD | NEW |