diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure index 18850d2e37..bfa098fbbc 100644 --- a/build/moz.configure/old.configure +++ b/build/moz.configure/old.configure @@ -164,6 +164,7 @@ def old_configure_options(*options): '--enable-negotiateauth', '--enable-nfc', '--enable-npapi', + '--enable-npapi-gtk2', '--enable-nspr-build', '--enable-official-branding', '--enable-official-vendor', diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 599466c6b3..61e56a9438 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -55,7 +55,12 @@ using namespace std; #include #include #include +#if (GTK_MAJOR_VERSION == 3) +#include +#endif +#ifdef MOZ_ENABLE_NPAPI_GTK2 #include "gtk2xtbin.h" +#endif #elif defined(OS_WIN) @@ -208,7 +213,9 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface, memset(&mWsInfo, 0, sizeof(mWsInfo)); #ifdef MOZ_WIDGET_GTK mWsInfo.display = nullptr; +#ifdef MOZ_ENABLE_NPAPI_GTK2 mXtClient.top_widget = nullptr; +#endif #else mWsInfo.display = DefaultXDisplay(); #endif @@ -620,15 +627,17 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue) NPWindowType newWindowType = windowed ? NPWindowTypeWindow : NPWindowTypeDrawable; #ifdef MOZ_WIDGET_GTK if (mWindow.type != newWindowType && mWsInfo.display) { - // plugin type has been changed but we already have a valid display - // so update it for the recent plugin mode - if (mXEmbed || !windowed) { - // Use default GTK display for XEmbed and windowless plugins - mWsInfo.display = DefaultXDisplay(); - } - else { - mWsInfo.display = xt_client_get_display(); - } + // plugin type has been changed but we already have a valid display + // so update it for the recent plugin mode +#ifdef MOZ_ENABLE_NPAPI_GTK2 + if (!mXEmbed && windowed) { + mWsInfo.display = xt_client_get_display(); + } else +#endif + { + // Use default GTK display for XEmbed and windowless plugins. + mWsInfo.display = DefaultXDisplay(); + } } #endif mWindow.type = newWindowType; @@ -1214,12 +1223,18 @@ bool PluginInstanceChild::CreateWindow(const NPRemoteWindow& aWindow) if (mXEmbed) { mWindow.window = reinterpret_cast(aWindow.window); } +#ifdef MOZ_ENABLE_NPAPI_GTK2 else { Window browserSocket = (Window)(aWindow.window); xt_client_init(&mXtClient, mWsInfo.visual, mWsInfo.colormap, mWsInfo.depth); xt_client_create(&mXtClient, browserSocket, mWindow.width, mWindow.height); mWindow.window = (void *)XtWindow(mXtClient.child_widget); - } + } +#else + else { + mWindow.window = reinterpret_cast(aWindow.window); + } +#endif #else mWindow.window = reinterpret_cast(aWindow.window); #endif @@ -1239,7 +1254,7 @@ void PluginInstanceChild::DeleteWindow() if (!mWindow.window) return; -#ifdef MOZ_WIDGET_GTK +#ifdef MOZ_ENABLE_NPAPI_GTK2 if (mXtClient.top_widget) { xt_client_unrealize(&mXtClient); xt_client_destroy(&mXtClient); @@ -1321,7 +1336,7 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow) CreateWindow(aWindow); } -#ifdef MOZ_WIDGET_GTK +#ifdef MOZ_ENABLE_NPAPI_GTK2 if (mXEmbed && gtk_check_version(2,18,7) != nullptr) { // older if (aWindow.type == NPWindowTypeWindow) { GdkWindow* socket_window = gdk_window_lookup(static_cast(aWindow.window)); @@ -1456,19 +1471,27 @@ PluginInstanceChild::Initialize() if (mWindow.type == NPWindowTypeWindow) { AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(&mXEmbed, &rv); +#ifdef MOZ_ENABLE_NPAPI_GTK2 // Set up Xt loop for windowed plugins without XEmbed support if (!mXEmbed) { xt_client_xloop_create(); } +#endif } - // Use default GTK display for XEmbed and windowless plugins + // Use default GTK display for XEmbed and windowless plugins. if (mXEmbed || mWindow.type != NPWindowTypeWindow) { mWsInfo.display = DefaultXDisplay(); } +#ifdef MOZ_ENABLE_NPAPI_GTK2 else { mWsInfo.display = xt_client_get_display(); } +#else + else { + mWsInfo.display = DefaultXDisplay(); + } +#endif #endif return true; @@ -4656,7 +4679,7 @@ PluginInstanceChild::Destroy() mPendingAsyncCalls.Clear(); -#ifdef MOZ_WIDGET_GTK +#ifdef MOZ_ENABLE_NPAPI_GTK2 if (mWindow.type == NPWindowTypeWindow && !mXEmbed) { xt_client_xloop_destroy(); } diff --git a/dom/plugins/ipc/PluginInstanceChild.h b/dom/plugins/ipc/PluginInstanceChild.h index ec8a7675ef..57b88a30fb 100644 --- a/dom/plugins/ipc/PluginInstanceChild.h +++ b/dom/plugins/ipc/PluginInstanceChild.h @@ -36,7 +36,7 @@ #include -#ifdef MOZ_WIDGET_GTK +#ifdef MOZ_ENABLE_NPAPI_GTK2 #include "gtk2xtbin.h" #endif @@ -462,6 +462,8 @@ private: NPSetWindowCallbackStruct mWsInfo; #ifdef MOZ_WIDGET_GTK bool mXEmbed; +#endif +#ifdef MOZ_ENABLE_NPAPI_GTK2 XtClient mXtClient; #endif #elif defined(OS_WIN) diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index 035a54c9a4..4bdaa613c5 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -12,6 +12,9 @@ #ifdef MOZ_WIDGET_GTK #include +#if (GTK_MAJOR_VERSION == 3) +#include +#endif #endif #include "nsIFile.h" @@ -1101,7 +1104,11 @@ _getvalue(NPP aNPP, return InstCast(aNPP)->NPN_GetValue(aVariable, aValue); } else { +#ifdef MOZ_ENABLE_NPAPI_GTK2 *(void **)aValue = xt_client_get_display(); +#else + *(void **)aValue = DefaultXDisplay(); +#endif } return NPERR_NO_ERROR; } diff --git a/dom/plugins/ipc/moz.build b/dom/plugins/ipc/moz.build index 9afa6f298e..5bc3474413 100644 --- a/dom/plugins/ipc/moz.build +++ b/dom/plugins/ipc/moz.build @@ -143,11 +143,13 @@ LOCAL_INCLUDES += [ DEFINES['FORCE_PR_LOG'] = True -if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gtk3': - CXXFLAGS += CONFIG['TK_CFLAGS'] -else: +if (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3' and + CONFIG['MOZ_ENABLE_NPAPI'] and + CONFIG['MOZ_ENABLE_NPAPI_GTK2']): # Force build against gtk+2 for struct offsets and such. CXXFLAGS += CONFIG['MOZ_GTK2_CFLAGS'] +else: + CXXFLAGS += CONFIG['TK_CFLAGS'] CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] diff --git a/old-configure.in b/old-configure.in index 2eccf92eaf..3832889919 100644 --- a/old-configure.in +++ b/old-configure.in @@ -2146,12 +2146,26 @@ MOZ_ARG_DISABLE_BOOL(npapi, MOZ_ENABLE_NPAPI=, MOZ_ENABLE_NPAPI=1) +MOZ_ENABLE_NPAPI_GTK2=1 + +MOZ_ARG_DISABLE_BOOL(npapi-gtk2, +[ --disable-npapi-gtk2 Disable GTK2 support for NPAPI plugins ], + MOZ_ENABLE_NPAPI_GTK2= + MOZ_DISABLE_NPAPI_GTK2=1, + MOZ_ENABLE_NPAPI_GTK2=1) + if test "$MOZ_ENABLE_NPAPI" then AC_DEFINE(MOZ_ENABLE_NPAPI) fi +if test "$MOZ_ENABLE_NPAPI" -a "$MOZ_ENABLE_NPAPI_GTK2" +then + AC_DEFINE(MOZ_ENABLE_NPAPI_GTK2) +fi + AC_SUBST(MOZ_ENABLE_NPAPI) +AC_SUBST(MOZ_ENABLE_NPAPI_GTK2) dnl ======================================================== dnl = @@ -2200,6 +2214,10 @@ gtk*) ;; esac +if test "$MOZ_WIDGET_TOOLKIT" = gtk2 -a "$MOZ_DISABLE_NPAPI_GTK2"; then + AC_MSG_ERROR([--disable-npapi-gtk2 cannot be used with GTK2 browser builds.]) +fi + if test "$COMPILE_ENVIRONMENT"; then if test "$MOZ_WIDGET_TOOLKIT" = gtk3; then PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 $GDK_PACKAGES) @@ -2210,8 +2228,9 @@ if test "$COMPILE_ENVIRONMENT"; then dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h. AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED) GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32 - dnl We want to check GTK2 packages if NPAPI is enabled, even if building with GTK3. - if test "$MOZ_ENABLE_NPAPI"; then + dnl GTK2 NPAPI plugin support needs GTK2 packages, even when the browser + dnl itself is built against GTK3. + if test "$MOZ_ENABLE_NPAPI" -a "$MOZ_ENABLE_NPAPI_GTK2"; then MOZ_CHECK_GTK2=1 fi fi @@ -2229,7 +2248,7 @@ if test "$COMPILE_ENVIRONMENT"; then if test "$MOZ_CHECK_GTK2"; then PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 >= $GLIB_VERSION gobject-2.0 $GDK_PACKAGES, , - [AC_MSG_ERROR([ * * * Could not find gtk+-2.0. Required for NPAPI plugins. To build without NPAPI, add --disable-npapi to your .mozconfig and clobber.])]) + [AC_MSG_ERROR([ * * * Could not find gtk+-2.0. Required for GTK2 browser builds and GTK2 NPAPI plugin support. To build a GTK3 browser with NPAPI but without GTK2 NPAPI plugin support, add --disable-npapi-gtk2 to your .mozconfig and clobber.])]) MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS" fi fi diff --git a/widget/gtk/mozgtk/moz.build b/widget/gtk/mozgtk/moz.build index 43f94aabfe..99d10056d8 100644 --- a/widget/gtk/mozgtk/moz.build +++ b/widget/gtk/mozgtk/moz.build @@ -3,4 +3,7 @@ # 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/. -DIRS += ['stub', 'gtk2', 'gtk3'] +DIRS += ['stub', 'gtk3'] + +if CONFIG['MOZ_ENABLE_NPAPI_GTK2']: + DIRS += ['gtk2'] diff --git a/widget/gtk/mozgtk/stub/moz.build b/widget/gtk/mozgtk/stub/moz.build index 7713bfaafd..c8e35b37ca 100644 --- a/widget/gtk/mozgtk/stub/moz.build +++ b/widget/gtk/mozgtk/stub/moz.build @@ -7,9 +7,12 @@ SOURCES += [ '../mozgtk.c', ] -for var in ('COMMON_SYMBOLS', 'GTK2_SYMBOLS', 'GTK3_SYMBOLS'): +for var in ('COMMON_SYMBOLS', 'GTK3_SYMBOLS'): DEFINES[var] = True +if CONFIG['MOZ_ENABLE_NPAPI_GTK2']: + DEFINES['GTK2_SYMBOLS'] = True + SharedLibrary('mozgtk_stub') SONAME = 'mozgtk' diff --git a/widget/moz.build b/widget/moz.build index 2d40447821..6b49e35270 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -52,7 +52,8 @@ if toolkit in ('cocoa', 'gtk2', 'gtk3'): if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: DIRS += ['gtk'] - if CONFIG['MOZ_X11'] and CONFIG['MOZ_ENABLE_NPAPI']: + if (CONFIG['MOZ_X11'] and CONFIG['MOZ_ENABLE_NPAPI'] and + CONFIG['MOZ_ENABLE_NPAPI_GTK2']): DIRS += ['gtkxtbin'] XPIDL_SOURCES += [