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