Skip to content

Commit

Permalink
Bug 1286317 - part 2 - remove Qt widget usage from plugins. r=jrmuizel
Browse files Browse the repository at this point in the history
  • Loading branch information
lsalzman committed Jul 13, 2016
1 parent 16ca322 commit 0e1e833
Show file tree
Hide file tree
Showing 18 changed files with 12 additions and 242 deletions.
9 changes: 0 additions & 9 deletions dom/ipc/ContentChild.cpp
Expand Up @@ -8,10 +8,6 @@
#include <gtk/gtk.h>
#endif

#ifdef MOZ_WIDGET_QT
#include "nsQAppInstance.h"
#endif

#include "ContentChild.h"

#include "BlobChild.h"
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/moz.build
Expand Up @@ -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']:
Expand Down
2 changes: 1 addition & 1 deletion dom/moz.build
Expand Up @@ -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']

4 changes: 0 additions & 4 deletions dom/plugins/base/moz.build
Expand Up @@ -77,10 +77,6 @@ else:
SOURCES += [
'nsPluginNativeWindowGtk.cpp',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
UNIFIED_SOURCES += [
'nsPluginNativeWindowQt.cpp',
]
else:
UNIFIED_SOURCES += [
'nsPluginNativeWindow.cpp',
Expand Down
13 changes: 2 additions & 11 deletions dom/plugins/base/nsNPAPIPlugin.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions dom/plugins/base/nsPluginInstanceOwner.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions dom/plugins/base/nsPluginInstanceOwner.h
Expand Up @@ -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
Expand Down Expand Up @@ -395,12 +391,7 @@ class nsPluginInstanceOwner final : public nsIPluginInstanceOwner
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,
Expand Down
89 changes: 0 additions & 89 deletions dom/plugins/base/nsPluginNativeWindowQt.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion dom/plugins/base/nsPluginStreamListenerPeer.cpp
Expand Up @@ -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<nsIWidget> widget;
Expand Down
16 changes: 0 additions & 16 deletions dom/plugins/ipc/PluginHelperQt.h

This file was deleted.

5 changes: 0 additions & 5 deletions dom/plugins/ipc/PluginInstanceChild.cpp
Expand Up @@ -54,9 +54,6 @@ using namespace std;
#include <gdk/gdk.h>
#include "gtk2xtbin.h"

#elif defined(MOZ_WIDGET_QT)
#undef KeyPress
#undef KeyRelease
#elif defined(OS_WIN)

#include <windows.h>
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions dom/plugins/ipc/PluginInstanceParent.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dom/plugins/ipc/PluginMessageUtils.h
Expand Up @@ -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
Expand Down
58 changes: 1 addition & 57 deletions dom/plugins/ipc/PluginModuleChild.cpp
Expand Up @@ -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 <QtCore/QTimer>
#include "nsQAppInstance.h"
#include "NestedLoopTimer.h"
#endif

#include "mozilla/plugins/PluginModuleChild.h"

/* This must occur *after* plugins/PluginModuleChild.h to avoid typedefs conflicts. */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<NPNToolkitType*>(aValue) = NPNVGtk2;
return NPERR_NO_ERROR;
#endif
Expand Down

0 comments on commit 0e1e833

Please sign in to comment.