Bug 1278282 - Remove the 'MOZ_WIDGET_GTK == 2' defines r=karlt,lsalzman
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 10 Jan 2018 08:52:04 +0100
changeset 398762 26fa4e61b9bc
parent 398761 28340f2e2631
child 398763 4edc392d61fa
push id33232
push usernerli@mozilla.com
push date2018-01-11 21:53 +0000
treeherdermozilla-central@185d2695bf96 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, lsalzman
bugs1278282
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1278282 - Remove the 'MOZ_WIDGET_GTK == 2' defines r=karlt,lsalzman MozReview-Commit-ID: 3v8D600g8St
accessible/atk/Platform.cpp
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/base/nsPluginsDirUnix.cpp
gfx/thebes/gfxGdkNativeRenderer.cpp
gfx/thebes/gfxGdkNativeRenderer.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
image/decoders/icon/nsIconModule.cpp
layout/xul/nsMenuPopupFrame.cpp
modules/libpref/init/all.js
testing/tools/screenshot/gdk-screenshot.cpp
toolkit/components/remote/nsGTKRemoteService.cpp
toolkit/crashreporter/client/crashreporter_linux.cpp
toolkit/xre/glxtest.cpp
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsEmbedFunctions.cpp
toolkit/xre/nsNativeAppSupportUnix.cpp
toolkit/xre/nsX11ErrorHandler.cpp
widget/gtk/IMContextWrapper.cpp
widget/gtk/NativeKeyBindings.cpp
widget/gtk/gtkdrawing.h
widget/gtk/mozcontainer.cpp
widget/gtk/nsDragService.cpp
widget/gtk/nsNativeThemeGTK.cpp
widget/gtk/nsPrintDialogGTK.cpp
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
xpcom/base/nsSystemInfo.cpp
xpcom/build/nsXULAppAPI.h
xpcom/glue/standalone/nsXPCOMGlue.cpp
--- a/accessible/atk/Platform.cpp
+++ b/accessible/atk/Platform.cpp
@@ -64,24 +64,16 @@ static GnomeAccessibilityModule sAtkBrid
     "libatk-bridge.a(libatk-bridge.so.0)", nullptr,
 #else
     "libatk-bridge.so", nullptr,
 #endif
     "gnome_accessibility_module_init", nullptr,
     "gnome_accessibility_module_shutdown", nullptr
 };
 
-#if (MOZ_WIDGET_GTK == 2)
-static GnomeAccessibilityModule sGail = {
-    "libgail.so", nullptr,
-    "gnome_accessibility_module_init", nullptr,
-    "gnome_accessibility_module_shutdown", nullptr
-};
-#endif
-
 static nsresult
 LoadGtkModule(GnomeAccessibilityModule& aModule)
 {
     NS_ENSURE_ARG(aModule.libName);
 
     if (!(aModule.lib = PR_LoadLibrary(aModule.libName))) {
         //try to load the module with "gtk-2.0/modules" appended
         char *curLibPath = PR_GetLibraryPath();
@@ -97,21 +89,17 @@ LoadGtkModule(GnomeAccessibilityModule& 
         int16_t subLen = 0;
         while (loc2 >= 0) {
             loc2 = libPath.FindChar(':', loc1);
             if (loc2 < 0)
                 subLen = libPath.Length() - loc1;
             else
                 subLen = loc2 - loc1;
             nsAutoCString sub(Substring(libPath, loc1, subLen));
-#if (MOZ_WIDGET_GTK == 2)
-            sub.AppendLiteral("/gtk-2.0/modules/");
-#else
             sub.AppendLiteral("/gtk-3.0/modules/");
-#endif
             sub.Append(aModule.libName);
             aModule.lib = PR_LoadLibrary(sub.get());
             if (aModule.lib)
                 break;
 
             loc1 = loc2+1;
         }
         if (!aModule.lib)
@@ -171,23 +159,16 @@ a11y::PlatformInit()
       if (atkMajorVersion != 0L) {
         atkMinorVersion = strtol(endPtr + 1, &endPtr, 10);
         if (atkMinorVersion != 0L)
           atkMicroVersion = strtol(endPtr + 1, &endPtr, 10);
       }
     }
   }
 
-#if (MOZ_WIDGET_GTK == 2)
-  // Load and initialize gail library.
-  nsresult rv = LoadGtkModule(sGail);
-  if (NS_SUCCEEDED(rv))
-    (*sGail.init)();
-#endif
-
   // Initialize the MAI Utility class, it will overwrite gail_util.
   g_type_class_unref(g_type_class_ref(mai_util_get_type()));
 
   // Init atk-bridge now
   PR_SetEnv("NO_AT_BRIDGE=0");
 #ifdef MOZ_WIDGET_GTK
   if (atk_bridge_adaptor_init) {
     atk_bridge_adaptor_init(nullptr, nullptr);
@@ -231,29 +212,16 @@ a11y::PlatformShutdown()
         // an exit function registered will take care of it
         // if (sAtkBridge.shutdown)
         //     (*sAtkBridge.shutdown)();
         // PR_UnloadLibrary(sAtkBridge.lib);
         sAtkBridge.lib = nullptr;
         sAtkBridge.init = nullptr;
         sAtkBridge.shutdown = nullptr;
     }
-#if (MOZ_WIDGET_GTK == 2)
-    if (sGail.lib) {
-        // Do not shutdown gail because
-        // 1) Maybe it's not init-ed by us. e.g. GtkEmbed
-        // 2) We need it to avoid assert in spi_atk_tidy_windows
-        // if (sGail.shutdown)
-        //   (*sGail.shutdown)();
-        // PR_UnloadLibrary(sGail.lib);
-        sGail.lib = nullptr;
-        sGail.init = nullptr;
-        sGail.shutdown = nullptr;
-    }
-#endif
     // if (sATKLib) {
     //     PR_UnloadLibrary(sATKLib);
     //     sATKLib = nullptr;
     // }
 }
 
   static const char sAccEnv [] = "GNOME_ACCESSIBILITY";
 #ifdef MOZ_ENABLE_DBUS
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -52,19 +52,16 @@
 #include "nsCocoaFeatures.h"
 #include "PluginUtilsOSX.h"
 #endif
 
 // needed for nppdf plugin
 #if (MOZ_WIDGET_GTK)
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
-#if (MOZ_WIDGET_GTK == 2)
-#include "gtk2xtbin.h"
-#endif
 #endif
 
 #include "nsJSUtils.h"
 #include "nsJSNPRuntime.h"
 #include "nsIHttpAuthManager.h"
 #include "nsICookieService.h"
 #include "nsILoadContext.h"
 #include "nsIDocShell.h"
@@ -1336,29 +1333,16 @@ NPError
           needsXEmbed = 0;
         }
       }
       if (windowless || needsXEmbed) {
         (*(Display **)result) = mozilla::DefaultXDisplay();
         return NPERR_NO_ERROR;
       }
     }
-#if (MOZ_WIDGET_GTK == 2)
-    // adobe nppdf calls XtGetApplicationNameAndClass(display,
-    // &instance, &class) we have to init Xt toolkit before get
-    // XtDisplay just call gtk_xtbin_new(w,0) once
-    static GtkWidget *gtkXtBinHolder = 0;
-    if (!gtkXtBinHolder) {
-      gtkXtBinHolder = gtk_xtbin_new(gdk_get_default_root_window(),0);
-      // it crashes on destroy, let it leak
-      // gtk_widget_destroy(gtkXtBinHolder);
-    }
-    (*(Display **)result) =  GTK_XTBIN(gtkXtBinHolder)->xtdisplay;
-    return NPERR_NO_ERROR;
-#endif
 #endif
     return NPERR_GENERIC_ERROR;
   }
 
   case NPNVxtAppContext:
     return NPERR_GENERIC_ERROR;
 #endif
 
--- a/dom/plugins/base/nsPluginsDirUnix.cpp
+++ b/dom/plugins/base/nsPluginsDirUnix.cpp
@@ -34,182 +34,16 @@
 #define DEFAULT_X11_PATH "/usr/X11R6/lib"
 #undef LOCAL_PLUGIN_DLL_SUFFIX
 #define LOCAL_PLUGIN_DLL_SUFFIX ".dylib"
 #define LOCAL_PLUGIN_DLL_ALT_SUFFIX ".so"
 #else
 #define DEFAULT_X11_PATH ""
 #endif
 
-#if (MOZ_WIDGET_GTK == 2)
-
-#define PLUGIN_MAX_LEN_OF_TMP_ARR 512
-
-static void DisplayPR_LoadLibraryErrorMessage(const char *libName)
-{
-    char errorMsg[PLUGIN_MAX_LEN_OF_TMP_ARR] = "Cannot get error from NSPR.";
-    if (PR_GetErrorTextLength() < (int) sizeof(errorMsg))
-        PR_GetErrorText(errorMsg);
-
-    fprintf(stderr, "LoadPlugin: failed to initialize shared library %s [%s]\n",
-        libName, errorMsg);
-}
-
-static void SearchForSoname(const char* name, char** soname)
-{
-    if (!(name && soname))
-        return;
-    PRDir *fdDir = PR_OpenDir(DEFAULT_X11_PATH);
-    if (!fdDir)
-        return;
-
-    int n = strlen(name);
-    PRDirEntry *dirEntry;
-    while ((dirEntry = PR_ReadDir(fdDir, PR_SKIP_BOTH))) {
-        if (!PL_strncmp(dirEntry->name, name, n)) {
-            if (dirEntry->name[n] == '.' && dirEntry->name[n+1] && !dirEntry->name[n+2]) {
-                // name.N, wild guess this is what we need
-                char out[PLUGIN_MAX_LEN_OF_TMP_ARR] = DEFAULT_X11_PATH;
-                PL_strcat(out, dirEntry->name);
-                *soname = PL_strdup(out);
-               break;
-            }
-        }
-    }
-
-    PR_CloseDir(fdDir);
-}
-
-static bool LoadExtraSharedLib(const char *name, char **soname, bool tryToGetSoname)
-{
-    bool ret = true;
-    PRLibSpec tempSpec;
-    PRLibrary *handle;
-    tempSpec.type = PR_LibSpec_Pathname;
-    tempSpec.value.pathname = name;
-    handle = PR_LoadLibraryWithFlags(tempSpec, PR_LD_NOW|PR_LD_GLOBAL);
-    if (!handle) {
-        ret = false;
-        DisplayPR_LoadLibraryErrorMessage(name);
-        if (tryToGetSoname) {
-            SearchForSoname(name, soname);
-            if (*soname) {
-                ret = LoadExtraSharedLib((const char *) *soname, nullptr, false);
-            }
-        }
-    }
-    return ret;
-}
-
-#define PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS 32
-#define PREF_PLUGINS_SONAME "plugin.soname.list"
-#if defined(SOLARIS) || defined(HPUX)
-#define DEFAULT_EXTRA_LIBS_LIST "libXt" LOCAL_PLUGIN_DLL_SUFFIX ":libXext" LOCAL_PLUGIN_DLL_SUFFIX ":libXm" LOCAL_PLUGIN_DLL_SUFFIX
-#else
-#define DEFAULT_EXTRA_LIBS_LIST "libXt" LOCAL_PLUGIN_DLL_SUFFIX ":libXext" LOCAL_PLUGIN_DLL_SUFFIX
-#endif
-/*
- this function looks for
- user_pref("plugin.soname.list", "/usr/X11R6/lib/libXt.so.6:libXext.so");
- in user's pref.js
- and loads all libs in specified order
-*/
-
-static void LoadExtraSharedLibs()
-{
-    // check out if user's prefs.js has libs name
-    nsresult res;
-    nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &res));
-    if (NS_SUCCEEDED(res) && (prefs != nullptr)) {
-        char *sonameList = nullptr;
-        bool prefSonameListIsSet = true;
-        res = prefs->GetCharPref(PREF_PLUGINS_SONAME, &sonameList);
-        if (!sonameList) {
-            // pref is not set, lets use hardcoded list
-            prefSonameListIsSet = false;
-            sonameList = PL_strdup(DEFAULT_EXTRA_LIBS_LIST);
-        }
-        if (sonameList) {
-            char *arrayOfLibs[PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS] = {0};
-            int numOfLibs = 0;
-            char *nextToken;
-            char *p = nsCRT::strtok(sonameList,":",&nextToken);
-            if (p) {
-                while (p && numOfLibs < PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS) {
-                    arrayOfLibs[numOfLibs++] = p;
-                    p = nsCRT::strtok(nextToken,":",&nextToken);
-                }
-            } else // there is just one lib
-                arrayOfLibs[numOfLibs++] = sonameList;
-
-            char sonameListToSave[PLUGIN_MAX_LEN_OF_TMP_ARR] = "";
-            for (int i=0; i<numOfLibs; i++) {
-                // trim out head/tail white spaces (just in case)
-                bool head = true;
-                p = arrayOfLibs[i];
-                while (*p) {
-                    if (*p == ' ' || *p == '\t') {
-                        if (head) {
-                            arrayOfLibs[i] = ++p;
-                        } else {
-                            *p = 0;
-                        }
-                    } else {
-                        head = false;
-                        p++;
-                    }
-                }
-                if (!arrayOfLibs[i][0]) {
-                    continue; // null string
-                }
-                bool tryToGetSoname = true;
-                if (PL_strchr(arrayOfLibs[i], '/')) {
-                    //assuming it's real name, try to stat it
-                    struct stat st;
-                    if (stat((const char*) arrayOfLibs[i], &st)) {
-                        //get just a file name
-                        arrayOfLibs[i] = PL_strrchr(arrayOfLibs[i], '/') + 1;
-                    } else
-                        tryToGetSoname = false;
-                }
-                char *soname = nullptr;
-                if (LoadExtraSharedLib(arrayOfLibs[i], &soname, tryToGetSoname)) {
-                    //construct soname's list to save in prefs
-                    p = soname ? soname : arrayOfLibs[i];
-                    int n = PLUGIN_MAX_LEN_OF_TMP_ARR -
-                        (strlen(sonameListToSave) + strlen(p));
-                    if (n > 0) {
-                        PL_strcat(sonameListToSave, p);
-                        PL_strcat(sonameListToSave,":");
-                    }
-                    if (soname) {
-                        PL_strfree(soname); // it's from strdup
-                    }
-                    if (numOfLibs > 1)
-                        arrayOfLibs[i][strlen(arrayOfLibs[i])] = ':'; //restore ":" in sonameList
-                }
-            }
-
-            // Check whether sonameListToSave is a empty String, Bug: 329205
-            if (sonameListToSave[0])
-                for (p = &sonameListToSave[strlen(sonameListToSave) - 1]; *p == ':'; p--)
-                    *p = 0; //delete tail ":" delimiters
-
-            if (!prefSonameListIsSet || PL_strcmp(sonameList, sonameListToSave)) {
-                // if user specified some bogus soname I overwrite it here,
-                // otherwise it'll decrease performance by calling popen() in SearchForSoname
-                // every time for each bogus name
-                prefs->SetCharPref(PREF_PLUGINS_SONAME, (const char *)sonameListToSave);
-            }
-            PL_strfree(sonameList);
-        }
-    }
-}
-#endif //MOZ_WIDGET_GTK == 2
-
 /* nsPluginsDir implementation */
 
 bool nsPluginsDir::IsPluginFile(nsIFile* file)
 {
     nsAutoCString filename;
     if (NS_FAILED(file->GetNativeLeafName(filename)))
         return false;
 
@@ -250,53 +84,18 @@ nsresult nsPluginFile::LoadPlugin(PRLibr
     nsresult rv;
     nsAutoCString path;
     rv = mPlugin->GetNativePath(path);
     if (NS_FAILED(rv))
         return rv;
 
     libSpec.value.pathname = path.get();
 
-#if (MOZ_WIDGET_GTK == 2)
-
-    // Normally, Mozilla isn't linked against libXt and libXext
-    // since it's a Gtk/Gdk application.  On the other hand,
-    // legacy plug-ins expect the libXt and libXext symbols
-    // to already exist in the global name space.  This plug-in
-    // wrapper is linked against libXt and libXext, but since
-    // we never call on any of these libraries, plug-ins still
-    // fail to resolve Xt symbols when trying to do a dlopen
-    // at runtime.  Explicitly opening Xt/Xext into the global
-    // namespace before attempting to load the plug-in seems to
-    // work fine.
-
-
-#if defined(SOLARIS) || defined(HPUX)
-    // Acrobat/libXm: Lazy resolving might cause crash later (bug 211587)
-    *outLibrary = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW);
-    pLibrary = *outLibrary;
-#else
-    // Some dlopen() doesn't recover from a failed PR_LD_NOW (bug 223744)
     *outLibrary = PR_LoadLibraryWithFlags(libSpec, 0);
     pLibrary = *outLibrary;
-#endif
-    if (!pLibrary) {
-        LoadExtraSharedLibs();
-        // try reload plugin once more
-        *outLibrary = PR_LoadLibraryWithFlags(libSpec, 0);
-        pLibrary = *outLibrary;
-        if (!pLibrary) {
-            DisplayPR_LoadLibraryErrorMessage(libSpec.value.pathname);
-            return NS_ERROR_FAILURE;
-        }
-    }
-#else
-    *outLibrary = PR_LoadLibraryWithFlags(libSpec, 0);
-    pLibrary = *outLibrary;
-#endif  // MOZ_WIDGET_GTK == 2
 
 #ifdef DEBUG
     printf("LoadPlugin() %s returned %lx\n",
            libSpec.value.pathname, (unsigned long)pLibrary);
 #endif
 
     if (!pLibrary) {
         return NS_ERROR_FAILURE;
--- a/gfx/thebes/gfxGdkNativeRenderer.cpp
+++ b/gfx/thebes/gfxGdkNativeRenderer.cpp
@@ -7,63 +7,10 @@
 #include "gfxContext.h"
 #include "gfxPlatformGtk.h"
 
 #ifdef MOZ_X11
 #include <gdk/gdkx.h>
 #include "cairo-xlib.h"
 #include "gfxXlibSurface.h"
 
-#if (MOZ_WIDGET_GTK == 2)
-nsresult
-gfxGdkNativeRenderer::DrawWithXlib(cairo_surface_t* surface,
-                                   nsIntPoint offset,
-                                   mozilla::gfx::IntRect* clipRects, uint32_t numClipRects)
-{
-    GdkDrawable *drawable = gfxPlatformGtk::GetGdkDrawable(surface);
-    if (!drawable) {
-        int depth = cairo_xlib_surface_get_depth(surface);
-        GdkScreen* screen = gdk_colormap_get_screen(mColormap);
-        drawable =
-            gdk_pixmap_foreign_new_for_screen(screen, cairo_xlib_surface_get_drawable(surface),
-                                              cairo_xlib_surface_get_width(surface),
-                                              cairo_xlib_surface_get_height(surface),
-                                              depth);
-        if (!drawable)
-            return NS_ERROR_FAILURE;
-
-        gdk_drawable_set_colormap(drawable, mColormap);
-        gfxPlatformGtk::SetGdkDrawable(surface, drawable);
-        g_object_unref(drawable); // The drawable now belongs to |surface|.
-    }
-    
-    GdkRectangle clipRect;
-    if (numClipRects) {
-        NS_ASSERTION(numClipRects == 1, "Too many clip rects");
-        clipRect.x = clipRects[0].x;
-        clipRect.y = clipRects[0].y;
-        clipRect.width = clipRects[0].width;
-        clipRect.height = clipRects[0].height;
-    }
-
-    return DrawWithGDK(drawable, offset.x, offset.y,
-                       numClipRects ? &clipRect : nullptr, numClipRects);
-}
-
-void
-gfxGdkNativeRenderer::Draw(gfxContext* ctx, mozilla::gfx::IntSize size,
-                           uint32_t flags, GdkColormap* colormap)
-{
-    mColormap = colormap;
-
-    Visual* visual =
-        gdk_x11_visual_get_xvisual(gdk_colormap_get_visual(colormap));
-    Screen* screen =
-        gdk_x11_screen_get_xscreen(gdk_colormap_get_screen(colormap));
-
-    gfxXlibNativeRenderer::Draw(ctx, size, flags, screen, visual);
-}
-
-#else
-// TODO GTK3
-#endif
 
 #endif
--- a/gfx/thebes/gfxGdkNativeRenderer.h
+++ b/gfx/thebes/gfxGdkNativeRenderer.h
@@ -30,21 +30,16 @@ public:
      * Perform the native drawing.
      * @param offsetX draw at this offset into the given drawable
      * @param offsetY draw at this offset into the given drawable
      * @param clipRects an array of rects; clip to the union
      * @param numClipRects the number of rects in the array, or zero if
      * no clipping is required
      */
 
-#if (MOZ_WIDGET_GTK == 2)
-    virtual nsresult DrawWithGDK(GdkDrawable * drawable, gint offsetX, 
-            gint offsetY, GdkRectangle * clipRects, uint32_t numClipRects) = 0;
-#endif
-
     enum {
         // If set, then Draw() is opaque, i.e., every pixel in the intersection
         // of the clipRect and (offset.x,offset.y,bounds.width,bounds.height)
         // will be set and there is no dependence on what the existing pixels
         // in the drawable are set to.
         DRAW_IS_OPAQUE =
 #ifdef MOZ_X11
             gfxXlibNativeRenderer::DRAW_IS_OPAQUE
@@ -62,27 +57,20 @@ public:
     };
 
     /**
      * @param flags see above
      * @param bounds Draw()'s drawing is guaranteed to be restricted to
      * the rectangle (offset.x,offset.y,bounds.width,bounds.height)
      * @param dpy a display to use for the drawing if ctx doesn't have one
      */
-#if (MOZ_WIDGET_GTK == 2)
-    void Draw(gfxContext* ctx, mozilla::gfx::IntSize size,
-              uint32_t flags, GdkColormap* colormap);
-#endif
 
 private:
 #ifdef MOZ_X11
     // for gfxXlibNativeRenderer:
     virtual nsresult DrawWithXlib(cairo_surface_t* surface,
                                   nsIntPoint offset,
                                   mozilla::gfx::IntRect* clipRects, uint32_t numClipRects) override;
 
-#if (MOZ_WIDGET_GTK == 2)
-    GdkColormap *mColormap;
-#endif
 #endif
 };
 
 #endif /*GFXGDKNATIVERENDER_H_*/
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -62,20 +62,16 @@
 
 #define GFX_PREF_MAX_GENERIC_SUBSTITUTIONS "gfx.font_rendering.fontconfig.max_generic_substitutions"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::unicode;
 using mozilla::dom::SystemFontListEntry;
 
-#if (MOZ_WIDGET_GTK == 2)
-static cairo_user_data_key_t cairo_gdk_drawable_key;
-#endif
-
 gfxPlatformGtk::gfxPlatformGtk()
 {
     if (!gfxPlatform::IsHeadless()) {
         gtk_init(nullptr, nullptr);
     }
 
     mMaxGenericSubstitutions = UNINITIALIZED_VALUE;
 
@@ -527,61 +523,16 @@ gfxPlatformGtk::GetPlatformCMSOutputProf
             }
 #endif
         }
     }
 #endif
 }
 
 
-#if (MOZ_WIDGET_GTK == 2)
-void
-gfxPlatformGtk::SetGdkDrawable(cairo_surface_t *target,
-                               GdkDrawable *drawable)
-{
-    if (cairo_surface_status(target))
-        return;
-
-    g_object_ref(drawable);
-
-    cairo_surface_set_user_data (target,
-                                 &cairo_gdk_drawable_key,
-                                 drawable,
-                                 g_object_unref);
-}
-
-GdkDrawable *
-gfxPlatformGtk::GetGdkDrawable(cairo_surface_t *target)
-{
-    if (cairo_surface_status(target))
-        return nullptr;
-
-    GdkDrawable *result;
-
-    result = (GdkDrawable*) cairo_surface_get_user_data (target,
-                                                         &cairo_gdk_drawable_key);
-    if (result)
-        return result;
-
-#ifdef MOZ_X11
-    if (cairo_surface_get_type(target) != CAIRO_SURFACE_TYPE_XLIB)
-        return nullptr;
-
-    // try looking it up in gdk's table
-    result = (GdkDrawable*) gdk_xid_table_lookup(cairo_xlib_surface_get_drawable(target));
-    if (result) {
-        SetGdkDrawable(target, result);
-        return result;
-    }
-#endif
-
-    return nullptr;
-}
-#endif
-
 #ifdef GL_PROVIDER_GLX
 
 class GLXVsyncSource final : public VsyncSource
 {
 public:
   GLXVsyncSource()
   {
     MOZ_ASSERT(NS_IsMainThread());
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -6,22 +6,16 @@
 #ifndef GFX_PLATFORM_GTK_H
 #define GFX_PLATFORM_GTK_H
 
 #include "gfxPlatform.h"
 #include "nsAutoRef.h"
 #include "nsTArray.h"
 #include "mozilla/gfx/gfxVars.h"
 
-#if (MOZ_WIDGET_GTK == 2)
-extern "C" {
-    typedef struct _GdkDrawable GdkDrawable;
-}
-#endif
-
 #ifdef MOZ_X11
 struct _XDisplay;
 typedef struct _XDisplay Display;
 #endif // MOZ_X11
 
 namespace mozilla {
     namespace dom {
         class SystemFontListEntry;
@@ -89,22 +83,16 @@ public:
 
     /**
      * Calls XFlush if xrender is enabled.
      */
     virtual void FlushContentDrawing() override;
 
     FT_Library GetFTLibrary() override;
 
-#if (MOZ_WIDGET_GTK == 2)
-    static void SetGdkDrawable(cairo_surface_t *target,
-                               GdkDrawable *drawable);
-    static GdkDrawable *GetGdkDrawable(cairo_surface_t *target);
-#endif
-
     static int32_t GetFontScaleDPI();
     static double  GetFontScaleFactor();
 
 #ifdef MOZ_X11
     virtual void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) override {
       gfxPlatform::GetAzureBackendInfo(aObj);
       aObj.DefineProperty("CairoUseXRender", mozilla::gfx::gfxVars::UseXRender());
     }
--- a/image/decoders/icon/nsIconModule.cpp
+++ b/image/decoders/icon/nsIconModule.cpp
@@ -41,19 +41,16 @@ static const mozilla::Module::ContractID
 
 static const mozilla::Module::CategoryEntry kIconCategories[] = {
   { nullptr }
 };
 
 static void
 IconDecoderModuleDtor()
 {
-#if (MOZ_WIDGET_GTK == 2)
-  nsIconChannel::Shutdown();
-#endif
 }
 
 static const mozilla::Module kIconModule = {
   mozilla::Module::kVersion,
   kIconCIDs,
   kIconContracts,
   kIconCategories,
   nullptr,
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -2295,24 +2295,16 @@ nsMenuPopupFrame::AttributeChanged(int32
 
 {
   nsresult rv = nsBoxFrame::AttributeChanged(aNameSpaceID, aAttribute,
                                              aModType);
 
   if (aAttribute == nsGkAtoms::left || aAttribute == nsGkAtoms::top)
     MoveToAttributePosition();
 
-#ifndef MOZ_GTK2
-  if (aAttribute == nsGkAtoms::noautohide) {
-    nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
-    if (pm)
-      pm->EnableRollup(mContent, !IsNoAutoHide());
-  }
-#endif
-
   if (aAttribute == nsGkAtoms::remote) {
     // When the remote attribute changes, we need to create a new widget to
     // ensure that it has the correct compositor and transparency settings to
     // match the new value.
     EnsureWidget(true);
   }
 
   if (aAttribute == nsGkAtoms::followanchor) {
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4482,21 +4482,17 @@ pref("font.name-list.monospace.zh-TW", "
 // 2 problems:
 // 1. The non-topmost panel steals focus from its parent window at showing.
 // 2. The parent of non-topmost panel is not activated when the panel is hidden.
 // So, we have no reasons we should use non-toplevel window for popup.
 pref("ui.panel.default_level_parent", true);
 
 pref("mousewheel.system_scroll_override_on_root_content.enabled", false);
 
-#if MOZ_WIDGET_GTK == 2
-pref("intl.ime.use_simple_context_on_password_field", true);
-#else
 pref("intl.ime.use_simple_context_on_password_field", false);
-#endif
 
 #ifdef MOZ_WIDGET_GTK
 // maximum number of fonts to substitute for a generic
 pref("gfx.font_rendering.fontconfig.max_generic_substitutions", 3);
 #endif
 
 # XP_UNIX
 #endif
--- a/testing/tools/screenshot/gdk-screenshot.cpp
+++ b/testing/tools/screenshot/gdk-screenshot.cpp
@@ -124,26 +124,19 @@ int main(int argc, char** argv)
     fprintf(stderr, "User input has been idle for %lu seconds\n", info->idle / 1000);
 
     XFree(info);
   }
 #endif
 
   GdkPixbuf* screenshot = nullptr;
   GdkWindow* window = gdk_get_default_root_window();
-#if (MOZ_WIDGET_GTK == 2)
-  screenshot = gdk_pixbuf_get_from_drawable(nullptr, window, nullptr,
-                                            0, 0, 0, 0,
-                                            gdk_screen_width(),
-                                            gdk_screen_height());
-#else
   screenshot = gdk_pixbuf_get_from_window(window, 0, 0,
                                           gdk_window_get_width(window),
                                           gdk_window_get_height(window));
-#endif
   if (!screenshot) {
     fprintf(stderr, "%s: failed to create screenshot GdkPixbuf\n", argv[0]);
     return 1;
   }
 
   GError* error = nullptr;
   if (argc > 1) {
     gdk_pixbuf_save(screenshot, argv[1], "png", &error, nullptr);
--- a/toolkit/components/remote/nsGTKRemoteService.cpp
+++ b/toolkit/components/remote/nsGTKRemoteService.cpp
@@ -99,36 +99,28 @@ void
 nsGTKRemoteService::HandleCommandsFor(GtkWidget* widget,
                                       nsIWeakReference* aWindow)
 {
   g_signal_connect(G_OBJECT(widget), "property_notify_event",
                    G_CALLBACK(HandlePropertyChange), aWindow);
 
   gtk_widget_add_events(widget, GDK_PROPERTY_CHANGE_MASK);
 
-#if (MOZ_WIDGET_GTK == 2)
-  Window window = GDK_WINDOW_XWINDOW(widget->window);
-#else
   Window window = gdk_x11_window_get_xid(gtk_widget_get_window(widget));
-#endif
   nsXRemoteService::HandleCommandsFor(window);
 }
 
 gboolean
 nsGTKRemoteService::HandlePropertyChange(GtkWidget *aWidget,
                                          GdkEventProperty *pevent,
                                          nsIWeakReference *aThis)
 {
   if (pevent->state == GDK_PROPERTY_NEW_VALUE) {
     Atom changedAtom = gdk_x11_atom_to_xatom(pevent->atom);
 
-#if (MOZ_WIDGET_GTK == 2)
-    XID window = GDK_WINDOW_XWINDOW(pevent->window);
-#else
     XID window = gdk_x11_window_get_xid(gtk_widget_get_window(aWidget));
-#endif
     return HandleNewProperty(window,
                              GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
                              pevent->time, changedAtom, aThis);
   }
   return FALSE;
 }
 
--- a/toolkit/crashreporter/client/crashreporter_linux.cpp
+++ b/toolkit/crashreporter/client/crashreporter_linux.cpp
@@ -420,21 +420,17 @@ bool UIShowCrashUI(const StringTable& fi
                                  gStrings[ST_CRASHREPORTERHEADER].c_str());
   gtk_label_set_markup(GTK_LABEL(titleLabel), markup);
   g_free(markup);
 
   GtkWidget* descriptionLabel =
     gtk_label_new(gStrings[ST_CRASHREPORTERDESCRIPTION].c_str());
   gtk_box_pack_start(GTK_BOX(vbox), descriptionLabel, TRUE, TRUE, 0);
   // force the label to line wrap
-#if (MOZ_WIDGET_GTK == 2)
-  gtk_widget_set_size_request(descriptionLabel, 400, -1);
-#else
   gtk_label_set_max_width_chars(GTK_LABEL(descriptionLabel), LABEL_MAX_CHAR_WIDTH);
-#endif
   gtk_label_set_line_wrap(GTK_LABEL(descriptionLabel), TRUE);
   gtk_label_set_selectable(GTK_LABEL(descriptionLabel), TRUE);
   gtk_misc_set_alignment(GTK_MISC(descriptionLabel), 0, 0.5);
 
   // this is honestly how they suggest you indent a section
   GtkWidget* indentBox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox), indentBox, FALSE, FALSE, 0);
   gtk_box_pack_start(GTK_BOX(indentBox), gtk_label_new(""), FALSE, FALSE, 6);
@@ -529,21 +525,17 @@ bool UIShowCrashUI(const StringTable& fi
   g_free(dir);
   gThrobber = gtk_image_new_from_file(path);
   gtk_box_pack_start(GTK_BOX(progressBox), gThrobber, FALSE, FALSE, 0);
 
   gProgressLabel =
     gtk_label_new(gStrings[ST_REPORTPRESUBMIT].c_str());
   gtk_box_pack_start(GTK_BOX(progressBox), gProgressLabel, TRUE, TRUE, 0);
   // force the label to line wrap
-#if (MOZ_WIDGET_GTK == 2)
-  gtk_widget_set_size_request(gProgressLabel, 400, -1);
-#else
   gtk_label_set_max_width_chars(GTK_LABEL(gProgressLabel), LABEL_MAX_CHAR_WIDTH);
-#endif
   gtk_label_set_line_wrap(GTK_LABEL(gProgressLabel), TRUE);
 
   GtkWidget* buttonBox = gtk_hbutton_box_new();
   gtk_box_pack_end(GTK_BOX(vbox), buttonBox, FALSE, FALSE, 0);
   gtk_box_set_spacing(GTK_BOX(buttonBox), 6);
   gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonBox), GTK_BUTTONBOX_END);
 
   gCloseButton =
--- a/toolkit/xre/glxtest.cpp
+++ b/toolkit/xre/glxtest.cpp
@@ -22,20 +22,16 @@
 #include <cstdio>
 #include <cstdlib>
 #include <unistd.h>
 #include <dlfcn.h>
 #include "nscore.h"
 #include <fcntl.h>
 #include "stdint.h"
 
-#if MOZ_WIDGET_GTK == 2
-#include <glib.h>
-#endif
-
 #ifdef __SUNPRO_CC
 #include <stdio.h>
 #endif
 
 #include "X11/Xlib.h"
 #include "X11/Xutil.h"
 
 #include "mozilla/Unused.h"
@@ -69,21 +65,16 @@ extern int glxtest_pipe;
 // the PID of the glxtest process, to pass to waitpid()
 extern pid_t glxtest_pid;
 }
 }
 
 // the write end of the pipe, which we're going to write to
 static int write_end_of_the_pipe = -1;
 
-#if MOZ_WIDGET_GTK == 2
-static int gtk_write_end_of_the_pipe = -1;
-int gtk_read_end_of_the_pipe = -1;
-#endif
-
 // C++ standard collides with C standard in that it doesn't allow casting void* to function pointer types.
 // So the work-around is to convert first to size_t.
 // http://www.trilithium.com/johan/2004/12/problem-with-dlsym/
 template<typename func_ptr_type>
 static func_ptr_type cast(void *ptr)
 {
   return reinterpret_cast<func_ptr_type>(
            reinterpret_cast<size_t>(ptr)
@@ -124,46 +115,16 @@ void glxtest()
   // we want to redirect to /dev/null stdout, stderr, and while we're at it,
   // any PR logging file descriptors. To that effect, we redirect all positive
   // file descriptors up to what open() returns here. In particular, 1 is stdout and 2 is stderr.
   int fd = open("/dev/null", O_WRONLY);
   for (int i = 1; i < fd; i++)
     dup2(fd, i);
   close(fd);
 
-#if MOZ_WIDGET_GTK == 2
-  // On Gtk+2 builds, try to get the Gtk+3 version if it's installed, and
-  // use that in nsSystemInfo for secondaryLibrary. Better safe than sorry,
-  // we want to load the Gtk+3 library in a subprocess, and since we already
-  // have such a subprocess for the GLX test, we piggy back on it.
-  void *gtk3 = dlopen("libgtk-3.so.0", RTLD_LOCAL | RTLD_LAZY);
-  if (gtk3) {
-    auto gtk_get_major_version = reinterpret_cast<guint (*)(void)>(
-      dlsym(gtk3, "gtk_get_major_version"));
-    auto gtk_get_minor_version = reinterpret_cast<guint (*)(void)>(
-      dlsym(gtk3, "gtk_get_minor_version"));
-    auto gtk_get_micro_version = reinterpret_cast<guint (*)(void)>(
-      dlsym(gtk3, "gtk_get_micro_version"));
-
-    if (gtk_get_major_version && gtk_get_minor_version &&
-        gtk_get_micro_version) {
-      // 64 bytes is going to be well enough for "GTK " followed by 3 integers
-      // separated with dots.
-      char gtkver[64];
-      int len = snprintf(gtkver, sizeof(gtkver), "GTK %u.%u.%u",
-                         gtk_get_major_version(), gtk_get_minor_version(),
-                         gtk_get_micro_version());
-      if (len > 0 && size_t(len) < sizeof(gtkver)) {
-        mozilla::Unused << write(gtk_write_end_of_the_pipe, gtkver, len);
-      }
-    }
-  }
-#endif
-
-
   if (getenv("MOZ_AVOID_OPENGL_ALTOGETHER"))
     fatal_error("The MOZ_AVOID_OPENGL_ALTOGETHER environment variable is defined");
 
   ///// Open libGL and load needed symbols /////
 #ifdef __OpenBSD__
   #define LIBGL_FILENAME "libGL.so"
 #else
   #define LIBGL_FILENAME "libGL.so.1"
@@ -298,52 +259,30 @@ void glxtest()
 /** \returns true in the child glxtest process, false in the parent process */
 bool fire_glxtest_process()
 {
   int pfd[2];
   if (pipe(pfd) == -1) {
       perror("pipe");
       return false;
   }
-#if MOZ_WIDGET_GTK == 2
-  int gtkpfd[2];
-  if (pipe(gtkpfd) == -1) {
-      perror("pipe");
-      return false;
-  }
-#endif
   pid_t pid = fork();
   if (pid < 0) {
       perror("fork");
       close(pfd[0]);
       close(pfd[1]);
-#if MOZ_WIDGET_GTK == 2
-      close(gtkpfd[0]);
-      close(gtkpfd[1]);
-#endif
       return false;
   }
   // The child exits early to avoid running the full shutdown sequence and avoid conflicting with threads
   // we have already spawned (like the profiler).
   if (pid == 0) {
       close(pfd[0]);
       write_end_of_the_pipe = pfd[1];
-#if MOZ_WIDGET_GTK == 2
-      close(gtkpfd[0]);
-      gtk_write_end_of_the_pipe = gtkpfd[1];
-#endif
       glxtest();
       close(pfd[1]);
-#if MOZ_WIDGET_GTK == 2
-      close(gtkpfd[1]);
-#endif
       _exit(0);
   }
 
   close(pfd[1]);
   mozilla::widget::glxtest_pipe = pfd[0];
   mozilla::widget::glxtest_pid = pid;
-#if MOZ_WIDGET_GTK == 2
-  close(gtkpfd[1]);
-  gtk_read_end_of_the_pipe = gtkpfd[0];
-#endif
   return false;
 }
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3859,20 +3859,16 @@ XREMain::XRE_mainStartup(bool* aExitFlag
   }
 #endif
 
 #if defined(MOZ_WIDGET_GTK)
   // setup for private colormap.  Ideally we'd like to do this
   // in nsAppShell::Create, but we need to get in before gtk
   // has been initialized to make sure everything is running
   // consistently.
-#if (MOZ_WIDGET_GTK == 2)
-  if (CheckArg("install"))
-    gdk_rgb_set_install(TRUE);
-#endif
 
   // Set program name to the one defined in application.ini.
   {
     nsAutoCString program(gAppData->name);
     ToLowerCase(program);
     g_set_prgname(program.get());
   }
 
@@ -4067,19 +4063,16 @@ XREMain::XRE_mainStartup(bool* aExitFlag
       return 1;
     }
   }
 #endif
 #if defined(MOZ_WIDGET_GTK)
   g_set_application_name(mAppData->name);
   gtk_window_set_auto_startup_notification(false);
 
-#if (MOZ_WIDGET_GTK == 2)
-  gtk_widget_set_default_colormap(gdk_rgb_get_colormap());
-#endif /* (MOZ_WIDGET_GTK == 2) */
 #endif /* defined(MOZ_WIDGET_GTK) */
 #ifdef MOZ_X11
   // Do this after initializing GDK, or GDK will install its own handler.
   XRE_InstallX11ErrorHandler();
 #endif
 
   // Call the code to install our handler
 #ifdef MOZ_JPROF
@@ -4711,35 +4704,16 @@ XREMain::XRE_mainRun()
       NS_ERROR("failed to run appstartup");
       gLogConsoleErrors = true;
     }
   }
 
   return rv;
 }
 
-#if MOZ_WIDGET_GTK == 2
-void XRE_GlibInit()
-{
-  static bool ran_once = false;
-
-  // glib < 2.24 doesn't want g_thread_init to be invoked twice, so ensure
-  // we only do it once. No need for thread safety here, since this is invoked
-  // well before any thread is spawned.
-  if (!ran_once) {
-    // glib version < 2.36 doesn't initialize g_slice in a static initializer.
-    // Ensure this happens through g_thread_init (glib version < 2.32) or
-    // g_type_init (2.32 <= gLib version < 2.36)."
-    g_thread_init(nullptr);
-    g_type_init();
-    ran_once = true;
-  }
-}
-#endif
-
 /*
  * XRE_main - A class based main entry point used by most platforms.
  *            Note that on OSX, aAppData->xreDirectory will point to
  *            .app/Contents/Resources.
  */
 int
 XREMain::XRE_main(int argc, char* argv[], const BootstrapConfig& aConfig)
 {
@@ -4837,20 +4811,16 @@ XREMain::XRE_main(int argc, char* argv[]
 #if defined(XP_WIN)
   // Some COM settings are global to the process and must be set before any non-
   // trivial COM is run in the application. Since these settings may affect
   // stability, we should instantiate COM ASAP so that we can ensure that these
   // global settings are configured before anything can interfere.
   mozilla::mscom::MainThreadRuntime msCOMRuntime;
 #endif
 
-#if MOZ_WIDGET_GTK == 2
-  XRE_GlibInit();
-#endif
-
   // init
   bool exit = false;
   int result = XRE_mainInit(&exit);
   if (result != 0 || exit)
     return result;
 
   // startup
   result = XRE_mainStartup(&exit);
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -510,19 +510,16 @@ XRE_InitChildProcess(int aArgc,
   CrashReporter::InitThreadAnnotationRAII annotation;
 
   gArgv = aArgv;
   gArgc = aArgc;
 
 #ifdef MOZ_X11
   XInitThreads();
 #endif
-#if MOZ_WIDGET_GTK == 2
-  XRE_GlibInit();
-#endif
 #ifdef MOZ_WIDGET_GTK
   // Setting the name here avoids the need to pass this through to gtk_init().
   g_set_prgname(aArgv[0]);
 #endif
 
 #ifdef OS_POSIX
   if (PR_GetEnv("MOZ_DEBUG_CHILD_PROCESS") ||
       PR_GetEnv("MOZ_DEBUG_CHILD_PAUSE")) {
--- a/toolkit/xre/nsNativeAppSupportUnix.cpp
+++ b/toolkit/xre/nsNativeAppSupportUnix.cpp
@@ -455,36 +455,16 @@ nsNativeAppSupportUnix::Start(bool *aRet
 
 // The dbus library is used by both nsWifiScannerDBus and BluetoothDBusService,
 // from diffrent threads. This could lead to race conditions if the dbus is not
 // initialized before making any other library calls.
 #ifdef MOZ_ENABLE_DBUS
   dbus_threads_init_default();
 #endif
 
-#if (MOZ_WIDGET_GTK == 2)
-  if (gtk_major_version < MIN_GTK_MAJOR_VERSION ||
-      (gtk_major_version == MIN_GTK_MAJOR_VERSION && gtk_minor_version < MIN_GTK_MINOR_VERSION)) {
-    GtkWidget* versionErrDialog = gtk_message_dialog_new(nullptr,
-                     GtkDialogFlags(GTK_DIALOG_MODAL |
-                                    GTK_DIALOG_DESTROY_WITH_PARENT),
-                     GTK_MESSAGE_ERROR,
-                     GTK_BUTTONS_OK,
-                     UNSUPPORTED_GTK_MSG,
-                     gtk_major_version,
-                     gtk_minor_version,
-                     MIN_GTK_MAJOR_VERSION,
-                     MIN_GTK_MINOR_VERSION);
-    gtk_dialog_run(GTK_DIALOG(versionErrDialog));
-    gtk_widget_destroy(versionErrDialog);
-    MozExpectedExit();
-    exit(0);
-  }
-#endif
-
   *aRetVal = true;
 
 #ifdef MOZ_X11
   gboolean sm_disable = FALSE;
   if (!getenv("SESSION_MANAGER")) {
     sm_disable = TRUE;
   }
 
--- a/toolkit/xre/nsX11ErrorHandler.cpp
+++ b/toolkit/xre/nsX11ErrorHandler.cpp
@@ -52,27 +52,16 @@ X11Error(Display *display, XErrorEvent *
             message.AppendInt(event->minor_code);
             break;
           }
         }
 
         XFreeExtensionList(extNames);
       }
       XCloseDisplay(tmpDisplay);
-
-#if (MOZ_WIDGET_GTK == 2)
-      // GDK2 calls XCloseDevice the devices that it opened on startup, but
-      // the XI protocol no longer ensures that the devices will still exist.
-      // If they have been removed, then a BadDevice error results.  Ignore
-      // this error.
-      if (message.EqualsLiteral("XInputExtension.4") &&
-          event->error_code == first_error + 0) {
-        return 0;
-      }
-#endif
     }
   }
 
   char buffer[BUFSIZE];
   if (message.IsEmpty()) {
     buffer[0] = '\0';
   } else {
     XGetErrorDatabaseText(display, "XRequest", message.get(), "",
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -146,17 +146,17 @@ public:
     {
         AppendPrintf("{ R=0x%02X, G=0x%02X, B=0x%02X, A=0x%02X }",
                      NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor),
                      NS_GET_A(aColor));
     }
     virtual ~GetTextRangeStyleText() {};
 };
 
-const static bool kUseSimpleContextDefault = MOZ_WIDGET_GTK == 2;
+const static bool kUseSimpleContextDefault = false;
 
 /******************************************************************************
  * IMContextWrapper
  ******************************************************************************/
 
 IMContextWrapper* IMContextWrapper::sLastFocusedContext = nullptr;
 bool IMContextWrapper::sUseSimpleContext;
 
@@ -427,22 +427,17 @@ IMContextWrapper::OnDestroyWindow(nsWind
 // find the signal handlers and remove them.
 //
 // GtkIMContextXIMs share XOpenIM connections and display closed signal
 // handlers (where possible).
 
 void
 IMContextWrapper::PrepareToDestroyContext(GtkIMContext* aContext)
 {
-#if (MOZ_WIDGET_GTK == 2)
-    GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT(aContext);
-    GtkIMContext *slave = multicontext->slave;
-#else
     GtkIMContext *slave = nullptr; //TODO GTK3
-#endif
     if (!slave) {
         return;
     }
 
     GType slaveType = G_TYPE_FROM_INSTANCE(slave);
     const gchar *im_type_name = g_type_name(slaveType);
     if (strcmp(im_type_name, "GtkIMContextIIIM") == 0) {
         // Add a reference to prevent the IIIM module from being unloaded
--- a/widget/gtk/NativeKeyBindings.cpp
+++ b/widget/gtk/NativeKeyBindings.cpp
@@ -355,23 +355,18 @@ NativeKeyBindings::GetEditCommandsIntern
                                            guint aKeyval)
 {
   guint modifiers =
     static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent)->state;
 
   gCurrentCommands = &aCommands;
 
   gHandled = false;
-#if (MOZ_WIDGET_GTK == 2)
-  gtk_bindings_activate(GTK_OBJECT(mNativeTarget),
-                        aKeyval, GdkModifierType(modifiers));
-#else
   gtk_bindings_activate(G_OBJECT(mNativeTarget),
                         aKeyval, GdkModifierType(modifiers));
-#endif
 
   gCurrentCommands = nullptr;
 
   MOZ_ASSERT(!gHandled || !aCommands.IsEmpty());
 
   return gHandled;
 }
 
--- a/widget/gtk/gtkdrawing.h
+++ b/widget/gtk/gtkdrawing.h
@@ -14,22 +14,16 @@
 
 #ifndef _GTK_DRAWING_H_
 #define _GTK_DRAWING_H_
 
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 #include <algorithm>
 
-#if (MOZ_WIDGET_GTK == 2)
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-#endif
-
 /*** type definitions ***/
 typedef struct {
   guint8 active;
   guint8 focused;
   guint8 inHover;
   guint8 disabled;
   guint8 isDefault;
   guint8 canDefault;
@@ -330,48 +324,32 @@ void moz_gtk_refresh();
 /**
  * Perform cleanup of the drawing library. You should call this function
  * when your program exits, or you no longer need the library.
  *
  * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
  */
 gint moz_gtk_shutdown();
 
-#if (MOZ_WIDGET_GTK == 2)
-/**
- * Retrieves the colormap to use for drawables passed to moz_gtk_widget_paint.
- */
-GdkColormap* moz_gtk_widget_get_colormap();
-#endif
-
 /*** Widget drawing ***/
-#if (MOZ_WIDGET_GTK == 2)
 /**
  * Paint a widget in the current theme.
  * widget:    a constant giving the widget to paint
  * drawable:  the drawable to paint to;
  *            it's colormap must be moz_gtk_widget_get_colormap().
  * rect:      the bounding rectangle for the widget
- * cliprect:  a clipprect rectangle for this painting operation
  * state:     the state of the widget.  ignored for some widgets.
  * flags:     widget-dependant flags; see the WidgetNodeType definition.
  * direction: the text direction, to draw the widget correctly LTR and RTL.
  */
 gint
-moz_gtk_widget_paint(WidgetNodeType widget, GdkDrawable* drawable,
-                     GdkRectangle* rect, GdkRectangle* cliprect,
-                     GtkWidgetState* state, gint flags,
-                     GtkTextDirection direction);
-#else
-gint
 moz_gtk_widget_paint(WidgetNodeType widget, cairo_t *cr,
                      GdkRectangle* rect,
                      GtkWidgetState* state, gint flags,
                      GtkTextDirection direction);
-#endif
 
 
 /*** Widget metrics ***/
 /**
  * Get the border size of a widget
  * left/right:  [OUT] the widget's left/right border
  * top/bottom:  [OUT] the widget's top/bottom border
  * direction:   the text direction for the widget.  Callers depend on this
@@ -569,15 +547,9 @@ gint moz_gtk_get_menu_separator_height(g
 gint moz_gtk_splitter_get_metrics(gint orientation, gint* size);
 
 /**
  * Get the YTHICKNESS of a tab (notebook extension).
  */
 gint
 moz_gtk_get_tab_thickness(WidgetNodeType aNodeType);
 
-#if (MOZ_WIDGET_GTK == 2)
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
 #endif
-
-#endif
--- a/widget/gtk/mozcontainer.cpp
+++ b/widget/gtk/mozcontainer.cpp
@@ -345,39 +345,25 @@ moz_container_realize (GtkWidget *widget
         attributes.x = allocation.x;
         attributes.y = allocation.y;
         attributes.width = allocation.width;
         attributes.height = allocation.height;
         attributes.wclass = GDK_INPUT_OUTPUT;
         attributes.visual = gtk_widget_get_visual (widget);
         attributes.window_type = GDK_WINDOW_CHILD;
 
-#if (MOZ_WIDGET_GTK == 2)
-        attributes.colormap = gtk_widget_get_colormap (widget);
-        attributes_mask |= GDK_WA_COLORMAP;
-#endif
-
         window = gdk_window_new (parent, &attributes, attributes_mask);
         gdk_window_set_user_data (window, widget);
-#if (MOZ_WIDGET_GTK == 2)
-        /* TODO GTK3? */
-        /* set the back pixmap to None so that you don't end up with the gtk
-           default which is BlackPixel */
-        gdk_window_set_back_pixmap (window, NULL, FALSE);
-#endif
     } else {
         window = parent;
         g_object_ref (window);
     }
 
     gtk_widget_set_window (widget, window);
 
-#if (MOZ_WIDGET_GTK == 2)
-    widget->style = gtk_style_attach (widget->style, widget->window);
-#endif
 }
 
 void
 moz_container_size_allocate (GtkWidget     *widget,
                              GtkAllocation *allocation)
 {
     MozContainer   *container;
     GList          *tmp_list;
--- a/widget/gtk/nsDragService.cpp
+++ b/widget/gtk/nsDragService.cpp
@@ -102,22 +102,18 @@ nsDragService::nsDragService()
 {
     // We have to destroy the hidden widget before the event loop stops
     // running.
     nsCOMPtr<nsIObserverService> obsServ =
         mozilla::services::GetObserverService();
     obsServ->AddObserver(this, "quit-application", false);
 
     // our hidden source widget
-#if (MOZ_WIDGET_GTK == 2)
-    mHiddenWidget = gtk_window_new(GTK_WINDOW_POPUP);
-#else
     // Using an offscreen window works around bug 983843.
     mHiddenWidget = gtk_offscreen_window_new();
-#endif
     // make sure that the widget is realized so that
     // we can use it as a drag source.
     gtk_widget_realize(mHiddenWidget);
     // hook up our internal signals so that we can get some feedback
     // from our drag source
     g_signal_connect(mHiddenWidget, "drag_begin",
                      G_CALLBACK(invisibleSourceDragBegin), this);
     g_signal_connect(mHiddenWidget, "drag_data_get",
@@ -430,52 +426,16 @@ nsDragService::SetAlphaPixmap(SourceSurf
 {
     GdkScreen* screen = gtk_widget_get_screen(mHiddenWidget);
 
     // Transparent drag icons need, like a lot of transparency-related things,
     // a compositing X window manager
     if (!gdk_screen_is_composited(screen))
       return false;
 
-#if (MOZ_WIDGET_GTK == 2)
-    GdkColormap* alphaColormap = gdk_screen_get_rgba_colormap(screen);
-    if (!alphaColormap)
-      return false;
-
-    GdkPixmap* pixmap = gdk_pixmap_new(nullptr, dragRect.width, dragRect.height,
-                                       gdk_colormap_get_visual(alphaColormap)->depth);
-    if (!pixmap)
-      return false;
-
-    gdk_drawable_set_colormap(GDK_DRAWABLE(pixmap), alphaColormap);
-
-    // Make a DrawTarget wrapped around the pixmap to render on
-    RefPtr<DrawTarget> dt =
-         nsWindow::GetDrawTargetForGdkDrawable(GDK_DRAWABLE(pixmap),
-                                               IntSize(dragRect.width,
-                                                       dragRect.height));
-    if (!dt)
-      return false;
-
-    // Clear it...
-    dt->ClearRect(Rect(0, 0, dragRect.width, dragRect.height));
-
-    // ...and paint the drag image with translucency
-    dt->DrawSurface(aSurface,
-                    Rect(0, 0, dragRect.width, dragRect.height),
-                    Rect(0, 0, dragRect.width, dragRect.height),
-                    DrawSurfaceOptions(),
-                    DrawOptions(DRAG_IMAGE_ALPHA_LEVEL, CompositionOp::OP_SOURCE));
-
-    // The drag transaction addrefs the pixmap, so we can just unref it from us here
-    gtk_drag_set_icon_pixmap(aContext, alphaColormap, pixmap, nullptr,
-                             aXOffset, aYOffset);
-    g_object_unref(pixmap);
-    return true;
-#else
 #ifdef cairo_image_surface_create
 #error "Looks like we're including Mozilla's cairo instead of system cairo"
 #endif
     // Prior to GTK 3.9.12, cairo surfaces passed into gtk_drag_set_icon_surface
     // had their shape information derived from the alpha channel and used with
     // the X SHAPE extension instead of being displayed as an ARGB window.
     // See bug 1249604.
     if (gtk_check_version(3, 9, 12))
@@ -513,17 +473,16 @@ nsDragService::SetAlphaPixmap(SourceSurf
     if (sCairoSurfaceSetDeviceScalePtr) {
         gint scale = ScreenHelperGTK::GetGTKMonitorScaleFactor();
         sCairoSurfaceSetDeviceScalePtr(surf, scale, scale);
     }
 
     gtk_drag_set_icon_surface(aContext, surf);
     cairo_surface_destroy(surf);
     return true;
-#endif
 }
 
 NS_IMETHODIMP
 nsDragService::StartDragSession()
 {
     MOZ_LOG(sDragLm, LogLevel::Debug, ("nsDragService::StartDragSession"));
     return nsBaseDragService::StartDragSession();
 }
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -727,60 +727,16 @@ nsNativeThemeGTK::GetGtkWidgetAndState(u
     break;
   default:
     return false;
   }
 
   return true;
 }
 
-#if (MOZ_WIDGET_GTK == 2)
-class ThemeRenderer : public gfxGdkNativeRenderer {
-public:
-  ThemeRenderer(GtkWidgetState aState, WidgetNodeType aGTKWidgetType,
-                gint aFlags, GtkTextDirection aDirection,
-                const GdkRectangle& aGDKRect, const GdkRectangle& aGDKClip)
-    : mState(aState), mGTKWidgetType(aGTKWidgetType), mFlags(aFlags),
-      mDirection(aDirection), mGDKRect(aGDKRect), mGDKClip(aGDKClip) {}
-  nsresult DrawWithGDK(GdkDrawable * drawable, gint offsetX, gint offsetY,
-                       GdkRectangle * clipRects, uint32_t numClipRects);
-private:
-  GtkWidgetState mState;
-  WidgetNodeType mGTKWidgetType;
-  gint mFlags;
-  GtkTextDirection mDirection;
-  const GdkRectangle& mGDKRect;
-  const GdkRectangle& mGDKClip;
-};
-
-nsresult
-ThemeRenderer::DrawWithGDK(GdkDrawable * drawable, gint offsetX, 
-        gint offsetY, GdkRectangle * clipRects, uint32_t numClipRects)
-{
-  GdkRectangle gdk_rect = mGDKRect;
-  gdk_rect.x += offsetX;
-  gdk_rect.y += offsetY;
-
-  GdkRectangle gdk_clip = mGDKClip;
-  gdk_clip.x += offsetX;
-  gdk_clip.y += offsetY;
-
-  GdkRectangle surfaceRect;
-  surfaceRect.x = 0;
-  surfaceRect.y = 0;
-  gdk_drawable_get_size(drawable, &surfaceRect.width, &surfaceRect.height);
-  gdk_rectangle_intersect(&gdk_clip, &surfaceRect, &gdk_clip);
-  
-  NS_ASSERTION(numClipRects == 0, "We don't support clipping!!!");
-  moz_gtk_widget_paint(mGTKWidgetType, drawable, &gdk_rect, &gdk_clip,
-                       &mState, mFlags, mDirection);
-
-  return NS_OK;
-}
-#else
 class SystemCairoClipper : public ClipExporter {
 public:
   explicit SystemCairoClipper(cairo_t* aContext) : mContext(aContext)
   {
   }
 
   void
   BeginClip(const Matrix& aTransform) override
@@ -1019,17 +975,16 @@ DrawThemeWithCairo(gfxContext* aContext,
       }
 
       if (surf) {
         cairo_surface_destroy(surf);
       }
     }
   }
 }
-#endif
 
 bool
 nsNativeThemeGTK::GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType,
                                         nsIntMargin* aExtra)
 {
   *aExtra = nsIntMargin(0,0,0,0);
   // Allow an extra one pixel above and below the thumb for certain
   // GTK2 themes (Ximian Industrial, Bluecurve, Misty, at least);
@@ -1167,52 +1122,20 @@ nsNativeThemeGTK::DrawWidgetBackground(g
   GdkRectangle gdk_rect = {-drawingRect.x/scaleFactor,
                            -drawingRect.y/scaleFactor,
                            widgetRect.width/scaleFactor,
                            widgetRect.height/scaleFactor};
 
   // translate everything so (0,0) is the top left of the drawingRect
   gfxPoint origin = rect.TopLeft() + drawingRect.TopLeft();
 
-#if (MOZ_WIDGET_GTK == 2)
-  gfxContextAutoSaveRestore autoSR(ctx);
-  gfxMatrix matrix;
-  if (!snapped) { // else rects are in device coords
-    matrix = ctx->CurrentMatrixDouble();
-  }
-  matrix.Translate(origin);
-  matrix.Scale(scaleFactor, scaleFactor); // Draw in GDK coords
-  ctx->SetMatrixDouble(matrix);
-
-  // The gdk_clip is just advisory here, meaning "you don't
-  // need to draw outside this rect if you don't feel like it!"
-  GdkRectangle gdk_clip = {0, 0, drawingRect.width, drawingRect.height};
-
-  ThemeRenderer renderer(state, gtkWidgetType, flags, direction,
-                         gdk_rect, gdk_clip);
-
-  // Some themes (e.g. Clearlooks) just don't clip properly to any
-  // clip rect we provide, so we cannot advertise support for clipping within
-  // the widget bounds.
-  uint32_t rendererFlags = 0;
-  if (transparency == eOpaque) {
-    rendererFlags |= gfxGdkNativeRenderer::DRAW_IS_OPAQUE;
-  }
-
-  // GtkStyles (used by the widget drawing backend) are created for a
-  // particular colormap/visual.
-  GdkColormap* colormap = moz_gtk_widget_get_colormap();
-
-  renderer.Draw(ctx, drawingRect.Size(), rendererFlags, colormap);
-#else 
   DrawThemeWithCairo(ctx, aContext->GetDrawTarget(),
                      state, gtkWidgetType, flags, direction, scaleFactor,
                      snapped, ToPoint(origin), drawingRect.Size(),
                      gdk_rect, transparency);
-#endif
 
   if (!safeState) {
     gdk_flush();
     gLastGdkError = gdk_error_trap_pop ();
 
     if (gLastGdkError) {
 #ifdef DEBUG
       printf("GTK theme failed for widget type %d, error was %d, state was "
@@ -1963,20 +1886,16 @@ nsNativeThemeGTK::ThemeNeedsComboboxDrop
   return false;
 }
 
 nsITheme::Transparency
 nsNativeThemeGTK::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType)
 {
   switch (aWidgetType) {
   // These widgets always draw a default background.
-#if (MOZ_WIDGET_GTK == 2)
-  case NS_THEME_TOOLBAR:
-  case NS_THEME_MENUBAR:
-#endif
   case NS_THEME_MENUPOPUP:
   case NS_THEME_WINDOW:
   case NS_THEME_DIALOG:
     return eOpaque;
   case NS_THEME_SCROLLBAR_VERTICAL:
   case NS_THEME_SCROLLBAR_HORIZONTAL:
 #ifdef MOZ_WIDGET_GTK
     // Make scrollbar tracks opaque on the window's scroll frame to prevent
@@ -1985,17 +1904,13 @@ nsNativeThemeGTK::GetWidgetTransparency(
           aFrame->PresContext()->IsRootContentDocument() &&
           IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)))
       return eTransparent;
 #endif
     return eOpaque;
   // Tooltips use gtk_paint_flat_box() on Gtk2
   // but are shaped on Gtk3
   case NS_THEME_TOOLTIP:
-#if (MOZ_WIDGET_GTK == 2)
-    return eOpaque;
-#else
     return eTransparent;
-#endif
   }
 
   return eUnknownTransparency;
 }
--- a/widget/gtk/nsPrintDialogGTK.cpp
+++ b/widget/gtk/nsPrintDialogGTK.cpp
@@ -52,21 +52,17 @@ ShowCustomDialog(GtkComboBox *changed_bo
        do_GetService(NS_STRINGBUNDLE_CONTRACTID);
 
   nsCOMPtr<nsIStringBundle> printBundle;
   bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", getter_AddRefs(printBundle));
   nsAutoString intlString;
 
   printBundle->GetStringFromName("headerFooterCustom", intlString);
   GtkWidget* prompt_dialog = gtk_dialog_new_with_buttons(NS_ConvertUTF16toUTF8(intlString).get(), printDialog,
-#if (MOZ_WIDGET_GTK == 2)
-                                                         (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
-#else
                                                          (GtkDialogFlags)(GTK_DIALOG_MODAL),
-#endif
                                                          GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
                                                          GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
                                                          nullptr);
   gtk_dialog_set_default_response(GTK_DIALOG(prompt_dialog), GTK_RESPONSE_ACCEPT);
   gtk_dialog_set_alternative_button_order(GTK_DIALOG(prompt_dialog),
                                           GTK_RESPONSE_ACCEPT,
                                           GTK_RESPONSE_REJECT,
                                           -1);
@@ -462,33 +458,25 @@ nsPrintDialogWidgetGTK::ExportSettings(n
   if (settings)
     g_object_unref(settings);
   return NS_OK;
 }
 
 GtkWidget*
 nsPrintDialogWidgetGTK::ConstructHeaderFooterDropdown(const char16_t *currentString)
 {
-#if (MOZ_WIDGET_GTK == 2)
-  GtkWidget* dropdown = gtk_combo_box_new_text();
-#else
   GtkWidget* dropdown = gtk_combo_box_text_new();
-#endif
   const char hf_options[][22] = {"headerFooterBlank", "headerFooterTitle",
                                  "headerFooterURL", "headerFooterDate",
                                  "headerFooterPage", "headerFooterPageTotal",
                                  "headerFooterCustom"};
 
   for (unsigned int i = 0; i < ArrayLength(hf_options); i++) {
-#if (MOZ_WIDGET_GTK == 2)
-    gtk_combo_box_append_text(GTK_COMBO_BOX(dropdown), GetUTF8FromBundle(hf_options[i]).get());
-#else
-    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(dropdown), nullptr, 
+    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(dropdown), nullptr,
                               GetUTF8FromBundle(hf_options[i]).get());
-#endif
   }
 
   bool shouldBeCustom = true;
   NS_ConvertUTF16toUTF8 currentStringUTF8(currentString);
 
   for (unsigned int i = 0; i < ArrayLength(header_footer_tags); i++) {
     if (!strcmp(currentStringUTF8.get(), header_footer_tags[i])) {
       gtk_combo_box_set_active(GTK_COMBO_BOX(dropdown), i);
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -45,25 +45,19 @@
 #endif /* MOZ_WAYLAND */
 
 #ifdef MOZ_X11
 #include <gdk/gdkx.h>
 #include <X11/Xatom.h>
 #include <X11/extensions/XShm.h>
 #include <X11/extensions/shape.h>
 #include <gdk/gdkkeysyms-compat.h>
-#if (MOZ_WIDGET_GTK == 2)
-#include "gtk2xtbin.h"
-#endif
 #endif /* MOZ_X11 */
 
 #include <gdk/gdkkeysyms.h>
-#if (MOZ_WIDGET_GTK == 2)
-#include <gtk/gtkprivate.h>
-#endif
 
 #if defined(MOZ_WAYLAND)
 #include <gdk/gdkwayland.h>
 #endif
 
 #include "nsGkAtoms.h"
 
 #ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
@@ -175,23 +169,18 @@ static GdkCursor *get_gtk_cursor(nsCurso
 static GdkWindow *get_inner_gdk_window (GdkWindow *aWindow,
                                         gint x, gint y,
                                         gint *retx, gint *rety);
 
 static int    is_parent_ungrab_enter(GdkEventCrossing *aEvent);
 static int    is_parent_grab_leave(GdkEventCrossing *aEvent);
 
 /* callbacks from widgets */
-#if (MOZ_WIDGET_GTK == 2)
-static gboolean expose_event_cb           (GtkWidget *widget,
-                                           GdkEventExpose *event);
-#else
 static gboolean expose_event_cb           (GtkWidget *widget,
                                            cairo_t *rect);
-#endif
 static gboolean configure_event_cb        (GtkWidget *widget,
                                            GdkEventConfigure *event);
 static void     container_unrealize_cb    (GtkWidget *widget);
 static void     size_allocate_cb          (GtkWidget *widget,
                                            GtkAllocation *allocation);
 static gboolean delete_event_cb           (GtkWidget *widget,
                                            GdkEventAny *event);
 static gboolean enter_notify_event_cb     (GtkWidget *widget,
@@ -385,17 +374,17 @@ static GtkWidget *gInvisibleContainer = 
 
 // Sometimes this actually also includes the state of the modifier keys, but
 // only the button state bits are used.
 static guint gButtonState;
 
 static inline int32_t
 GetBitmapStride(int32_t width)
 {
-#if defined(MOZ_X11) || (MOZ_WIDGET_GTK == 2)
+#if defined(MOZ_X11)
   return (width+7)/8;
 #else
   return cairo_format_stride_for_width(CAIRO_FORMAT_A1, width);
 #endif
 }
 
 static inline bool TimestampIsNewerThan(guint32 a, guint32 b)
 {
@@ -1981,21 +1970,17 @@ gdk_window_flash(GdkWindow *    aGdkWind
   gint         x;
   gint         y;
   gint         width;
   gint         height;
   guint        i;
   GdkGC *      gc = 0;
   GdkColor     white;
 
-#if (MOZ_WIDGET_GTK == 2)
-  gdk_window_get_geometry(aGdkWindow,nullptr,nullptr,&width,&height,nullptr);
-#else
   gdk_window_get_geometry(aGdkWindow,nullptr,nullptr,&width,&height);
-#endif
 
   gdk_window_get_origin (aGdkWindow,
                          &x,
                          &y);
 
   gc = gdk_gc_new(gdk_get_default_root_window());
 
   white.pixel = WhitePixel(gdk_display,DefaultScreen(gdk_display));
@@ -2029,40 +2014,16 @@ gdk_window_flash(GdkWindow *    aGdkWind
   gdk_gc_destroy(gc);
 
   gdk_region_offset(aRegion, -x, -y);
 }
 #endif /* MOZ_X11 */
 #endif // DEBUG
 #endif
 
-#if (MOZ_WIDGET_GTK == 2)
-static bool
-ExtractExposeRegion(LayoutDeviceIntRegion& aRegion, GdkEventExpose* aEvent)
-{
-  GdkRectangle* rects;
-  gint nrects;
-  gdk_region_get_rectangles(aEvent->region, &rects, &nrects);
-
-  if (nrects > MAX_RECTS_IN_REGION) {
-      // Just use the bounding box
-      rects[0] = aEvent->area;
-      nrects = 1;
-  }
-
-  for (GdkRectangle* r = rects; r < rects + nrects; r++) {
-      aRegion.Or(aRegion, LayoutDeviceIntRect(r->x, r->y, r->width, r->height));
-      LOGDRAW(("\t%d %d %d %d\n", r->x, r->y, r->width, r->height));
-  }
-
-  g_free(rects);
-  return true;
-}
-
-#else
 # ifdef cairo_copy_clip_rectangle_list
 #  error "Looks like we're including Mozilla's cairo instead of system cairo"
 # endif
 static bool
 ExtractExposeRegion(LayoutDeviceIntRegion& aRegion, cairo_t* cr)
 {
   cairo_rectangle_list_t* rects = cairo_copy_clip_rectangle_list(cr);
   if (rects->status != CAIRO_STATUS_SUCCESS) {
@@ -2074,25 +2035,19 @@ ExtractExposeRegion(LayoutDeviceIntRegio
       const cairo_rectangle_t& r = rects->rectangles[i];
       aRegion.Or(aRegion, LayoutDeviceIntRect::Truncate(r.x, r.y, r.width, r.height));
       LOGDRAW(("\t%f %f %f %f\n", r.x, r.y, r.width, r.height));
   }
 
   cairo_rectangle_list_destroy(rects);
   return true;
 }
-#endif
-
-#if (MOZ_WIDGET_GTK == 2)
-gboolean
-nsWindow::OnExposeEvent(GdkEventExpose *aEvent)
-#else
+
 gboolean
 nsWindow::OnExposeEvent(cairo_t *cr)
-#endif
 {
     // Send any pending resize events so that layout can update.
     // May run event loop.
     MaybeDispatchResized();
 
     if (mIsDestroyed) {
         return FALSE;
     }
@@ -2101,21 +2056,17 @@ nsWindow::OnExposeEvent(cairo_t *cr)
     if (!mGdkWindow || mIsFullyObscured || !mHasMappedToplevel)
         return FALSE;
 
     nsIWidgetListener *listener = GetListener();
     if (!listener)
         return FALSE;
 
     LayoutDeviceIntRegion exposeRegion;
-#if (MOZ_WIDGET_GTK == 2)
-    if (!ExtractExposeRegion(exposeRegion, aEvent)) {
-#else
     if (!ExtractExposeRegion(exposeRegion, cr)) {
-#endif
         return FALSE;
     }
 
     gint scale = GdkScaleFactor();
     LayoutDeviceIntRegion region = exposeRegion;
     region.ScaleRoundOut(scale, scale);
 
     if (GetLayerManager()->AsKnowsCompositor() && mCompositorSession) {
@@ -2309,29 +2260,21 @@ nsWindow::OnExposeEvent(cairo_t *cr)
 
 #endif // MOZ_X11
 
     EndRemoteDrawingInRegion(dt, region);
 
     listener->DidPaintWindow();
 
     // Synchronously flush any new dirty areas
-#if (MOZ_WIDGET_GTK == 2)
-    GdkRegion* dirtyArea = gdk_window_get_update_area(mGdkWindow);
-#else
     cairo_region_t* dirtyArea = gdk_window_get_update_area(mGdkWindow);
-#endif
 
     if (dirtyArea) {
         gdk_window_invalidate_region(mGdkWindow, dirtyArea, false);
-#if (MOZ_WIDGET_GTK == 2)
-        gdk_region_destroy(dirtyArea);
-#else
         cairo_region_destroy(dirtyArea);
-#endif
         gdk_window_process_updates(mGdkWindow, false);
     }
 
     // check the return value!
     return TRUE;
 }
 
 void
@@ -3555,31 +3498,19 @@ CreateGdkWindow(GdkWindow *parent, GtkWi
     attributes.event_mask = kEvents;
 
     attributes.width = 1;
     attributes.height = 1;
     attributes.wclass = GDK_INPUT_OUTPUT;
     attributes.visual = gtk_widget_get_visual(widget);
     attributes.window_type = GDK_WINDOW_CHILD;
 
-#if (MOZ_WIDGET_GTK == 2)
-    attributes_mask |= GDK_WA_COLORMAP;
-    attributes.colormap = gtk_widget_get_colormap(widget);
-#endif
-
     GdkWindow *window = gdk_window_new(parent, &attributes, attributes_mask);
     gdk_window_set_user_data(window, widget);
 
-// GTK3 TODO?
-#if (MOZ_WIDGET_GTK == 2)
-    /* set the default pixmap to None so that you don't end up with the
-       gtk default which is BlackPixel. */
-    gdk_window_set_back_pixmap(window, nullptr, FALSE);
-#endif
-
     return window;
 }
 
 nsresult
 nsWindow::Create(nsIWidget* aParent,
                  nsNativeWidget aNativeParent,
                  const LayoutDeviceIntRect& aRect,
                  nsWidgetInitData* aInitData)
@@ -3683,23 +3614,18 @@ nsWindow::Create(nsIWidget* aParent,
 
         // We need to select an ARGB visual here instead of in
         // SetTransparencyMode() because it has to be done before the
         // widget is realized.  An ARGB visual is only useful if we
         // are on a compositing window manager.
         if (useAlphaVisual) {
             GdkScreen *screen = gtk_widget_get_screen(mShell);
             if (gdk_screen_is_composited(screen)) {
-#if (MOZ_WIDGET_GTK == 2)
-                GdkColormap *colormap = gdk_screen_get_rgba_colormap(screen);
-                gtk_widget_set_colormap(mShell, colormap);
-#else
                 GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
                 gtk_widget_set_visual(mShell, visual);
-#endif
             }
         }
 
         // We only move a general managed toplevel window if someone has
         // actually placed the window somewhere.  If no placement has taken
         // place, we just let the window manager Do The Right Thing.
         NativeResize();
 
@@ -3857,29 +3783,21 @@ nsWindow::Create(nsIWidget* aParent,
             if (aInitData->mNoAutoHide) {
                 gint wmd = ConvertBorderStyles(mBorderStyle);
                 if (wmd != -1)
                   gdk_window_set_decorations(mGdkWindow, (GdkWMDecoration) wmd);
             }
 
             // If the popup ignores mouse events, set an empty input shape.
             if (aInitData->mMouseTransparent) {
-#if (MOZ_WIDGET_GTK == 2)
-              GdkRectangle rect = { 0, 0, 0, 0 };
-              GdkRegion *region = gdk_region_rectangle(&rect);
-
-              gdk_window_input_shape_combine_region(mGdkWindow, region, 0, 0);
-              gdk_region_destroy(region);
-#else
               cairo_rectangle_int_t rect = { 0, 0, 0, 0 };
               cairo_region_t *region = cairo_region_create_rectangle(&rect);
 
               gdk_window_input_shape_combine_region(mGdkWindow, region, 0, 0);
               cairo_region_destroy(region);
-#endif
             }
         }
     }
         break;
 
     case eWindowType_plugin:
     case eWindowType_plugin_ipc_chrome:
     case eWindowType_plugin_ipc_content:
@@ -3970,23 +3888,18 @@ nsWindow::Create(nsIWidget* aParent,
         g_signal_connect(mContainer, "hierarchy-changed",
                          G_CALLBACK(hierarchy_changed_cb), nullptr);
         g_signal_connect(mContainer, "notify::scale-factor",
                          G_CALLBACK(scale_changed_cb), nullptr);
         // Initialize mHasMappedToplevel.
         hierarchy_changed_cb(GTK_WIDGET(mContainer), nullptr);
         // Expose, focus, key, and drag events are sent even to GTK_NO_WINDOW
         // widgets.
-#if (MOZ_WIDGET_GTK == 2)
-        g_signal_connect(mContainer, "expose_event",
-                         G_CALLBACK(expose_event_cb), nullptr);
-#else
         g_signal_connect(G_OBJECT(mContainer), "draw",
                          G_CALLBACK(expose_event_cb), nullptr);
-#endif
         g_signal_connect(mContainer, "focus_in_event",
                          G_CALLBACK(focus_in_event_cb), nullptr);
         g_signal_connect(mContainer, "focus_out_event",
                          G_CALLBACK(focus_out_event_cb), nullptr);
         g_signal_connect(mContainer, "key_press_event",
                          G_CALLBACK(key_press_event_cb), nullptr);
         g_signal_connect(mContainer, "key_release_event",
                          G_CALLBACK(key_release_event_cb), nullptr);
@@ -4028,20 +3941,16 @@ nsWindow::Create(nsIWidget* aParent,
     } else if (!mIMContext) {
         nsWindow *container = GetContainerWindow();
         if (container) {
             mIMContext = container->mIMContext;
         }
     }
 
     if (eventWidget) {
-#if (MOZ_WIDGET_GTK == 2)
-        // Don't let GTK mess with the shapes of our GdkWindows
-        GTK_PRIVATE_SET_FLAG(eventWidget, GTK_HAS_SHAPE_MASK);
-#endif
 
         // These events are sent to the owning widget of the relevant window
         // and propagate up to the first widget that handles the events, so we
         // need only connect on mShell, if it exists, to catch events on its
         // window and windows of mContainer.
         g_signal_connect(eventWidget, "enter-notify-event",
                          G_CALLBACK(enter_notify_event_cb), nullptr);
         g_signal_connect(eventWidget, "leave-notify-event",
@@ -4554,37 +4463,25 @@ nsWindow::SetWindowClipRegion(const nsTA
     if (IsWindowClipRegionEqual(*newRects))
         return NS_OK;
 
     StoreWindowClipRegion(*newRects);
 
     if (!mGdkWindow)
         return NS_OK;
 
-#if (MOZ_WIDGET_GTK == 2)
-    GdkRegion *region = gdk_region_new(); // aborts on OOM
-    for (uint32_t i = 0; i < newRects->Length(); ++i) {
-        const LayoutDeviceIntRect& r = newRects->ElementAt(i);
-        GdkRectangle rect = { r.x, r.y, r.width, r.height };
-        gdk_region_union_with_rect(region, &rect);
-    }
-
-    gdk_window_shape_combine_region(mGdkWindow, region, 0, 0);
-    gdk_region_destroy(region);
-#else
     cairo_region_t *region = cairo_region_create();
     for (uint32_t i = 0; i < newRects->Length(); ++i) {
         const LayoutDeviceIntRect& r = newRects->ElementAt(i);
         cairo_rectangle_int_t rect = { r.x, r.y, r.width, r.height };
         cairo_region_union_rectangle(region, &rect);
     }
 
     gdk_window_shape_combine_region(mGdkWindow, region, 0, 0);
     cairo_region_destroy(region);
-#endif
 
     return NS_OK;
 }
 
 void
 nsWindow::ResizeTransparencyBitmap()
 {
     if (!mTransparencyBitmap)
@@ -4683,41 +4580,29 @@ nsWindow::ApplyTransparencyBitmap()
                                               mTransparencyBitmap,
                                               mTransparencyBitmapWidth,
                                               mTransparencyBitmapHeight);
     XShapeCombineMask(xDisplay, xDrawable,
                       ShapeBounding, 0, 0,
                       maskPixmap, ShapeSet);
     XFreePixmap(xDisplay, maskPixmap);
 #else
-#if (MOZ_WIDGET_GTK == 2)
-    gtk_widget_reset_shapes(mShell);
-    GdkBitmap* maskBitmap = gdk_bitmap_create_from_data(mGdkWindow,
-            mTransparencyBitmap,
-            mTransparencyBitmapWidth, mTransparencyBitmapHeight);
-    if (!maskBitmap)
-        return;
-
-    gtk_widget_shape_combine_mask(mShell, maskBitmap, 0, 0);
-    g_object_unref(maskBitmap);
-#else
     cairo_surface_t *maskBitmap;
     maskBitmap = cairo_image_surface_create_for_data((unsigned char*)mTransparencyBitmap,
                                                      CAIRO_FORMAT_A1,
                                                      mTransparencyBitmapWidth,
                                                      mTransparencyBitmapHeight,
                                                      GetBitmapStride(mTransparencyBitmapWidth));
     if (!maskBitmap)
         return;
 
     cairo_region_t * maskRegion = gdk_cairo_region_create_from_surface(maskBitmap);
     gtk_widget_shape_combine_region(mShell, maskRegion);
     cairo_region_destroy(maskRegion);
     cairo_surface_destroy(maskBitmap);
-#endif // MOZ_WIDGET_GTK == 2
 #endif // MOZ_X11
 }
 
 void
 nsWindow::ClearTransparencyBitmap()
 {
     if (!mTransparencyBitmap)
         return;
@@ -5283,22 +5168,18 @@ is_mouse_in_window (GdkWindow* aWindow, 
             break;
         }
 
         offsetX += tmpX;
         offsetY += tmpY;
         window = gdk_window_get_parent(window);
     }
 
-#if (MOZ_WIDGET_GTK == 2)
-    gdk_drawable_get_size(aWindow, &w, &h);
-#else
     w = gdk_window_get_width(aWindow);
     h = gdk_window_get_height(aWindow);
-#endif
 
     if (aMouseX > x && aMouseX < x + w &&
         aMouseY > y && aMouseY < y + h)
         return true;
 
     return false;
 }
 
@@ -5544,28 +5425,16 @@ get_gtk_cursor(nsCursor aCursor)
 
     gCursorCache[aCursor] = gdkcursor;
 
     return gdkcursor;
 }
 
 // gtk callbacks
 
-#if (MOZ_WIDGET_GTK == 2)
-static gboolean
-expose_event_cb(GtkWidget *widget, GdkEventExpose *event)
-{
-    RefPtr<nsWindow> window = get_window_for_gdk_window(event->window);
-    if (!window)
-        return FALSE;
-
-    window->OnExposeEvent(event);
-    return FALSE;
-}
-#else
 void
 draw_window_of_widget(GtkWidget *widget, GdkWindow *aWindow, cairo_t *cr)
 {
     if (gtk_cairo_should_draw_window(cr, aWindow)) {
         RefPtr<nsWindow> window = get_window_for_gdk_window(aWindow);
         if (!window) {
             NS_WARNING("Cannot get nsWindow from GtkWidget");
         }
@@ -5607,17 +5476,16 @@ expose_event_cb(GtkWidget *widget, cairo
         [](gpointer data) -> gboolean {
             g_object_unref(data);
             return G_SOURCE_REMOVE;
         },
         widget);
 
     return FALSE;
 }
-#endif //MOZ_WIDGET_GTK == 2
 
 static gboolean
 configure_event_cb(GtkWidget *widget,
                    GdkEventConfigure *event)
 {
     RefPtr<nsWindow> window = get_window_for_gtk_widget(widget);
     if (!window)
         return FALSE;
@@ -6218,21 +6086,17 @@ get_inner_gdk_window (GdkWindow *aWindow
 {
     gint cx, cy, cw, ch;
     GList *children = gdk_window_peek_children(aWindow);
     for (GList *child = g_list_last(children);
          child;
          child = g_list_previous(child)) {
         auto *childWindow = (GdkWindow *) child->data;
         if (get_window_for_gdk_window(childWindow)) {
-#if (MOZ_WIDGET_GTK == 2)
-            gdk_window_get_geometry(childWindow, &cx, &cy, &cw, &ch, nullptr);
-#else
             gdk_window_get_geometry(childWindow, &cx, &cy, &cw, &ch);
-#endif
             if ((cx < x) && (x < (cx + cw)) &&
                 (cy < y) && (y < (cy + ch)) &&
                 gdk_window_is_visible(childWindow)) {
                 return get_inner_gdk_window(childWindow,
                                             x - cx, y - cy,
                                             retx, rety);
             }
         }
@@ -6430,63 +6294,16 @@ nsWindow::GetEditCommands(NativeKeyBindi
             return;
         }
     }
 
     NativeKeyBindings* keyBindings = NativeKeyBindings::GetInstance(aType);
     keyBindings->GetEditCommands(aEvent, aCommands);
 }
 
-#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2)
-/* static */ already_AddRefed<DrawTarget>
-nsWindow::GetDrawTargetForGdkDrawable(GdkDrawable* aDrawable,
-                                      const IntSize& aSize)
-{
-    GdkVisual* visual = gdk_drawable_get_visual(aDrawable);
-    Screen* xScreen =
-        gdk_x11_screen_get_xscreen(gdk_drawable_get_screen(aDrawable));
-    Display* xDisplay = DisplayOfScreen(xScreen);
-    Drawable xDrawable = gdk_x11_drawable_get_xid(aDrawable);
-
-    RefPtr<gfxASurface> surface;
-
-    if (visual) {
-        Visual* xVisual = gdk_x11_visual_get_xvisual(visual);
-
-        surface = new gfxXlibSurface(xDisplay, xDrawable, xVisual, aSize);
-    } else {
-        // no visual? we must be using an xrender format.  Find a format
-        // for this depth.
-        XRenderPictFormat *pf = nullptr;
-        switch (gdk_drawable_get_depth(aDrawable)) {
-            case 32:
-                pf = XRenderFindStandardFormat(xDisplay, PictStandardARGB32);
-                break;
-            case 24:
-                pf = XRenderFindStandardFormat(xDisplay, PictStandardRGB24);
-                break;
-            default:
-                NS_ERROR("Don't know how to handle the given depth!");
-                break;
-        }
-
-        surface = new gfxXlibSurface(xScreen, xDrawable, pf, aSize);
-    }
-
-    RefPtr<DrawTarget> dt =
-        gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surface, aSize);
-
-    if (!dt || !dt->IsValid()) {
-        return nullptr;
-    }
-
-    return dt.forget();
-}
-#endif
-
 already_AddRefed<DrawTarget>
 nsWindow::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion, BufferMode* aBufferMode)
 {
   return mSurfaceProvider.StartRemoteDrawingInRegion(aInvalidRegion, aBufferMode);
 }
 
 void
 nsWindow::EndRemoteDrawingInRegion(DrawTarget* aDrawTarget,
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -170,21 +170,17 @@ public:
 
     // utility method, -1 if no change should be made, otherwise returns a
     // value that can be passed to gdk_window_set_decorations
     gint               ConvertBorderStyles(nsBorderStyle aStyle);
 
     GdkRectangle DevicePixelsToGdkRectRoundOut(LayoutDeviceIntRect aRect);
 
     // event callbacks
-#if (MOZ_WIDGET_GTK == 2)
-    gboolean           OnExposeEvent(GdkEventExpose *aEvent);
-#else
     gboolean           OnExposeEvent(cairo_t *cr);
-#endif
     gboolean           OnConfigureEvent(GtkWidget *aWidget,
                                         GdkEventConfigure *aEvent);
     void               OnContainerUnrealize();
     void               OnSizeAllocate(GtkAllocation *aAllocation);
     void               OnDeleteEvent();
     void               OnEnterNotifyEvent(GdkEventCrossing *aEvent);
     void               OnLeaveNotifyEvent(GdkEventCrossing *aEvent);
     void               OnMotionNotifyEvent(GdkEventMotion *aEvent);
@@ -313,20 +309,16 @@ public:
    virtual nsTransparencyMode GetTransparencyMode() override;
 #if (MOZ_WIDGET_GTK >= 3)
    virtual void        UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) override;
 #endif
    virtual nsresult    ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
    nsresult            UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
                                                             uint8_t* aAlphas, int32_t aStride);
 
-#if (MOZ_WIDGET_GTK == 2)
-    static already_AddRefed<DrawTarget> GetDrawTargetForGdkDrawable(GdkDrawable* aDrawable,
-                                                                    const mozilla::gfx::IntSize& aSize);
-#endif
     virtual void       ReparentNativeWidget(nsIWidget* aNewParent) override;
 
     virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
                                                 uint32_t aNativeMessage,
                                                 uint32_t aModifierFlags,
                                                 nsIObserver* aObserver) override;
 
     virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
--- a/xpcom/base/nsSystemInfo.cpp
+++ b/xpcom/base/nsSystemInfo.cpp
@@ -710,27 +710,16 @@ nsSystemInfo::Init()
 
 #if defined(MOZ_WIDGET_GTK)
   // This must be done here because NSPR can only separate OS's when compiled, not libraries.
   // 64 bytes is going to be well enough for "GTK " followed by 3 integers
   // separated with dots.
   char gtkver[64];
   ssize_t gtkver_len = 0;
 
-#if MOZ_WIDGET_GTK == 2
-  extern int gtk_read_end_of_the_pipe;
-
-  if (gtk_read_end_of_the_pipe != -1) {
-    do {
-      gtkver_len = read(gtk_read_end_of_the_pipe, &gtkver, sizeof(gtkver));
-    } while (gtkver_len < 0 && errno == EINTR);
-    close(gtk_read_end_of_the_pipe);
-  }
-#endif
-
   if (gtkver_len <= 0) {
     gtkver_len = SprintfLiteral(gtkver, "GTK %u.%u.%u", gtk_major_version,
                                 gtk_minor_version, gtk_micro_version);
   }
 
   nsAutoCString secondaryLibrary;
   if (gtkver_len > 0 && gtkver_len < int(sizeof(gtkver))) {
     secondaryLibrary.Append(nsDependentCSubstring(gtkver, gtkver_len));
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -507,22 +507,16 @@ XRE_API(void,
 
 XRE_API(void,
         XRE_EnableSameExecutableForContentProc, ())
 
 XRE_API(int,
         XRE_XPCShellMain, (int argc, char** argv, char** envp,
                            const XREShellData* aShellData))
 
-#if MOZ_WIDGET_GTK == 2
-XRE_API(void,
-        XRE_GlibInit, ())
-#endif
-
-
 #ifdef LIBFUZZER
 #include "LibFuzzerRegistry.h"
 
 XRE_API(void,
         XRE_LibFuzzerSetDriver, (LibFuzzerDriver))
 
 #endif // LIBFUZZER
 
--- a/xpcom/glue/standalone/nsXPCOMGlue.cpp
+++ b/xpcom/glue/standalone/nsXPCOMGlue.cpp
@@ -358,25 +358,16 @@ public:
       // initializers, so this needs to happen before glib is loaded, which is
       // this is hooked in XPCOMGlueStartup before libxul is loaded. This
       // relies on the main executable not depending on glib.
       setenv("G_SLICE", "always-malloc", 1);
     }
   }
 
   ~GSliceInit() {
-#if MOZ_WIDGET_GTK == 2
-    if (sTop) {
-      auto XRE_GlibInit = (void (*)(void)) GetSymbol(sTop->libHandle,
-        "XRE_GlibInit");
-      // Initialize glib enough for G_SLICE to have an effect before it is unset.
-      // unset.
-      XRE_GlibInit();
-    }
-#endif
     if (!mHadGSlice) {
       unsetenv("G_SLICE");
     }
   }
 
 private:
   bool mHadGSlice;
 };