Changeset 96991 in webkit
- Timestamp:
- Oct 7, 2011, 4:58:42 PM (15 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 5 edited
-
ChangeLog (modified) (1 diff)
-
WebCore.gypi (modified) (1 diff)
-
bindings/v8/NPObjectWrapper.cpp (added)
-
bindings/v8/NPObjectWrapper.h (added)
-
bindings/v8/NPV8Object.cpp (modified) (2 diffs)
-
bindings/v8/ScriptController.cpp (modified) (4 diffs)
-
bindings/v8/ScriptController.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r96990 r96991 1 2011-10-07 Anantanarayanan G Iyengar <ananta@chromium.org> 2 3 https://bugs.webkit.org/show_bug.cgi?id=69471 4 5 We now wrap the window script NPObject which is requested by NPAPI plugins for 6 scripting. The wrapped NPObject pointer maintains a weak reference to the 7 window script NPObject and is cleared out when the window script object is destroyed. 8 The NPObject wrapper is destroyed when the last outstanding reference is released. 9 10 Reviewed by Nate Chapin. 11 12 No tests added as there is no change in functionality. 13 14 * WebCore.gypi: 15 * bindings/v8/NPObjectWrapper.cpp: Added. 16 (WebCore::NPObjectWrapper::NPObjectWrapper): 17 (WebCore::NPObjectWrapper::create): 18 (WebCore::NPObjectWrapper::clear): 19 (WebCore::NPObjectWrapper::getWrapper): 20 (WebCore::NPObjectWrapper::getUnderlyingNPObject): 21 (WebCore::NPObjectWrapper::getObjectForCall): 22 (WebCore::NPObjectWrapper::NPAllocate): 23 (WebCore::NPObjectWrapper::NPDeallocate): 24 (WebCore::NPObjectWrapper::NPPInvalidate): 25 (WebCore::NPObjectWrapper::NPHasMethod): 26 (WebCore::NPObjectWrapper::NPInvoke): 27 (WebCore::NPObjectWrapper::NPInvokeDefault): 28 (WebCore::NPObjectWrapper::NPHasProperty): 29 (WebCore::NPObjectWrapper::NPGetProperty): 30 (WebCore::NPObjectWrapper::NPSetProperty): 31 (WebCore::NPObjectWrapper::NPRemoveProperty): 32 (WebCore::NPObjectWrapper::NPNEnumerate): 33 (WebCore::NPObjectWrapper::NPNConstruct): 34 (WebCore::NPObjectWrapper::NPInvokePrivate): 35 * bindings/v8/NPObjectWrapper.h: Added. 36 * bindings/v8/NPV8Object.cpp: 37 (_NPN_EvaluateHelper): 38 * bindings/v8/ScriptController.cpp: 39 (WebCore::ScriptController::ScriptController): 40 (WebCore::ScriptController::clearScriptObjects): 41 (WebCore::ScriptController::windowScriptNPObject): 42 * bindings/v8/ScriptController.h: 43 1 44 2011-10-07 Antoine Labour <piman@chromium.org> 2 45 -
trunk/Source/WebCore/WebCore.gypi
r96966 r96991 2017 2017 'bindings/v8/JavaScriptCallFrame.cpp', 2018 2018 'bindings/v8/JavaScriptCallFrame.h', 2019 'bindings/v8/NPObjectWrapper.cpp', 2020 'bindings/v8/NPObjectWrapper.h', 2019 2021 'bindings/v8/NPV8Object.cpp', 2020 2022 'bindings/v8/NPV8Object.h', -
trunk/Source/WebCore/bindings/v8/NPV8Object.cpp
r95901 r96991 32 32 #include "DOMWindow.h" 33 33 #include "Frame.h" 34 #include "NPObjectWrapper.h" 34 35 #include "OwnArrayPtr.h" 35 36 #include "PlatformString.h" … … 284 285 return false; 285 286 286 if (npObject->_class != npScriptObjectClass) 287 return false; 287 if (npObject->_class != npScriptObjectClass) { 288 // Check if the object passed in is wrapped. If yes, then we need to invoke on the underlying object. 289 NPObject* actualObject = NPObjectWrapper::getUnderlyingNPObject(npObject); 290 if (!actualObject) 291 return false; 292 npObject = actualObject; 293 } 288 294 289 295 v8::HandleScope handleScope; -
trunk/Source/WebCore/bindings/v8/ScriptController.cpp
r95901 r96991 46 46 #include "Node.h" 47 47 #include "NotImplemented.h" 48 #include "NPObjectWrapper.h" 48 49 #include "npruntime_impl.h" 49 50 #include "npruntime_priv.h" … … 114 115 , m_proxy(adoptPtr(new V8Proxy(frame))) 115 116 #if ENABLE(NETSCAPE_PLUGIN_API) 116 , m_w indowScriptNPObject(0)117 , m_wrappedWindowScriptNPObject(0) 117 118 #endif 118 119 { … … 133 134 134 135 #if ENABLE(NETSCAPE_PLUGIN_API) 135 if (m_windowScriptNPObject) { 136 if (m_wrappedWindowScriptNPObject) { 137 NPObjectWrapper* windowScriptObjectWrapper = NPObjectWrapper::getWrapper(m_wrappedWindowScriptNPObject); 138 ASSERT(windowScriptObjectWrapper); 139 140 NPObject* windowScriptNPObject = NPObjectWrapper::getUnderlyingNPObject(m_wrappedWindowScriptNPObject); 141 ASSERT(windowScriptNPObject); 136 142 // Call _NPN_DeallocateObject() instead of _NPN_ReleaseObject() so that we don't leak if a plugin fails to release the window 137 143 // script object properly. 138 144 // This shouldn't cause any problems for plugins since they should have already been stopped and destroyed at this point. 139 _NPN_DeallocateObject(m_windowScriptNPObject); 140 m_windowScriptNPObject = 0; 145 _NPN_DeallocateObject(windowScriptNPObject); 146 147 // Clear out the wrapped window script object pointer held by the wrapper. 148 windowScriptObjectWrapper->clear(); 149 _NPN_ReleaseObject(m_wrappedWindowScriptNPObject); 150 m_wrappedWindowScriptNPObject = 0; 141 151 } 142 152 #endif … … 360 370 NPObject* ScriptController::windowScriptNPObject() 361 371 { 362 if (m_windowScriptNPObject) 363 return m_windowScriptNPObject; 364 372 if (m_wrappedWindowScriptNPObject) 373 return m_wrappedWindowScriptNPObject; 374 375 NPObject* windowScriptNPObject = 0; 365 376 if (canExecuteScripts(NotAboutToExecuteScript)) { 366 377 // JavaScript is enabled, so there is a JavaScript window object. 367 378 // Return an NPObject bound to the window object. 368 m_windowScriptNPObject = createScriptObject(m_frame);369 _NPN_RegisterObject( m_windowScriptNPObject, 0);379 windowScriptNPObject = createScriptObject(m_frame); 380 _NPN_RegisterObject(windowScriptNPObject, 0); 370 381 } else { 371 382 // JavaScript is not enabled, so we cannot bind the NPObject to the 372 383 // JavaScript window object. Instead, we create an NPObject of a 373 384 // different class, one which is not bound to a JavaScript object. 374 m_windowScriptNPObject = createNoScriptObject();385 windowScriptNPObject = createNoScriptObject(); 375 386 } 376 return m_windowScriptNPObject; 387 388 m_wrappedWindowScriptNPObject = NPObjectWrapper::create(windowScriptNPObject); 389 return m_wrappedWindowScriptNPObject; 377 390 } 378 391 -
trunk/Source/WebCore/bindings/v8/ScriptController.h
r95901 r96991 209 209 PluginObjectMap m_pluginObjects; 210 210 #if ENABLE(NETSCAPE_PLUGIN_API) 211 NPObject* m_windowScriptNPObject; 211 // The window script object can get destroyed while there are outstanding 212 // references to it. Please refer to ScriptController::clearScriptObjects 213 // for more information as to why this is necessary. To avoid crashes due 214 // to calls on the destroyed window object, we return a proxy NPObject 215 // which wraps the underlying window object. The wrapped window object 216 // pointer in this object is cleared out when the window object is 217 // destroyed. 218 NPObject* m_wrappedWindowScriptNPObject; 212 219 #endif 213 220 };
Note:
See TracChangeset
for help on using the changeset viewer.