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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 for (size_t i = 0; i < data.size(); ++i) | 283 for (size_t i = 0; i < data.size(); ++i) |
284 result->Set(i, v8::Number::New(data[i])); | 284 result->Set(i, v8::Number::New(data[i])); |
285 | 285 |
286 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); | 286 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); |
287 return npCreateV8ScriptObject(0, result, window); | 287 return npCreateV8ScriptObject(0, result, window); |
288 } | 288 } |
289 | 289 |
290 static NPObject* makeStringArrayImpl(const WebVector<WebString>& data) | 290 static NPObject* makeStringArrayImpl(const WebVector<WebString>& data) |
291 { | 291 { |
292 v8::HandleScope handleScope; | 292 v8::HandleScope handleScope; |
| 293 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 294 |
293 v8::Handle<v8::Array> result = v8::Array::New(data.size()); | 295 v8::Handle<v8::Array> result = v8::Array::New(data.size()); |
294 for (size_t i = 0; i < data.size(); ++i) | 296 for (size_t i = 0; i < data.size(); ++i) |
295 result->Set(i, data[i].data() ? v8::String::New(reinterpret_cast<const u
int16_t*>((data[i].data())), data[i].length()) : v8::String::New("")); | 297 result->Set(i, v8String(String(data[i]), isolate)); |
296 | 298 |
297 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); | 299 DOMWindow* window = toDOMWindow(v8::Context::GetCurrent()); |
298 return npCreateV8ScriptObject(0, result, window); | 300 return npCreateV8ScriptObject(0, result, window); |
299 } | 301 } |
300 | 302 |
301 bool WebBindings::getRange(NPObject* range, WebRange* webRange) | 303 bool WebBindings::getRange(NPObject* range, WebRange* webRange) |
302 { | 304 { |
303 return getRangeImpl(range, webRange, v8::Isolate::GetCurrent()); | 305 return getRangeImpl(range, webRange, v8::Isolate::GetCurrent()); |
304 } | 306 } |
305 | 307 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 return v8::Undefined(); | 359 return v8::Undefined(); |
358 V8NPObject* v8Object = reinterpret_cast<V8NPObject*>(object); | 360 V8NPObject* v8Object = reinterpret_cast<V8NPObject*>(object); |
359 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame()
->script()->windowScriptNPObject(), isolate); | 361 return convertNPVariantToV8Object(variant, v8Object->rootObject->frame()
->script()->windowScriptNPObject(), isolate); |
360 } | 362 } |
361 // Safe to pass 0 since we have checked the script object class to make sure
the | 363 // Safe to pass 0 since we have checked the script object class to make sure
the |
362 // argument is a primitive v8 type. | 364 // argument is a primitive v8 type. |
363 return convertNPVariantToV8Object(variant, 0, isolate); | 365 return convertNPVariantToV8Object(variant, 0, isolate); |
364 } | 366 } |
365 | 367 |
366 } // namespace WebKit | 368 } // namespace WebKit |
OLD | NEW |