OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObj
ect* object) | 347 void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObj
ect* object) |
348 { | 348 { |
349 v8::HandleScope handleScope(m_isolate); | 349 v8::HandleScope handleScope(m_isolate); |
350 | 350 |
351 v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(frame
); | 351 v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(frame
); |
352 if (v8Context.IsEmpty()) | 352 if (v8Context.IsEmpty()) |
353 return; | 353 return; |
354 | 354 |
355 v8::Context::Scope scope(v8Context); | 355 v8::Context::Scope scope(v8Context); |
356 | 356 |
357 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0); | 357 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0, m_isolat
e); |
358 | 358 |
359 // Attach to the global object. | 359 // Attach to the global object. |
360 v8::Handle<v8::Object> global = v8Context->Global(); | 360 v8::Handle<v8::Object> global = v8Context->Global(); |
361 global->Set(v8String(key, m_isolate), value); | 361 global->Set(v8String(key, m_isolate), value); |
362 } | 362 } |
363 | 363 |
364 void ScriptController::enableEval() | 364 void ScriptController::enableEval() |
365 { | 365 { |
366 if (!m_windowShell->isContextInitialized()) | 366 if (!m_windowShell->isContextInitialized()) |
367 return; | 367 return; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // javascript garbage collection is non-deterministic, yet we need to | 407 // javascript garbage collection is non-deterministic, yet we need to |
408 // be able to tear down the plugin objects immediately. When an object | 408 // be able to tear down the plugin objects immediately. When an object |
409 // is registered, javascript can use it. When the object is destroyed, | 409 // is registered, javascript can use it. When the object is destroyed, |
410 // or when the object's "owning" object is destroyed, the object will | 410 // or when the object's "owning" object is destroyed, the object will |
411 // be un-registered, and the javascript engine must not use it. | 411 // be un-registered, and the javascript engine must not use it. |
412 // | 412 // |
413 // Inside the javascript engine, the engine can keep a reference to the | 413 // Inside the javascript engine, the engine can keep a reference to the |
414 // NPObject as part of its wrapper. However, before accessing the object | 414 // NPObject as part of its wrapper. However, before accessing the object |
415 // it must consult the _NPN_Registry. | 415 // it must consult the _NPN_Registry. |
416 | 416 |
417 v8::Local<v8::Object> wrapper = createV8ObjectForNPObject(npObject, 0); | 417 v8::Local<v8::Object> wrapper = createV8ObjectForNPObject(npObject, 0, m_iso
late); |
418 | 418 |
419 // Track the plugin object. We've been given a reference to the object. | 419 // Track the plugin object. We've been given a reference to the object. |
420 m_pluginObjects.set(widget, npObject); | 420 m_pluginObjects.set(widget, npObject); |
421 | 421 |
422 return V8ScriptInstance::create(wrapper); | 422 return V8ScriptInstance::create(wrapper); |
423 } | 423 } |
424 | 424 |
425 void ScriptController::cleanupScriptObjectsForPlugin(Widget* nativeHandle) | 425 void ScriptController::cleanupScriptObjectsForPlugin(Widget* nativeHandle) |
426 { | 426 { |
427 PluginObjectMap::iterator it = m_pluginObjects.find(nativeHandle); | 427 PluginObjectMap::iterator it = m_pluginObjects.find(nativeHandle); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 v8Results = evaluateHandleScope.Close(resultArray); | 714 v8Results = evaluateHandleScope.Close(resultArray); |
715 } | 715 } |
716 | 716 |
717 if (results && !v8Results.IsEmpty()) { | 717 if (results && !v8Results.IsEmpty()) { |
718 for (size_t i = 0; i < v8Results->Length(); ++i) | 718 for (size_t i = 0; i < v8Results->Length(); ++i) |
719 results->append(ScriptValue(v8Results->Get(i))); | 719 results->append(ScriptValue(v8Results->Get(i))); |
720 } | 720 } |
721 } | 721 } |
722 | 722 |
723 } // namespace WebCore | 723 } // namespace WebCore |
OLD | NEW |