Changeset 33570 in webkit
- Timestamp:
- May 19, 2008 3:09:38 AM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r33569 r33570 1 2008-05-14 Marc Ordinas i Llopis <marc.ordinasillopis@collabora.co.uk> 2 3 Reviewed by Holger. 4 5 https://bugs.webkit.org/show_bug.cgi?id=18882 6 https://bugs.webkit.org/show_bug.cgi?id=18892 7 Based also on work by Chris Lord. 8 9 Provides support for NPAPI plugins that pass NULL as their instance 10 info. There are two kinds: 11 - Some call NPN_UserAgent and NPN_GetValue before a PluginView has 12 been created. For those we provide static versions of those functions. 13 - Others call NPN_* functions with a NULL instance inside NPP_* 14 calls, for those we've added extra currentPluginView guards. 15 16 * plugins/PluginView.cpp: Add additional currentPluginView guards and 17 some small style changes. 18 (WebCore::PluginView::start): 19 (WebCore::PluginView::performRequest): 20 (WebCore::PluginView::bindingInstance): 21 (WebCore::PluginView::handlePost): 22 * plugins/PluginView.h: Added static versions of NPN_UserAgent and 23 NPN_GetValue. 24 * plugins/gtk/PluginViewGtk.cpp: Add additional currentPluginView 25 guards and some small style changes. 26 (WebCore::PluginView::setNPWindowRect): 27 (WebCore::PluginView::stop): 28 (WebCore::PluginView::userAgentStatic): Added to deal with plugins 29 that query this before having a PluginView. 30 (WebCore::PluginView::getValueStatic): Added to deal with plugins 31 that call this before we have created a PluginView. 32 (WebCore::PluginView::getValue): Moved some code to getValueStatic. 33 (WebCore::PluginView::init): 34 * plugins/npapi.cpp: Call PluginView::userAgentStatic 35 and PluginView::getValueStatic if no PluginView is 36 present. 37 (NPN_UserAgent): 38 (NPN_GetValue): 39 * plugins/qt/PluginPackageQt.cpp: 40 (WebCore::PluginPackage::fetchInfo): Corrected split args because ignoring 41 empty entries crashed. 42 (WebCore::PluginPackage::load): Resolve all symbols when loading plugins 43 to protect against XPCOM dependencies. 44 * plugins/qt/PluginViewQt.cpp: Add additional currentPluginView guards and 45 some small style changes. 46 (WebCore::PluginView::updateWindow): 47 (WebCore::PluginView::setNPWindowRect): 48 (WebCore::PluginView::stop): 49 (WebCore::PluginView::userAgentStatic): Added to deal with plugins 50 that query this before having a PluginView. 51 (WebCore::PluginView::handlePostReadFile): 52 (WebCore::PluginView::getValueStatic): Added to deal with plugins 53 that call this before we have created a PluginView. 54 (WebCore::PluginView::getValue): Moved some code to getValueStatic. 55 (WebCore::PluginView::init): m_needsXEmbed init was moved to constructor. 56 1 57 2008-05-19 Alp Toker <alp@nuanti.com> 2 58 -
trunk/WebCore/plugins/PluginView.cpp
r33441 r33570 152 152 153 153 NPError npErr; 154 PluginView::setCurrentPluginView(this);155 154 { 155 PluginView::setCurrentPluginView(this); 156 156 KJS::JSLock::DropAllLocks dropAllLocks; 157 157 setCallingPlugin(true); … … 159 159 setCallingPlugin(false); 160 160 LOG_NPERROR(npErr); 161 }162 PluginView::setCurrentPluginView(0);161 PluginView::setCurrentPluginView(0); 162 } 163 163 164 164 if (npErr != NPERR_NO_ERROR) … … 235 235 // FIXME: <rdar://problem/4807469> This should be sent when the document has finished loading 236 236 if (request->sendNotification()) { 237 PluginView::setCurrentPluginView(this); 237 238 KJS::JSLock::DropAllLocks dropAllLocks; 238 239 setCallingPlugin(true); 239 240 m_plugin->pluginFuncs()->urlnotify(m_instance, requestURL.string().utf8().data(), NPRES_DONE, request->notifyData()); 240 241 setCallingPlugin(false); 242 PluginView::setCurrentPluginView(0); 241 243 } 242 244 } … … 462 464 NPError npErr; 463 465 { 466 PluginView::setCurrentPluginView(this); 464 467 KJS::JSLock::DropAllLocks dropAllLocks; 465 468 setCallingPlugin(true); 466 469 npErr = m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginScriptableNPObject, &object); 467 470 setCallingPlugin(false); 471 PluginView::setCurrentPluginView(0); 468 472 } 469 473 -
trunk/WebCore/plugins/PluginView.h
r33452 r33570 119 119 NPError destroyStream(NPStream* stream, NPReason reason); 120 120 const char* userAgent(); 121 static const char* userAgentStatic(); 121 122 void status(const char* message); 122 123 NPError getValue(NPNVariable variable, void* value); 124 static NPError getValueStatic(NPNVariable variable, void* value); 123 125 NPError setValue(NPPVariable variable, void* value); 124 126 void invalidateRect(NPRect*); -
trunk/WebCore/plugins/gtk/PluginViewGtk.cpp
r33569 r33570 226 226 227 227 if (m_plugin->pluginFuncs()->setwindow) { 228 PluginView::setCurrentPluginView(this); 228 229 KJS::JSLock::DropAllLocks dropAllLocks; 229 230 setCallingPlugin(true); 230 231 m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow); 231 232 setCallingPlugin(false); 233 PluginView::setCurrentPluginView(0); 232 234 233 235 if (!m_isWindowed) … … 283 285 #endif 284 286 if (m_plugin->pluginFuncs()->setwindow && !m_plugin->quirks().contains(PluginQuirkDontSetNullWindowHandleOnDestroy)) { 287 PluginView::setCurrentPluginView(this); 285 288 setCallingPlugin(true); 286 289 m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow); 287 290 setCallingPlugin(false); 291 PluginView::setCurrentPluginView(0); 288 292 } 289 293 290 294 // Destroy the plugin 291 295 { 296 PluginView::setCurrentPluginView(this); 292 297 setCallingPlugin(true); 293 298 m_plugin->pluginFuncs()->destroy(m_instance, 0); 294 299 setCallingPlugin(false); 300 PluginView::setCurrentPluginView(0); 295 301 } 296 302 … … 309 315 310 316 return m_userAgent.data(); 317 } 318 319 const char* PluginView::userAgentStatic() 320 { 321 //FIXME - Lie and say we are Mozilla 322 return MozillaUserAgent; 311 323 } 312 324 … … 340 352 } 341 353 342 NPError PluginView::getValue (NPNVariable variable, void* value)354 NPError PluginView::getValueStatic(NPNVariable variable, void* value) 343 355 { 344 356 switch (variable) { 345 #if defined(GDK_WINDOWING_X11)346 case NPNVxtAppContext: {347 if (!m_needsXEmbed) {348 *(void **)value = XtDisplayToApplicationContext (GTK_XTBIN(m_window)->xtclient.xtdisplay);349 350 return NPERR_NO_ERROR;351 } else352 return NPERR_GENERIC_ERROR;353 }354 #endif355 356 357 case NPNVToolkit: { 357 358 #if PLATFORM(GTK) … … 372 373 } 373 374 375 case NPNVjavascriptEnabledBool: { 376 *((uint32 *)value) = true; 377 return NPERR_NO_ERROR; 378 } 379 380 default: 381 return NPERR_GENERIC_ERROR; 382 } 383 } 384 385 NPError PluginView::getValue(NPNVariable variable, void* value) 386 { 387 switch (variable) { 388 case NPNVxDisplay: { 389 #if defined(GDK_WINDOWING_X11) 390 if (m_needsXEmbed) 391 *(void **)value = (void *)GDK_DISPLAY(); 392 else 393 *(void **)value = (void *)GTK_XTBIN(m_window)->xtclient.xtdisplay; 394 return NPERR_NO_ERROR; 395 #else 396 return NPERR_GENERIC_ERROR; 397 #endif 398 } 399 400 #if defined(GDK_WINDOWING_X11) 401 case NPNVxtAppContext: { 402 if (!m_needsXEmbed) { 403 *(void **)value = XtDisplayToApplicationContext (GTK_XTBIN(m_window)->xtclient.xtdisplay); 404 405 return NPERR_NO_ERROR; 406 } else 407 return NPERR_GENERIC_ERROR; 408 } 409 #endif 410 374 411 #if ENABLE(NETSCAPE_PLUGIN_API) 375 412 case NPNVWindowNPObject: { … … 421 458 } 422 459 default: 423 return NPERR_GENERIC_ERROR;460 return getValueStatic(variable, value); 424 461 } 425 462 } … … 487 524 } 488 525 489 if (m_plugin->pluginFuncs()->getvalue) 526 if (m_plugin->pluginFuncs()->getvalue) { 527 PluginView::setCurrentPluginView(this); 528 KJS::JSLock::DropAllLocks dropAllLocks; 529 setCallingPlugin(true); 490 530 m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginNeedsXEmbed, &m_needsXEmbed); 531 setCallingPlugin(false); 532 PluginView::setCurrentPluginView(0); 533 } 491 534 492 535 #if defined(GDK_WINDOWING_X11) -
trunk/WebCore/plugins/npapi.cpp
r32766 r33570 108 108 PluginView* view = pluginViewForInstance(instance); 109 109 110 // FIXME: Some plug-ins call NPN_UserAgent with a null instance in their NP_initialize function!111 // We'd need a way to get a user agent without having a frame around.112 110 if (!view) 113 return 0;111 return PluginView::userAgentStatic(); 114 112 115 113 return view->userAgent(); … … 138 136 NPError NPN_GetValue(NPP instance, NPNVariable variable, void* value) 139 137 { 140 // FIXME: Acrobat reader plugin calls NPN_GetValue before a PluginView141 // has been created 142 if (!instance)143 return NPERR_GENERIC_ERROR;138 PluginView* view = pluginViewForInstance(instance); 139 140 if (!view) 141 return PluginView::getValueStatic(variable, value); 144 142 145 143 return pluginViewForInstance(instance)->getValue(variable, value); -
trunk/WebCore/plugins/qt/PluginPackageQt.cpp
r32809 r33570 88 88 for (int i = 0; i < types.size(); ++i) { 89 89 Vector<String> mime; 90 types[i].split(UChar(':'), false, mime);90 types[i].split(UChar(':'), true, mime); 91 91 if (mime.size() > 0) { 92 92 Vector<String> exts; … … 111 111 112 112 m_module = new QLibrary((QString)m_path); 113 m_module->setLoadHints(QLibrary::ResolveAllSymbolsHint); 113 114 if (!m_module->load()) { 114 115 LOG(Plugin, "%s not loaded", m_path.utf8().data()); -
trunk/WebCore/plugins/qt/PluginViewQt.cpp
r32766 r33570 186 186 187 187 if (m_plugin->pluginFuncs()->setwindow) { 188 PluginView::setCurrentPluginView(this); 188 189 KJS::JSLock::DropAllLocks dropAllLocks; 189 190 setCallingPlugin(true); 190 191 m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow); 191 192 setCallingPlugin(false); 193 PluginView::setCurrentPluginView(0); 194 195 if (!m_isWindowed) 196 return; 192 197 193 198 ASSERT(m_window); … … 238 243 m_npWindow.ws_info = 0; 239 244 if (m_plugin->pluginFuncs()->setwindow && !m_plugin->quirks().contains(PluginQuirkDontSetNullWindowHandleOnDestroy)) { 245 PluginView::setCurrentPluginView(this); 240 246 setCallingPlugin(true); 241 247 m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow); 242 248 setCallingPlugin(false); 249 PluginView::setCurrentPluginView(0); 243 250 } 244 251 245 252 // Destroy the plugin 246 253 { 254 PluginView::setCurrentPluginView(this); 247 255 setCallingPlugin(true); 248 256 m_plugin->pluginFuncs()->destroy(m_instance, 0); 249 257 setCallingPlugin(false); 258 PluginView::setCurrentPluginView(0); 250 259 } 251 260 … … 264 273 265 274 return m_userAgent.data(); 275 } 276 277 const char* PluginView::userAgentStatic() 278 { 279 //FIXME - Just say we are Mozilla 280 return MozillaUserAgent; 266 281 } 267 282 … … 292 307 293 308 return NPERR_NO_ERROR; 309 } 310 311 NPError PluginView::getValueStatic(NPNVariable variable, void* value) 312 { 313 switch (variable) { 314 case NPNVToolkit: { 315 *((uint32 *)value) = 0; 316 return NPERR_NO_ERROR; 317 } 318 319 case NPNVSupportsXEmbedBool: { 320 *((uint32 *)value) = true; 321 return NPERR_NO_ERROR; 322 } 323 324 case NPNVjavascriptEnabledBool: { 325 *((uint32 *)value) = true; 326 return NPERR_NO_ERROR; 327 } 328 329 default: 330 return NPERR_GENERIC_ERROR; 331 } 294 332 } 295 333 … … 309 347 } 310 348 311 case NPNVToolkit: {312 *((uint32 *)value) = 0;313 return NPERR_NO_ERROR;314 }315 316 case NPNVSupportsXEmbedBool: {317 *((uint32 *)value) = true;318 return NPERR_NO_ERROR;319 }320 321 349 #if ENABLE(NETSCAPE_PLUGIN_API) 322 350 case NPNVWindowNPObject: { … … 362 390 } 363 391 364 case NPNVjavascriptEnabledBool: {365 *((uint32 *)value) = true;366 return NPERR_NO_ERROR;367 }368 369 392 default: 370 return NPERR_GENERIC_ERROR;393 return getValueStatic(variable, value); 371 394 } 372 395 } … … 426 449 } 427 450 428 m_needsXEmbed = false; 429 if (m_plugin->pluginFuncs()->getvalue) 451 if (m_plugin->pluginFuncs()->getvalue) { 452 PluginView::setCurrentPluginView(this); 453 KJS::JSLock::DropAllLocks dropAllLocks; 454 setCallingPlugin(true); 430 455 m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginNeedsXEmbed, &m_needsXEmbed); 456 setCallingPlugin(false); 457 PluginView::setCurrentPluginView(0); 458 } 431 459 432 460 if (m_needsXEmbed) {
Note: See TracChangeset
for help on using the changeset viewer.