OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (!v8NPObject) | 216 if (!v8NPObject) |
217 return false; | 217 return false; |
218 | 218 |
219 v8::HandleScope handleScope(isolate); | 219 v8::HandleScope handleScope(isolate); |
220 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); | 220 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); |
221 if (v8Object.IsEmpty()) | 221 if (v8Object.IsEmpty()) |
222 return false; | 222 return false; |
223 if (!V8Range::wrapperTypeInfo.equals(toWrapperTypeInfo(v8Object))) | 223 if (!V8Range::wrapperTypeInfo.equals(toWrapperTypeInfo(v8Object))) |
224 return false; | 224 return false; |
225 | 225 |
226 Range* native = V8Range::hasInstance(v8Object, isolate) ? V8Range::toNative(
v8Object) : 0; | 226 Range* native = V8Range::hasInstance(v8Object, isolate) ? V8Range::toImpl(v8
Object) : 0; |
227 if (!native) | 227 if (!native) |
228 return false; | 228 return false; |
229 | 229 |
230 *webRange = WebRange(native); | 230 *webRange = WebRange(native); |
231 return true; | 231 return true; |
232 } | 232 } |
233 | 233 |
234 static bool getNodeImpl(NPObject* object, WebNode* webNode, v8::Isolate* isolate
) | 234 static bool getNodeImpl(NPObject* object, WebNode* webNode, v8::Isolate* isolate
) |
235 { | 235 { |
236 if (!object) | 236 if (!object) |
237 return false; | 237 return false; |
238 | 238 |
239 V8NPObject* v8NPObject = npObjectToV8NPObject(object); | 239 V8NPObject* v8NPObject = npObjectToV8NPObject(object); |
240 if (!v8NPObject) | 240 if (!v8NPObject) |
241 return false; | 241 return false; |
242 | 242 |
243 v8::HandleScope handleScope(isolate); | 243 v8::HandleScope handleScope(isolate); |
244 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); | 244 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); |
245 if (v8Object.IsEmpty()) | 245 if (v8Object.IsEmpty()) |
246 return false; | 246 return false; |
247 Node* native = V8Node::hasInstance(v8Object, isolate) ? V8Node::toNative(v8O
bject) : 0; | 247 Node* native = V8Node::hasInstance(v8Object, isolate) ? V8Node::toImpl(v8Obj
ect) : 0; |
248 if (!native) | 248 if (!native) |
249 return false; | 249 return false; |
250 | 250 |
251 *webNode = WebNode(native); | 251 *webNode = WebNode(native); |
252 return true; | 252 return true; |
253 } | 253 } |
254 | 254 |
255 static bool getElementImpl(NPObject* object, WebElement* webElement, v8::Isolate
* isolate) | 255 static bool getElementImpl(NPObject* object, WebElement* webElement, v8::Isolate
* isolate) |
256 { | 256 { |
257 if (!object) | 257 if (!object) |
258 return false; | 258 return false; |
259 | 259 |
260 V8NPObject* v8NPObject = npObjectToV8NPObject(object); | 260 V8NPObject* v8NPObject = npObjectToV8NPObject(object); |
261 if (!v8NPObject) | 261 if (!v8NPObject) |
262 return false; | 262 return false; |
263 | 263 |
264 v8::HandleScope handleScope(isolate); | 264 v8::HandleScope handleScope(isolate); |
265 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); | 265 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); |
266 if (v8Object.IsEmpty()) | 266 if (v8Object.IsEmpty()) |
267 return false; | 267 return false; |
268 Element* native = V8Element::hasInstance(v8Object, isolate) ? V8Element::toN
ative(v8Object) : 0; | 268 Element* native = V8Element::hasInstance(v8Object, isolate) ? V8Element::toI
mpl(v8Object) : 0; |
269 if (!native) | 269 if (!native) |
270 return false; | 270 return false; |
271 | 271 |
272 *webElement = WebElement(native); | 272 *webElement = WebElement(native); |
273 return true; | 273 return true; |
274 } | 274 } |
275 | 275 |
276 static bool getArrayBufferImpl(NPObject* object, WebArrayBuffer* arrayBuffer, v8
::Isolate* isolate) | 276 static bool getArrayBufferImpl(NPObject* object, WebArrayBuffer* arrayBuffer, v8
::Isolate* isolate) |
277 { | 277 { |
278 if (!object) | 278 if (!object) |
279 return false; | 279 return false; |
280 | 280 |
281 V8NPObject* v8NPObject = npObjectToV8NPObject(object); | 281 V8NPObject* v8NPObject = npObjectToV8NPObject(object); |
282 if (!v8NPObject) | 282 if (!v8NPObject) |
283 return false; | 283 return false; |
284 | 284 |
285 v8::HandleScope handleScope(isolate); | 285 v8::HandleScope handleScope(isolate); |
286 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); | 286 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); |
287 if (v8Object.IsEmpty()) | 287 if (v8Object.IsEmpty()) |
288 return false; | 288 return false; |
289 ArrayBuffer* native = V8ArrayBuffer::hasInstance(v8Object, isolate) ? V8Arra
yBuffer::toNative(v8Object) : 0; | 289 ArrayBuffer* native = V8ArrayBuffer::hasInstance(v8Object, isolate) ? V8Arra
yBuffer::toImpl(v8Object) : 0; |
290 if (!native) | 290 if (!native) |
291 return false; | 291 return false; |
292 | 292 |
293 *arrayBuffer = WebArrayBuffer(native); | 293 *arrayBuffer = WebArrayBuffer(native); |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 static bool getArrayBufferViewImpl(NPObject* object, WebArrayBufferView* arrayBu
fferView, v8::Isolate* isolate) | 297 static bool getArrayBufferViewImpl(NPObject* object, WebArrayBufferView* arrayBu
fferView, v8::Isolate* isolate) |
298 { | 298 { |
299 if (!object) | 299 if (!object) |
300 return false; | 300 return false; |
301 | 301 |
302 V8NPObject* v8NPObject = npObjectToV8NPObject(object); | 302 V8NPObject* v8NPObject = npObjectToV8NPObject(object); |
303 if (!v8NPObject) | 303 if (!v8NPObject) |
304 return false; | 304 return false; |
305 | 305 |
306 v8::HandleScope handleScope(isolate); | 306 v8::HandleScope handleScope(isolate); |
307 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); | 307 v8::Handle<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NPOb
ject->v8Object); |
308 if (v8Object.IsEmpty()) | 308 if (v8Object.IsEmpty()) |
309 return false; | 309 return false; |
310 ArrayBufferView* native = V8ArrayBufferView::hasInstance(v8Object, isolate)
? V8ArrayBufferView::toNative(v8Object) : 0; | 310 ArrayBufferView* native = V8ArrayBufferView::hasInstance(v8Object, isolate)
? V8ArrayBufferView::toImpl(v8Object) : 0; |
311 if (!native) | 311 if (!native) |
312 return false; | 312 return false; |
313 | 313 |
314 *arrayBufferView = WebArrayBufferView(native); | 314 *arrayBufferView = WebArrayBufferView(native); |
315 return true; | 315 return true; |
316 } | 316 } |
317 | 317 |
318 static NPObject* makeIntArrayImpl(const WebVector<int>& data, v8::Isolate* isola
te) | 318 static NPObject* makeIntArrayImpl(const WebVector<int>& data, v8::Isolate* isola
te) |
319 { | 319 { |
320 v8::HandleScope handleScope(isolate); | 320 v8::HandleScope handleScope(isolate); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 if (!v8Object) | 396 if (!v8Object) |
397 return v8::Undefined(isolate); | 397 return v8::Undefined(isolate); |
398 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame()
->script().windowScriptNPObject(), isolate); | 398 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame()
->script().windowScriptNPObject(), isolate); |
399 } | 399 } |
400 // Safe to pass 0 since we have checked the script object class to make sure
the | 400 // Safe to pass 0 since we have checked the script object class to make sure
the |
401 // argument is a primitive v8 type. | 401 // argument is a primitive v8 type. |
402 return convertNPVariantToV8Object(variant, 0, isolate); | 402 return convertNPVariantToV8Object(variant, 0, isolate); |
403 } | 403 } |
404 | 404 |
405 } // namespace blink | 405 } // namespace blink |
OLD | NEW |