diff --git a/config/recurse.mk b/config/recurse.mk index c7bb531c6e..fad227aead 100644 --- a/config/recurse.mk +++ b/config/recurse.mk @@ -155,8 +155,10 @@ endif # Interdependencies that moz.build world don't know about yet for compilation. # Note some others are hardcoded or "guessed" in recursivemake.py and emitter.py ifeq ($(MOZ_WIDGET_TOOLKIT),gtk3) +ifdef MOZ_ENABLE_NPAPI toolkit/library/target: widget/gtk/mozgtk/gtk3/target endif +endif ifdef MOZ_LDAP_XPCOM ldap/target: security/target mozglue/build/target toolkit/library/target: ldap/target diff --git a/mozglue/build/gtk.c b/mozglue/build/gtk.c new file mode 100644 index 0000000000..b5b1b4be88 --- /dev/null +++ b/mozglue/build/gtk.c @@ -0,0 +1,19 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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/. */ + +#include "mozilla/Types.h" + +// Only define the following workaround when using GTK3, which we detect +// by checking if GTK3 stubs are not provided. +#include +// Bug 1271100 +// We need to trick system Cairo into not using the XShm extension due to +// a race condition in it that results in frequent BadAccess errors. Cairo +// relies upon XShmQueryExtension to initially detect if XShm is available. +// So we define our own stub that always indicates XShm not being present. +// mozgtk loads before libXext/libcairo and so this stub will take priority. +// Our tree usage goes through xcb and remains unaffected by this. +MFBT_API Bool XShmQueryExtension(Display* aDisplay) { return False; } diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build index 9197eda1bc..e291e472ae 100644 --- a/mozglue/build/moz.build +++ b/mozglue/build/moz.build @@ -15,6 +15,9 @@ SDK_LIBRARY = True if CONFIG['MOZ_ASAN']: SOURCES += ['AsanOptions.cpp'] +if not CONFIG['MOZ_ENABLE_NPAPI'] and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3': + SOURCES += ['gtk.c'] + if CONFIG['OS_TARGET'] == 'WINNT': DEFFILE = 'mozglue.def' # We'll break the DLL blocklist if we immediately load user32.dll diff --git a/old-configure.in b/old-configure.in index b5e4428dbd..ce3dd1b7f5 100644 --- a/old-configure.in +++ b/old-configure.in @@ -2122,6 +2122,24 @@ if test -z "$XULRUNNER_STUB_NAME"; then fi AC_SUBST(XULRUNNER_STUB_NAME) +dnl ======================================================== +dnl = NPAPI support +dnl ======================================================== + +MOZ_ENABLE_NPAPI=1 + +MOZ_ARG_DISABLE_BOOL(npapi, +[ --disable-npapi Disable NPAPI support ], + MOZ_ENABLE_NPAPI=, + MOZ_ENABLE_NPAPI=1) + +if test "$MOZ_ENABLE_NPAPI" +then + AC_DEFINE(MOZ_ENABLE_NPAPI) +fi + +AC_SUBST(MOZ_ENABLE_NPAPI) + dnl ======================================================== dnl = dnl = Toolkit Options @@ -2189,9 +2207,15 @@ 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 + MOZ_CHECK_GTK2=1 + fi fi if test "$MOZ_WIDGET_TOOLKIT" = gtk2; then GLIB_VERSION_MAX_ALLOWED=$GLIB_VERSION_MIN_REQUIRED + dnl Check GTK2 packages if we're building against GTK2, whether NPAPI is disabled or not. + MOZ_CHECK_GTK2=1 fi if test "$MOZ_ENABLE_GTK"; then if test "$MOZ_X11"; then @@ -2200,8 +2224,11 @@ if test "$COMPILE_ENVIRONMENT"; then AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED) AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED) - 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) + 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.])]) MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS" + fi fi if test "$MOZ_WIDGET_TOOLKIT" = gtk2; then TK_CFLAGS=$MOZ_GTK2_CFLAGS @@ -2491,24 +2518,6 @@ then fi AC_SUBST(MOZ_ENABLE_DBUS) -dnl ======================================================== -dnl = NPAPI support -dnl ======================================================== - -MOZ_ENABLE_NPAPI=1 - -MOZ_ARG_DISABLE_BOOL(npapi, -[ --disable-npapi Disable NPAPI support ], - MOZ_ENABLE_NPAPI=, - MOZ_ENABLE_NPAPI=1) - -if test "$MOZ_ENABLE_NPAPI" -then - AC_DEFINE(MOZ_ENABLE_NPAPI) -fi - -AC_SUBST(MOZ_ENABLE_NPAPI) - dnl ========================================================= dnl = Whether to exclude hyphenations files in the build dnl ========================================================= diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index 504600cfbc..06cc3598e2 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -116,11 +116,14 @@ if CONFIG['USE_ICU']: 'icu', ] -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3': +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3' and CONFIG['MOZ_ENABLE_NPAPI']: USE_LIBS += [ 'mozgtk_stub', ] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3' and not CONFIG['MOZ_ENABLE_NPAPI']: + OS_LIBS += CONFIG['MOZ_GTK3_LIBS'] + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': CXXFLAGS += CONFIG['TK_CFLAGS'] diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build index 7c802a3c1e..a948b46445 100644 --- a/widget/gtk/moz.build +++ b/widget/gtk/moz.build @@ -3,7 +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/. -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3': +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3' and CONFIG['MOZ_ENABLE_NPAPI']: DIRS += ['mozgtk'] EXPORTS += [ diff --git a/widget/moz.build b/widget/moz.build index 2ba398c260..e81c175254 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -52,7 +52,7 @@ if toolkit in ('cocoa', 'gtk2', 'gtk3'): if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: DIRS += ['gtk'] - if CONFIG['MOZ_X11']: + if CONFIG['MOZ_X11'] and CONFIG['MOZ_ENABLE_NPAPI']: DIRS += ['gtkxtbin'] XPIDL_SOURCES += [