From 0e1e833b40484fe21b93d4f1b53b9420637e2ed3 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Tue, 12 Jul 2016 20:28:31 -0400 Subject: [PATCH] Bug 1286317 - part 2 - remove Qt widget usage from plugins. r=jrmuizel --- dom/ipc/ContentChild.cpp | 9 -- dom/ipc/moz.build | 2 +- dom/moz.build | 2 +- dom/plugins/base/moz.build | 4 - dom/plugins/base/nsNPAPIPlugin.cpp | 13 +-- dom/plugins/base/nsPluginInstanceOwner.cpp | 4 +- dom/plugins/base/nsPluginInstanceOwner.h | 11 +-- dom/plugins/base/nsPluginNativeWindowQt.cpp | 89 ------------------- .../base/nsPluginStreamListenerPeer.cpp | 2 +- dom/plugins/ipc/PluginHelperQt.h | 16 ---- dom/plugins/ipc/PluginInstanceChild.cpp | 5 -- dom/plugins/ipc/PluginInstanceParent.cpp | 3 - dom/plugins/ipc/PluginMessageUtils.h | 2 +- dom/plugins/ipc/PluginModuleChild.cpp | 58 +----------- dom/plugins/ipc/PluginModuleChild.h | 11 --- dom/plugins/ipc/PluginModuleParent.cpp | 17 +--- dom/system/moz.build | 4 +- dom/xbl/builtin/moz.build | 2 +- 18 files changed, 12 insertions(+), 242 deletions(-) delete mode 100644 dom/plugins/base/nsPluginNativeWindowQt.cpp delete mode 100644 dom/plugins/ipc/PluginHelperQt.h diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 0a08967f48ce..4ba0bdee75f7 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -8,10 +8,6 @@ #include #endif -#ifdef MOZ_WIDGET_QT -#include "nsQAppInstance.h" -#endif - #include "ContentChild.h" #include "BlobChild.h" @@ -619,11 +615,6 @@ ContentChild::Init(MessageLoop* aIOLoop, } #endif -#ifdef MOZ_WIDGET_QT - // sigh, seriously - nsQAppInstance::AddRef(); -#endif - #ifdef MOZ_X11 // Do this after initializing GDK, or GDK will install its own handler. XRE_InstallX11ErrorHandler(); diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index c69b83d49be6..9b943c6448c1 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -168,7 +168,7 @@ if CONFIG['OS_ARCH'] != 'WINNT': DEFINES['BIN_SUFFIX'] = '"%s"' % CONFIG['BIN_SUFFIX'] -if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk', 'qt'): +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk'): DEFINES['MOZ_ENABLE_FREETYPE'] = True if CONFIG['MOZ_TOOLKIT_SEARCH']: diff --git a/dom/moz.build b/dom/moz.build index 5711c2c721c8..cf9f2f119472 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -160,6 +160,6 @@ TEST_DIRS += [ 'imptests', ] -if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'cocoa', 'windows', 'android', 'qt'): +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'cocoa', 'windows', 'android'): TEST_DIRS += ['plugins/test'] diff --git a/dom/plugins/base/moz.build b/dom/plugins/base/moz.build index 21184421e9ea..1aeb4167c0bb 100644 --- a/dom/plugins/base/moz.build +++ b/dom/plugins/base/moz.build @@ -77,10 +77,6 @@ else: SOURCES += [ 'nsPluginNativeWindowGtk.cpp', ] - elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': - UNIFIED_SOURCES += [ - 'nsPluginNativeWindowQt.cpp', - ] else: UNIFIED_SOURCES += [ 'nsPluginNativeWindow.cpp', diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 7bceb59dab01..e9021e5084c2 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -1811,7 +1811,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) return NPERR_GENERIC_ERROR; #endif -#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT) +#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) case NPNVnetscapeWindow: { if (!npp || !npp->ndata) return NPERR_INVALID_INSTANCE_ERROR; @@ -1860,10 +1860,6 @@ _getvalue(NPP npp, NPNVariable variable, void *result) *((NPNToolkitType*)result) = NPNVGtk2; #endif -#ifdef MOZ_WIDGET_QT - /* Fake toolkit so flash plugin works */ - *((NPNToolkitType*)result) = NPNVGtk2; -#endif if (*(NPNToolkitType*)result) return NPERR_NO_ERROR; @@ -1873,11 +1869,6 @@ _getvalue(NPP npp, NPNVariable variable, void *result) case NPNVSupportsXEmbedBool: { #ifdef MOZ_WIDGET_GTK *(NPBool*)result = true; -#elif defined(MOZ_WIDGET_QT) - // Desktop Flash fail to initialize if browser does not support NPNVSupportsXEmbedBool - // even when wmode!=windowed, lets return fake support - fprintf(stderr, "Fake support for XEmbed plugins in Qt port\n"); - *(NPBool*)result = true; #else *(NPBool*)result = false; #endif @@ -1898,7 +1889,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result) case NPNVSupportsWindowless: { #if defined(XP_WIN) || defined(XP_MACOSX) || \ - (defined(MOZ_X11) && (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT))) + (defined(MOZ_X11) && defined(MOZ_WIDGET_GTK)) *(NPBool*)result = true; #else *(NPBool*)result = false; diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 3d8001f06e8a..3730c2fb3c7a 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -763,7 +763,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) } return NS_OK; -#elif (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11) +#elif defined(MOZ_WIDGET_GTK) && defined(MOZ_X11) // X11 window managers want the toplevel window for WM_TRANSIENT_FOR. nsIWidget* win = mPluginFrame->GetNearestWidget(); if (!win) @@ -2616,8 +2616,6 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent) } #ifdef MOZ_WIDGET_GTK Window root = GDK_ROOT_WINDOW(); -#elif defined(MOZ_WIDGET_QT) - Window root = RootWindowOfScreen(DefaultScreenOfDisplay(mozilla::DefaultXDisplay())); #else Window root = None; // Could XQueryTree, but this is not important. #endif diff --git a/dom/plugins/base/nsPluginInstanceOwner.h b/dom/plugins/base/nsPluginInstanceOwner.h index f20882cbd46f..9b71f3de9f16 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.h +++ b/dom/plugins/base/nsPluginInstanceOwner.h @@ -46,12 +46,8 @@ class PuppetWidget; using mozilla::widget::PuppetWidget; #ifdef MOZ_X11 -#ifdef MOZ_WIDGET_QT -#include "gfxQtNativeRenderer.h" -#else #include "gfxXlibNativeRenderer.h" #endif -#endif class nsPluginInstanceOwner final : public nsIPluginInstanceOwner , public nsIDOMEventListener @@ -395,12 +391,7 @@ private: int mLastMouseDownButtonType; #ifdef MOZ_X11 - class Renderer -#if defined(MOZ_WIDGET_QT) - : public gfxQtNativeRenderer -#else - : public gfxXlibNativeRenderer -#endif + class Renderer : public gfxXlibNativeRenderer { public: Renderer(NPWindow* aWindow, nsPluginInstanceOwner* aInstanceOwner, diff --git a/dom/plugins/base/nsPluginNativeWindowQt.cpp b/dom/plugins/base/nsPluginNativeWindowQt.cpp deleted file mode 100644 index 3249842f4c31..000000000000 --- a/dom/plugins/base/nsPluginNativeWindowQt.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:expandtab:shiftwidth=2:tabstop=2: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/** - * This file is the Qt implementation of plugin native window. - */ - -#include "nsDebug.h" -#include "nsPluginNativeWindow.h" -#include "npapi.h" - -/** - * Qt implementation of plugin window - */ -class nsPluginNativeWindowQt : public nsPluginNativeWindow -{ -public: - nsPluginNativeWindowQt(); - virtual ~nsPluginNativeWindowQt(); - - virtual nsresult CallSetWindow(RefPtr &aPluginInstance); -private: - - NPSetWindowCallbackStruct mWsInfo; -}; - -nsPluginNativeWindowQt::nsPluginNativeWindowQt() : nsPluginNativeWindow() -{ - //Initialize member variables -#ifdef DEBUG - fprintf(stderr,"\n\n\nCreating plugin native window %p\n\n\n", (void *) this); -#endif - window = nullptr; - x = 0; - y = 0; - width = 0; - height = 0; - memset(&clipRect, 0, sizeof(clipRect)); - ws_info = &mWsInfo; - type = NPWindowTypeWindow; - mWsInfo.type = 0; -#if defined(MOZ_X11) - mWsInfo.display = nullptr; - mWsInfo.visual = nullptr; - mWsInfo.colormap = 0; - mWsInfo.depth = 0; -#endif -} - -nsPluginNativeWindowQt::~nsPluginNativeWindowQt() -{ -#ifdef DEBUG - fprintf(stderr,"\n\n\nDestoying plugin native window %p\n\n\n", (void *) this); -#endif -} - -nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow **aPluginNativeWindow) -{ - NS_ENSURE_ARG_POINTER(aPluginNativeWindow); - *aPluginNativeWindow = new nsPluginNativeWindowQt(); - return NS_OK; -} - -nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow) -{ - NS_ENSURE_ARG_POINTER(aPluginNativeWindow); - nsPluginNativeWindowQt *p = (nsPluginNativeWindowQt *)aPluginNativeWindow; - delete p; - return NS_OK; -} - -nsresult nsPluginNativeWindowQt::CallSetWindow(RefPtr &aPluginInstance) -{ - if (aPluginInstance) { - if (type == NPWindowTypeWindow) { - return NS_ERROR_FAILURE; - } // NPWindowTypeWindow - aPluginInstance->SetWindow(this); - } - else if (mPluginInstance) - mPluginInstance->SetWindow(nullptr); - - SetPluginInstance(aPluginInstance); - return NS_OK; -} diff --git a/dom/plugins/base/nsPluginStreamListenerPeer.cpp b/dom/plugins/base/nsPluginStreamListenerPeer.cpp index 881e163fbaa7..aaee0943c584 100644 --- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp +++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp @@ -841,7 +841,7 @@ nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request, if (owner) { NPWindow* window = nullptr; owner->GetWindow(window); -#if (MOZ_WIDGET_GTK == 2) || defined(MOZ_WIDGET_QT) +#if (MOZ_WIDGET_GTK == 2) // Should call GetPluginPort() here. // This part is copied from nsPluginInstanceOwner::GetPluginPort(). nsCOMPtr widget; diff --git a/dom/plugins/ipc/PluginHelperQt.h b/dom/plugins/ipc/PluginHelperQt.h deleted file mode 100644 index b940431b7b54..000000000000 --- a/dom/plugins/ipc/PluginHelperQt.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef PluginHelperQt_h_ -#define PluginHelperQt_h_ - -class PluginHelperQt -{ -public: - static bool AnswerProcessSomeEvents(); -}; - -#endif // PluginHelperQt_h_ diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index bd633a394692..cacb087a53a3 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -54,9 +54,6 @@ using namespace std; #include #include "gtk2xtbin.h" -#elif defined(MOZ_WIDGET_QT) -#undef KeyPress -#undef KeyRelease #elif defined(OS_WIN) #include @@ -1386,8 +1383,6 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow) #elif defined(ANDROID) // TODO: Need Android impl -#elif defined(MOZ_WIDGET_QT) - // TODO: Need QT-nonX impl #elif defined(MOZ_WIDGET_UIKIT) // Don't care #else diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index 4c8f503c04a1..416cd87c540c 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -287,9 +287,6 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle* #elif defined(ANDROID) // TODO: Need Android impl int id; -#elif defined(MOZ_WIDGET_QT) - // TODO: Need Qt non X impl - int id; #else #warning Implement me #endif diff --git a/dom/plugins/ipc/PluginMessageUtils.h b/dom/plugins/ipc/PluginMessageUtils.h index 1f0d05ad67d5..a09e99944a29 100644 --- a/dom/plugins/ipc/PluginMessageUtils.h +++ b/dom/plugins/ipc/PluginMessageUtils.h @@ -102,7 +102,7 @@ struct NPRemoteWindow typedef HWND NativeWindowHandle; #elif defined(MOZ_X11) typedef XID NativeWindowHandle; -#elif defined(XP_DARWIN) || defined(ANDROID) || defined(MOZ_WIDGET_QT) +#elif defined(XP_DARWIN) || defined(ANDROID) typedef intptr_t NativeWindowHandle; // never actually used, will always be 0 #else #error Need NativeWindowHandle for this platform diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index 6568d55b2c71..72a16d226a3f 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -4,12 +4,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifdef MOZ_WIDGET_QT -#include -#include "nsQAppInstance.h" -#include "NestedLoopTimer.h" -#endif - #include "mozilla/plugins/PluginModuleChild.h" /* This must occur *after* plugins/PluginModuleChild.h to avoid typedefs conflicts. */ @@ -73,12 +67,6 @@ namespace { PluginModuleChild* gChromeInstance = nullptr; } // namespace -#ifdef MOZ_WIDGET_QT -typedef void (*_gtk_init_fn)(int argc, char **argv); -static _gtk_init_fn s_gtk_init = nullptr; -static PRLibrary *sGtkLib = nullptr; -#endif - #ifdef XP_WIN // Hooking CreateFileW for protected-mode magic static WindowsDllInterceptor sKernel32Intercept; @@ -131,8 +119,6 @@ PluginModuleChild::PluginModuleChild(bool aIsChrome) , mGetEntryPointsFunc(0) #elif defined(MOZ_WIDGET_GTK) , mNestedLoopTimerId(0) -#elif defined(MOZ_WIDGET_QT) - , mNestedLoopTimerObject(0) #endif #ifdef OS_WIN , mNestedEventHook(nullptr) @@ -548,26 +534,6 @@ PluginModuleChild::ExitedCxxStack() g_source_remove(mNestedLoopTimerId); mNestedLoopTimerId = 0; } -#elif defined (MOZ_WIDGET_QT) - -void -PluginModuleChild::EnteredCxxStack() -{ - MOZ_ASSERT(mNestedLoopTimerObject == nullptr, - "previous timer not descheduled"); - mNestedLoopTimerObject = new NestedLoopTimer(this); - QTimer::singleShot(kNestedLoopDetectorIntervalMs, - mNestedLoopTimerObject, SLOT(timeOut())); -} - -void -PluginModuleChild::ExitedCxxStack() -{ - MOZ_ASSERT(mNestedLoopTimerObject != nullptr, - "nested loop timeout not scheduled"); - delete mNestedLoopTimerObject; - mNestedLoopTimerObject = nullptr; -} #endif @@ -628,19 +594,6 @@ PluginModuleChild::InitGraphics() real_gtk_plug_embedded = *embedded; *embedded = wrap_gtk_plug_embedded; -#elif defined(MOZ_WIDGET_QT) - nsQAppInstance::AddRef(); - // Work around plugins that don't interact well without gtk initialized - // see bug 566845 -#if defined(MOZ_X11) - if (!sGtkLib) - sGtkLib = PR_LoadLibrary("libgtk-x11-2.0.so.0"); -#endif - if (sGtkLib) { - s_gtk_init = (_gtk_init_fn)PR_FindFunctionSymbol(sGtkLib, "gtk_init"); - if (s_gtk_init) - s_gtk_init(0, 0); - } #else // may not be necessary on all platforms #endif @@ -654,15 +607,6 @@ PluginModuleChild::InitGraphics() void PluginModuleChild::DeinitGraphics() { -#ifdef MOZ_WIDGET_QT - nsQAppInstance::Release(); - if (sGtkLib) { - PR_UnloadLibrary(sGtkLib); - sGtkLib = nullptr; - s_gtk_init = nullptr; - } -#endif - #if defined(MOZ_X11) && defined(NS_FREE_PERMANENT_DATA) // We free some data off of XDisplay close hooks, ensure they're // run. Closing the display is pretty scary, so we only do it to @@ -1149,7 +1093,7 @@ _getvalue(NPP aNPP, switch (aVariable) { // Copied from nsNPAPIPlugin.cpp case NPNVToolkit: -#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT) +#if defined(MOZ_WIDGET_GTK) *static_cast(aValue) = NPNVGtk2; return NPERR_NO_ERROR; #endif diff --git a/dom/plugins/ipc/PluginModuleChild.h b/dom/plugins/ipc/PluginModuleChild.h index d342706c0bf8..0f7ec11605ec 100644 --- a/dom/plugins/ipc/PluginModuleChild.h +++ b/dom/plugins/ipc/PluginModuleChild.h @@ -52,11 +52,6 @@ class PCrashReporterChild; namespace plugins { -#ifdef MOZ_WIDGET_QT -class NestedLoopTimer; -static const int kNestedLoopDetectorIntervalMs = 90; -#endif - class PluginInstanceChild; class PluginModuleChild : public PPluginModuleChild @@ -261,10 +256,6 @@ private: static gboolean DetectNestedEventLoop(gpointer data); static gboolean ProcessBrowserEvents(gpointer data); - virtual void EnteredCxxStack() override; - virtual void ExitedCxxStack() override; -#elif defined(MOZ_WIDGET_QT) - virtual void EnteredCxxStack() override; virtual void ExitedCxxStack() override; #endif @@ -328,8 +319,6 @@ private: // MessagePumpForUI. int mTopLoopDepth; # endif -#elif defined (MOZ_WIDGET_QT) - NestedLoopTimer *mNestedLoopTimerObject; #endif public: // called by PluginInstanceChild diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 03d4cbdc009a..2eaad73c2844 100755 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -4,10 +4,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifdef MOZ_WIDGET_QT -#include "PluginHelperQt.h" -#endif - #include "mozilla/plugins/PluginModuleParent.h" #include "base/process_util.h" @@ -2859,18 +2855,7 @@ PluginModuleParent::ContentsScaleFactorChanged(NPP instance, double aContentsSca } #endif // #if defined(XP_MACOSX) -#if defined(MOZ_WIDGET_QT) -bool -PluginModuleParent::AnswerProcessSomeEvents() -{ - PLUGIN_LOG_DEBUG(("Spinning mini nested loop ...")); - PluginHelperQt::AnswerProcessSomeEvents(); - PLUGIN_LOG_DEBUG(("... quitting mini nested loop")); - - return true; -} - -#elif defined(XP_MACOSX) +#if defined(XP_MACOSX) bool PluginModuleParent::AnswerProcessSomeEvents() { diff --git a/dom/system/moz.build b/dom/system/moz.build index a5f152acc98d..b5929bc09490 100644 --- a/dom/system/moz.build +++ b/dom/system/moz.build @@ -6,9 +6,7 @@ toolkit = CONFIG['MOZ_WIDGET_TOOLKIT'] -if toolkit == 'qt': - DIRS += ['qt'] -elif toolkit == 'windows': +if toolkit == 'windows': DIRS += ['windows'] elif toolkit == 'cocoa': DIRS += ['mac'] diff --git a/dom/xbl/builtin/moz.build b/dom/xbl/builtin/moz.build index 8a3539ba79d3..2f4a857879dd 100644 --- a/dom/xbl/builtin/moz.build +++ b/dom/xbl/builtin/moz.build @@ -10,7 +10,7 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': DIRS += ['mac'] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': DIRS += ['android'] -elif CONFIG['MOZ_WIDGET_TOOLKIT'] in ('qt', 'gtk2', 'gtk3'): +elif CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'): DIRS += ['unix'] else: DIRS += ['emacs']