Bug 1286317 - part 2 - remove Qt widget usage from plugins. r=jrmuizel

This commit is contained in:
Lee Salzman
2016-07-12 20:28:31 -04:00
parent 3fbabed619
commit dbd438bc8a
18 changed files with 12 additions and 242 deletions

View File

@@ -8,10 +8,6 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#endif #endif
#ifdef MOZ_WIDGET_QT
#include "nsQAppInstance.h"
#endif
#include "ContentChild.h" #include "ContentChild.h"
#include "BlobChild.h" #include "BlobChild.h"
@@ -619,11 +615,6 @@ ContentChild::Init(MessageLoop* aIOLoop,
} }
#endif #endif
#ifdef MOZ_WIDGET_QT
// sigh, seriously
nsQAppInstance::AddRef();
#endif
#ifdef MOZ_X11 #ifdef MOZ_X11
// Do this after initializing GDK, or GDK will install its own handler. // Do this after initializing GDK, or GDK will install its own handler.
XRE_InstallX11ErrorHandler(); XRE_InstallX11ErrorHandler();

View File

@@ -168,7 +168,7 @@ if CONFIG['OS_ARCH'] != 'WINNT':
DEFINES['BIN_SUFFIX'] = '"%s"' % CONFIG['BIN_SUFFIX'] 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 DEFINES['MOZ_ENABLE_FREETYPE'] = True
if CONFIG['MOZ_TOOLKIT_SEARCH']: if CONFIG['MOZ_TOOLKIT_SEARCH']:

View File

@@ -160,6 +160,6 @@ TEST_DIRS += [
'imptests', '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'] TEST_DIRS += ['plugins/test']

View File

@@ -77,10 +77,6 @@ else:
SOURCES += [ SOURCES += [
'nsPluginNativeWindowGtk.cpp', 'nsPluginNativeWindowGtk.cpp',
] ]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
UNIFIED_SOURCES += [
'nsPluginNativeWindowQt.cpp',
]
else: else:
UNIFIED_SOURCES += [ UNIFIED_SOURCES += [
'nsPluginNativeWindow.cpp', 'nsPluginNativeWindow.cpp',

View File

@@ -1811,7 +1811,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
return NPERR_GENERIC_ERROR; return NPERR_GENERIC_ERROR;
#endif #endif
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT) #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
case NPNVnetscapeWindow: { case NPNVnetscapeWindow: {
if (!npp || !npp->ndata) if (!npp || !npp->ndata)
return NPERR_INVALID_INSTANCE_ERROR; return NPERR_INVALID_INSTANCE_ERROR;
@@ -1860,10 +1860,6 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
*((NPNToolkitType*)result) = NPNVGtk2; *((NPNToolkitType*)result) = NPNVGtk2;
#endif #endif
#ifdef MOZ_WIDGET_QT
/* Fake toolkit so flash plugin works */
*((NPNToolkitType*)result) = NPNVGtk2;
#endif
if (*(NPNToolkitType*)result) if (*(NPNToolkitType*)result)
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
@@ -1873,11 +1869,6 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
case NPNVSupportsXEmbedBool: { case NPNVSupportsXEmbedBool: {
#ifdef MOZ_WIDGET_GTK #ifdef MOZ_WIDGET_GTK
*(NPBool*)result = true; *(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 #else
*(NPBool*)result = false; *(NPBool*)result = false;
#endif #endif
@@ -1898,7 +1889,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
case NPNVSupportsWindowless: { case NPNVSupportsWindowless: {
#if defined(XP_WIN) || defined(XP_MACOSX) || \ #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; *(NPBool*)result = true;
#else #else
*(NPBool*)result = false; *(NPBool*)result = false;

View File

@@ -763,7 +763,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value)
} }
return NS_OK; 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. // X11 window managers want the toplevel window for WM_TRANSIENT_FOR.
nsIWidget* win = mPluginFrame->GetNearestWidget(); nsIWidget* win = mPluginFrame->GetNearestWidget();
if (!win) if (!win)
@@ -2616,8 +2616,6 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
} }
#ifdef MOZ_WIDGET_GTK #ifdef MOZ_WIDGET_GTK
Window root = GDK_ROOT_WINDOW(); Window root = GDK_ROOT_WINDOW();
#elif defined(MOZ_WIDGET_QT)
Window root = RootWindowOfScreen(DefaultScreenOfDisplay(mozilla::DefaultXDisplay()));
#else #else
Window root = None; // Could XQueryTree, but this is not important. Window root = None; // Could XQueryTree, but this is not important.
#endif #endif

View File

@@ -46,12 +46,8 @@ class PuppetWidget;
using mozilla::widget::PuppetWidget; using mozilla::widget::PuppetWidget;
#ifdef MOZ_X11 #ifdef MOZ_X11
#ifdef MOZ_WIDGET_QT
#include "gfxQtNativeRenderer.h"
#else
#include "gfxXlibNativeRenderer.h" #include "gfxXlibNativeRenderer.h"
#endif #endif
#endif
class nsPluginInstanceOwner final : public nsIPluginInstanceOwner class nsPluginInstanceOwner final : public nsIPluginInstanceOwner
, public nsIDOMEventListener , public nsIDOMEventListener
@@ -395,12 +391,7 @@ private:
int mLastMouseDownButtonType; int mLastMouseDownButtonType;
#ifdef MOZ_X11 #ifdef MOZ_X11
class Renderer class Renderer : public gfxXlibNativeRenderer
#if defined(MOZ_WIDGET_QT)
: public gfxQtNativeRenderer
#else
: public gfxXlibNativeRenderer
#endif
{ {
public: public:
Renderer(NPWindow* aWindow, nsPluginInstanceOwner* aInstanceOwner, Renderer(NPWindow* aWindow, nsPluginInstanceOwner* aInstanceOwner,

View File

@@ -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<nsNPAPIPluginInstance> &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<nsNPAPIPluginInstance> &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;
}

View File

@@ -841,7 +841,7 @@ nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request,
if (owner) { if (owner) {
NPWindow* window = nullptr; NPWindow* window = nullptr;
owner->GetWindow(window); owner->GetWindow(window);
#if (MOZ_WIDGET_GTK == 2) || defined(MOZ_WIDGET_QT) #if (MOZ_WIDGET_GTK == 2)
// Should call GetPluginPort() here. // Should call GetPluginPort() here.
// This part is copied from nsPluginInstanceOwner::GetPluginPort(). // This part is copied from nsPluginInstanceOwner::GetPluginPort().
nsCOMPtr<nsIWidget> widget; nsCOMPtr<nsIWidget> widget;

View File

@@ -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_

View File

@@ -54,9 +54,6 @@ using namespace std;
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include "gtk2xtbin.h" #include "gtk2xtbin.h"
#elif defined(MOZ_WIDGET_QT)
#undef KeyPress
#undef KeyRelease
#elif defined(OS_WIN) #elif defined(OS_WIN)
#include <windows.h> #include <windows.h>
@@ -1386,8 +1383,6 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
#elif defined(ANDROID) #elif defined(ANDROID)
// TODO: Need Android impl // TODO: Need Android impl
#elif defined(MOZ_WIDGET_QT)
// TODO: Need QT-nonX impl
#elif defined(MOZ_WIDGET_UIKIT) #elif defined(MOZ_WIDGET_UIKIT)
// Don't care // Don't care
#else #else

View File

@@ -287,9 +287,6 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle*
#elif defined(ANDROID) #elif defined(ANDROID)
// TODO: Need Android impl // TODO: Need Android impl
int id; int id;
#elif defined(MOZ_WIDGET_QT)
// TODO: Need Qt non X impl
int id;
#else #else
#warning Implement me #warning Implement me
#endif #endif

View File

@@ -102,7 +102,7 @@ struct NPRemoteWindow
typedef HWND NativeWindowHandle; typedef HWND NativeWindowHandle;
#elif defined(MOZ_X11) #elif defined(MOZ_X11)
typedef XID NativeWindowHandle; 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 typedef intptr_t NativeWindowHandle; // never actually used, will always be 0
#else #else
#error Need NativeWindowHandle for this platform #error Need NativeWindowHandle for this platform

View File

@@ -4,12 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef MOZ_WIDGET_QT
#include <QtCore/QTimer>
#include "nsQAppInstance.h"
#include "NestedLoopTimer.h"
#endif
#include "mozilla/plugins/PluginModuleChild.h" #include "mozilla/plugins/PluginModuleChild.h"
/* This must occur *after* plugins/PluginModuleChild.h to avoid typedefs conflicts. */ /* This must occur *after* plugins/PluginModuleChild.h to avoid typedefs conflicts. */
@@ -73,12 +67,6 @@ namespace {
PluginModuleChild* gChromeInstance = nullptr; PluginModuleChild* gChromeInstance = nullptr;
} // namespace } // 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 #ifdef XP_WIN
// Hooking CreateFileW for protected-mode magic // Hooking CreateFileW for protected-mode magic
static WindowsDllInterceptor sKernel32Intercept; static WindowsDllInterceptor sKernel32Intercept;
@@ -131,8 +119,6 @@ PluginModuleChild::PluginModuleChild(bool aIsChrome)
, mGetEntryPointsFunc(0) , mGetEntryPointsFunc(0)
#elif defined(MOZ_WIDGET_GTK) #elif defined(MOZ_WIDGET_GTK)
, mNestedLoopTimerId(0) , mNestedLoopTimerId(0)
#elif defined(MOZ_WIDGET_QT)
, mNestedLoopTimerObject(0)
#endif #endif
#ifdef OS_WIN #ifdef OS_WIN
, mNestedEventHook(nullptr) , mNestedEventHook(nullptr)
@@ -548,26 +534,6 @@ PluginModuleChild::ExitedCxxStack()
g_source_remove(mNestedLoopTimerId); g_source_remove(mNestedLoopTimerId);
mNestedLoopTimerId = 0; 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 #endif
@@ -628,19 +594,6 @@ PluginModuleChild::InitGraphics()
real_gtk_plug_embedded = *embedded; real_gtk_plug_embedded = *embedded;
*embedded = wrap_gtk_plug_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 #else
// may not be necessary on all platforms // may not be necessary on all platforms
#endif #endif
@@ -654,15 +607,6 @@ PluginModuleChild::InitGraphics()
void void
PluginModuleChild::DeinitGraphics() 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) #if defined(MOZ_X11) && defined(NS_FREE_PERMANENT_DATA)
// We free some data off of XDisplay close hooks, ensure they're // 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 // run. Closing the display is pretty scary, so we only do it to
@@ -1149,7 +1093,7 @@ _getvalue(NPP aNPP,
switch (aVariable) { switch (aVariable) {
// Copied from nsNPAPIPlugin.cpp // Copied from nsNPAPIPlugin.cpp
case NPNVToolkit: case NPNVToolkit:
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT) #if defined(MOZ_WIDGET_GTK)
*static_cast<NPNToolkitType*>(aValue) = NPNVGtk2; *static_cast<NPNToolkitType*>(aValue) = NPNVGtk2;
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
#endif #endif

View File

@@ -52,11 +52,6 @@ class PCrashReporterChild;
namespace plugins { namespace plugins {
#ifdef MOZ_WIDGET_QT
class NestedLoopTimer;
static const int kNestedLoopDetectorIntervalMs = 90;
#endif
class PluginInstanceChild; class PluginInstanceChild;
class PluginModuleChild : public PPluginModuleChild class PluginModuleChild : public PPluginModuleChild
@@ -261,10 +256,6 @@ private:
static gboolean DetectNestedEventLoop(gpointer data); static gboolean DetectNestedEventLoop(gpointer data);
static gboolean ProcessBrowserEvents(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 EnteredCxxStack() override;
virtual void ExitedCxxStack() override; virtual void ExitedCxxStack() override;
#endif #endif
@@ -328,8 +319,6 @@ private:
// MessagePumpForUI. // MessagePumpForUI.
int mTopLoopDepth; int mTopLoopDepth;
# endif # endif
#elif defined (MOZ_WIDGET_QT)
NestedLoopTimer *mNestedLoopTimerObject;
#endif #endif
public: // called by PluginInstanceChild public: // called by PluginInstanceChild

View File

@@ -4,10 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 "mozilla/plugins/PluginModuleParent.h"
#include "base/process_util.h" #include "base/process_util.h"
@@ -2859,18 +2855,7 @@ PluginModuleParent::ContentsScaleFactorChanged(NPP instance, double aContentsSca
} }
#endif // #if defined(XP_MACOSX) #endif // #if defined(XP_MACOSX)
#if defined(MOZ_WIDGET_QT) #if defined(XP_MACOSX)
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)
bool bool
PluginModuleParent::AnswerProcessSomeEvents() PluginModuleParent::AnswerProcessSomeEvents()
{ {

View File

@@ -6,9 +6,7 @@
toolkit = CONFIG['MOZ_WIDGET_TOOLKIT'] toolkit = CONFIG['MOZ_WIDGET_TOOLKIT']
if toolkit == 'qt': if toolkit == 'windows':
DIRS += ['qt']
elif toolkit == 'windows':
DIRS += ['windows'] DIRS += ['windows']
elif toolkit == 'cocoa': elif toolkit == 'cocoa':
DIRS += ['mac'] DIRS += ['mac']

View File

@@ -10,7 +10,7 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
DIRS += ['mac'] DIRS += ['mac']
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
DIRS += ['android'] DIRS += ['android']
elif CONFIG['MOZ_WIDGET_TOOLKIT'] in ('qt', 'gtk2', 'gtk3'): elif CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
DIRS += ['unix'] DIRS += ['unix']
else: else:
DIRS += ['emacs'] DIRS += ['emacs']