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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 | 182 |
183 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { | 183 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { |
184 v8SetReturnValue(info, info.Holder()); | 184 v8SetReturnValue(info, info.Holder()); |
185 return; | 185 return; |
186 } | 186 } |
187 | 187 |
188 TestNodeV8Internal::constructor(info); | 188 TestNodeV8Internal::constructor(info); |
189 } | 189 } |
190 | 190 |
191 static void configureV8TestNodeTemplate(v8::Handle<v8::FunctionTemplate> functio
nTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType) | 191 static void configureV8TestNodeTemplate(v8::Handle<v8::FunctionTemplate> functio
nTemplate, v8::Isolate* isolate) |
192 { | 192 { |
193 functionTemplate->ReadOnlyPrototype(); | 193 functionTemplate->ReadOnlyPrototype(); |
194 | 194 |
195 v8::Local<v8::Signature> defaultSignature; | 195 v8::Local<v8::Signature> defaultSignature; |
196 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestNode", V8Node::domTemplate(isolate, currentWorldType), V8TestNode::int
ernalFieldCount, | 196 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestNode", V8Node::domTemplate(isolate), V8TestNode::internalFieldCount, |
197 V8TestNodeAttributes, WTF_ARRAY_LENGTH(V8TestNodeAttributes), | 197 V8TestNodeAttributes, WTF_ARRAY_LENGTH(V8TestNodeAttributes), |
198 0, 0, | 198 0, 0, |
199 0, 0, | 199 0, 0, |
200 isolate, currentWorldType); | 200 isolate); |
201 functionTemplate->SetCallHandler(V8TestNode::constructorCallback); | 201 functionTemplate->SetCallHandler(V8TestNode::constructorCallback); |
202 functionTemplate->SetLength(0); | 202 functionTemplate->SetLength(0); |
203 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 203 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
204 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 204 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
205 | 205 |
206 // Custom toString template | 206 // Custom toString template |
207 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | 207 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); |
208 } | 208 } |
209 | 209 |
210 v8::Handle<v8::FunctionTemplate> V8TestNode::domTemplate(v8::Isolate* isolate, W
rapperWorldType currentWorldType) | 210 v8::Handle<v8::FunctionTemplate> V8TestNode::domTemplate(v8::Isolate* isolate) |
211 { | 211 { |
212 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 212 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
213 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | 213 V8PerIsolateData::TemplateMap::iterator result = data->templateMap().find(&w
rapperTypeInfo); |
214 if (result != data->templateMap(currentWorldType).end()) | 214 if (result != data->templateMap().end()) |
215 return result->value.newLocal(isolate); | 215 return result->value.newLocal(isolate); |
216 | 216 |
217 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 217 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
218 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); | 218 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
219 configureV8TestNodeTemplate(templ, isolate, currentWorldType); | 219 configureV8TestNodeTemplate(templ, isolate); |
220 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 220 data->templateMap().add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTempl
ate>(isolate, templ)); |
221 return templ; | 221 return templ; |
222 } | 222 } |
223 | 223 |
224 bool V8TestNode::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate
) | 224 bool V8TestNode::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate
) |
225 { | 225 { |
226 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); | 226 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e); |
227 } | 227 } |
228 | 228 |
229 v8::Handle<v8::Object> V8TestNode::findInstanceInPrototypeChain(v8::Handle<v8::V
alue> jsValue, v8::Isolate* isolate) | 229 v8::Handle<v8::Object> V8TestNode::findInstanceInPrototypeChain(v8::Handle<v8::V
alue> jsValue, v8::Isolate* isolate) |
230 { | 230 { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 fromInternalPointer(object)->deref(); | 266 fromInternalPointer(object)->deref(); |
267 } | 267 } |
268 | 268 |
269 template<> | 269 template<> |
270 v8::Handle<v8::Value> toV8NoInline(TestNode* impl, v8::Handle<v8::Object> creati
onContext, v8::Isolate* isolate) | 270 v8::Handle<v8::Value> toV8NoInline(TestNode* impl, v8::Handle<v8::Object> creati
onContext, v8::Isolate* isolate) |
271 { | 271 { |
272 return toV8(impl, creationContext, isolate); | 272 return toV8(impl, creationContext, isolate); |
273 } | 273 } |
274 | 274 |
275 } // namespace WebCore | 275 } // namespace WebCore |
OLD | NEW |