| 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::HasInstanceInAnyWorld(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) | 314 static NPObject* makeIntArrayImpl(const WebVector<int>& data, v8::Isolate* isola
te) |
| 315 { | 315 { |
| 316 v8::HandleScope handleScope; | 316 v8::HandleScope handleScope(isolate); |
| 317 v8::Handle<v8::Array> result = v8::Array::New(data.size()); | 317 v8::Handle<v8::Array> result = v8::Array::New(data.size()); |
| 318 for (size_t i = 0; i < data.size(); ++i) | 318 for (size_t i = 0; i < data.size(); ++i) |
| 319 result->Set(i, v8::Number::New(data[i])); | 319 result->Set(i, v8::Number::New(data[i])); |
| 320 | 320 |
| 321 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); | 321 DOMWindow* window = toDOMWindow(isolate->GetCurrentContext()); |
| 322 return npCreateV8ScriptObject(0, result, window); | 322 return npCreateV8ScriptObject(0, result, window); |
| 323 } | 323 } |
| 324 | 324 |
| 325 static NPObject* makeStringArrayImpl(const WebVector<WebString>& data) | 325 static NPObject* makeStringArrayImpl(const WebVector<WebString>& data, v8::Isola
te* isolate) |
| 326 { | 326 { |
| 327 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 327 v8::HandleScope handleScope(isolate); |
| 328 v8::HandleScope handleScope; | |
| 329 v8::Handle<v8::Array> result = v8::Array::New(data.size()); | 328 v8::Handle<v8::Array> result = v8::Array::New(data.size()); |
| 330 for (size_t i = 0; i < data.size(); ++i) | 329 for (size_t i = 0; i < data.size(); ++i) |
| 331 result->Set(i, v8String(data[i], isolate)); | 330 result->Set(i, v8String(data[i], isolate)); |
| 332 | 331 |
| 333 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); | 332 DOMWindow* window = toDOMWindow(isolate->GetCurrentContext()); |
| 334 return npCreateV8ScriptObject(0, result, window); | 333 return npCreateV8ScriptObject(0, result, window); |
| 335 } | 334 } |
| 336 | 335 |
| 337 bool WebBindings::getRange(NPObject* range, WebRange* webRange) | 336 bool WebBindings::getRange(NPObject* range, WebRange* webRange) |
| 338 { | 337 { |
| 339 return getRangeImpl(range, webRange, v8::Isolate::GetCurrent()); | 338 return getRangeImpl(range, webRange, v8::Isolate::GetCurrent()); |
| 340 } | 339 } |
| 341 | 340 |
| 342 bool WebBindings::getArrayBuffer(NPObject* arrayBuffer, WebArrayBuffer* webArray
Buffer) | 341 bool WebBindings::getArrayBuffer(NPObject* arrayBuffer, WebArrayBuffer* webArray
Buffer) |
| 343 { | 342 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 354 return getNodeImpl(node, webNode, v8::Isolate::GetCurrent()); | 353 return getNodeImpl(node, webNode, v8::Isolate::GetCurrent()); |
| 355 } | 354 } |
| 356 | 355 |
| 357 bool WebBindings::getElement(NPObject* element, WebElement* webElement) | 356 bool WebBindings::getElement(NPObject* element, WebElement* webElement) |
| 358 { | 357 { |
| 359 return getElementImpl(element, webElement, v8::Isolate::GetCurrent()); | 358 return getElementImpl(element, webElement, v8::Isolate::GetCurrent()); |
| 360 } | 359 } |
| 361 | 360 |
| 362 NPObject* WebBindings::makeIntArray(const WebVector<int>& data) | 361 NPObject* WebBindings::makeIntArray(const WebVector<int>& data) |
| 363 { | 362 { |
| 364 return makeIntArrayImpl(data); | 363 return makeIntArrayImpl(data, v8::Isolate::GetCurrent()); |
| 365 } | 364 } |
| 366 | 365 |
| 367 NPObject* WebBindings::makeStringArray(const WebVector<WebString>& data) | 366 NPObject* WebBindings::makeStringArray(const WebVector<WebString>& data) |
| 368 { | 367 { |
| 369 return makeStringArrayImpl(data); | 368 return makeStringArrayImpl(data, v8::Isolate::GetCurrent()); |
| 370 } | 369 } |
| 371 | 370 |
| 372 void WebBindings::pushExceptionHandler(ExceptionHandler handler, void* data) | 371 void WebBindings::pushExceptionHandler(ExceptionHandler handler, void* data) |
| 373 { | 372 { |
| 374 WebCore::pushExceptionHandler(handler, data); | 373 WebCore::pushExceptionHandler(handler, data); |
| 375 } | 374 } |
| 376 | 375 |
| 377 void WebBindings::popExceptionHandler() | 376 void WebBindings::popExceptionHandler() |
| 378 { | 377 { |
| 379 WebCore::popExceptionHandler(); | 378 WebCore::popExceptionHandler(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 393 if (!v8Object) | 392 if (!v8Object) |
| 394 return v8::Undefined(); | 393 return v8::Undefined(); |
| 395 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame()
->script()->windowScriptNPObject(), isolate); | 394 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame()
->script()->windowScriptNPObject(), isolate); |
| 396 } | 395 } |
| 397 // 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 |
| 398 // argument is a primitive v8 type. | 397 // argument is a primitive v8 type. |
| 399 return convertNPVariantToV8Object(variant, 0, isolate); | 398 return convertNPVariantToV8Object(variant, 0, isolate); |
| 400 } | 399 } |
| 401 | 400 |
| 402 } // namespace WebKit | 401 } // namespace WebKit |
| OLD | NEW |