OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) | 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) |
3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
4 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Lesser General Public | 7 * modify it under the terms of the GNU Lesser General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 // Instead, we create an NPObject of a different class, one which is
not bound to a JavaScript object. | 311 // Instead, we create an NPObject of a different class, one which is
not bound to a JavaScript object. |
312 m_windowScriptNPObject = _NPN_CreateNoScriptObject(); | 312 m_windowScriptNPObject = _NPN_CreateNoScriptObject(); |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 return m_windowScriptNPObject; | 316 return m_windowScriptNPObject; |
317 } | 317 } |
318 | 318 |
319 NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
* plugin) | 319 NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
* plugin) |
320 { | 320 { |
321 // Can't create NPObjects when JavaScript is disabled | 321 JSObject* object = jsObjectForPluginElement(plugin); |
| 322 if (!object) |
| 323 return _NPN_CreateNoScriptObject(); |
| 324 |
| 325 // Wrap the JSObject in an NPObject |
| 326 return _NPN_CreateScriptObject(0, object, bindingRootObject()); |
| 327 } |
| 328 #endif |
| 329 |
| 330 JSObject* ScriptController::jsObjectForPluginElement(HTMLPlugInElement* plugin) |
| 331 { |
| 332 // Can't create JSObjects when JavaScript is disabled |
322 if (!isEnabled()) | 333 if (!isEnabled()) |
323 return _NPN_CreateNoScriptObject(); | 334 return 0; |
324 | 335 |
325 // Create a JSObject bound to this element | 336 // Create a JSObject bound to this element |
326 JSLock lock(false); | 337 JSLock lock(false); |
327 ExecState* exec = globalObject()->globalExec(); | 338 ExecState* exec = globalObject()->globalExec(); |
328 JSValuePtr jsElementValue = toJS(exec, plugin); | 339 JSValuePtr jsElementValue = toJS(exec, plugin); |
329 if (!jsElementValue || !jsElementValue.isObject()) | 340 if (!jsElementValue || !jsElementValue.isObject()) |
330 return _NPN_CreateNoScriptObject(); | 341 return 0; |
331 | 342 |
332 // Wrap the JSObject in an NPObject | 343 return jsElementValue.getObject(); |
333 return _NPN_CreateScriptObject(0, jsElementValue.getObject(), bindingRootObj
ect()); | |
334 } | 344 } |
335 #endif | |
336 | 345 |
337 #if !PLATFORM(MAC) | 346 #if !PLATFORM(MAC) |
338 void ScriptController::updatePlatformScriptObjects() | 347 void ScriptController::updatePlatformScriptObjects() |
339 { | 348 { |
340 } | 349 } |
341 | 350 |
342 void ScriptController::disconnectPlatformScriptObjects() | 351 void ScriptController::disconnectPlatformScriptObjects() |
343 { | 352 { |
344 } | 353 } |
345 #endif | 354 #endif |
(...skipping 29 matching lines...) Expand all Loading... |
375 // Call _NPN_DeallocateObject() instead of _NPN_ReleaseObject() so that
we don't leak if a plugin fails to release the window | 384 // Call _NPN_DeallocateObject() instead of _NPN_ReleaseObject() so that
we don't leak if a plugin fails to release the window |
376 // script object properly. | 385 // script object properly. |
377 // This shouldn't cause any problems for plugins since they should have
already been stopped and destroyed at this point. | 386 // This shouldn't cause any problems for plugins since they should have
already been stopped and destroyed at this point. |
378 _NPN_DeallocateObject(m_windowScriptNPObject); | 387 _NPN_DeallocateObject(m_windowScriptNPObject); |
379 m_windowScriptNPObject = 0; | 388 m_windowScriptNPObject = 0; |
380 } | 389 } |
381 #endif | 390 #endif |
382 } | 391 } |
383 | 392 |
384 } // namespace WebCore | 393 } // namespace WebCore |
OLD | NEW |