Bug 1278282 - Replace #if (MOZ_WIDGET_GTK == 3) by #ifdef MOZ_WIDGET_GTK r=lsalzman
authorSylvestre Ledru <sledru@mozilla.com>
Tue, 09 Jan 2018 11:51:07 +0100
changeset 450517 07457a9823d374c3ef19b4034c6f56cc6d80bf8d
parent 450516 0054a15e3c89ca79eaf91817aeffe5e9ff40f923
child 450518 64a1d5998ef049326e6662e74cec56ac656efd2b
push id8528
push userryanvm@gmail.com
push dateFri, 12 Jan 2018 02:17:15 +0000
treeherdermozilla-beta@713625f4b2f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
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 - Replace #if (MOZ_WIDGET_GTK == 3) by #ifdef MOZ_WIDGET_GTK r=lsalzman MozReview-Commit-ID: Bo0m7n078oh
accessible/atk/Platform.cpp
dom/events/TouchEvent.cpp
ipc/glue/GeckoChildProcessHost.cpp
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsEmbedFunctions.cpp
toolkit/xre/nsGDKErrorHandler.h
view/nsView.cpp
widget/WidgetUtils.cpp
widget/gtk/IMContextWrapper.cpp
widget/gtk/NativeKeyBindings.cpp
widget/gtk/nsAppShell.cpp
widget/gtk/nsClipboardX11.cpp
widget/gtk/nsDeviceContextSpecG.cpp
widget/gtk/nsDragService.cpp
widget/gtk/nsFilePicker.cpp
widget/gtk/nsFilePicker.h
widget/gtk/nsGtkKeyUtils.cpp
widget/gtk/nsNativeThemeGTK.cpp
widget/gtk/nsWidgetFactory.cpp
widget/gtk/nsWindow.cpp
--- a/accessible/atk/Platform.cpp
+++ b/accessible/atk/Platform.cpp
@@ -14,17 +14,17 @@
 #include "prenv.h"
 #include "prlink.h"
 
 #ifdef MOZ_ENABLE_DBUS
 #include <dbus/dbus.h>
 #endif
 #include <gtk/gtk.h>
 
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
 extern "C" __attribute__((weak,visibility("default"))) int atk_bridge_adaptor_init(int*, char **[]);
 #endif
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 int atkMajorVersion = 1, atkMinorVersion = 12, atkMicroVersion = 0;
 
@@ -183,17 +183,17 @@ a11y::PlatformInit()
     (*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");
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
   if (atk_bridge_adaptor_init) {
     atk_bridge_adaptor_init(nullptr, nullptr);
   } else
 #endif
   {
     nsresult rv = LoadGtkModule(sAtkBridge);
     if (NS_SUCCEEDED(rv)) {
       (*sAtkBridge.init)();
--- a/dom/events/TouchEvent.cpp
+++ b/dom/events/TouchEvent.cpp
@@ -201,17 +201,17 @@ TouchEvent::PrefEnabled(nsIDocShell* aDo
     enabled = true;
   } else if (touchEventsOverride == nsIDocShell::TOUCHEVENTS_OVERRIDE_DISABLED) {
     enabled = false;
   } else {
     if (sPrefCacheValue == 2) {
 #if defined(MOZ_WIDGET_ANDROID)
       // Touch support is always enabled on B2G and android.
       enabled = true;
-#elif defined(XP_WIN) || MOZ_WIDGET_GTK == 3
+#elif defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
       static bool sDidCheckTouchDeviceSupport = false;
       static bool sIsTouchDeviceSupportPresent = false;
       // On Windows and GTK3 we auto-detect based on device support.
       if (!sDidCheckTouchDeviceSupport) {
         sDidCheckTouchDeviceSupport = true;
         sIsTouchDeviceSupportPresent = WidgetUtils::IsTouchDeviceSupportPresent();
         // But touch events are only actually supported if APZ is enabled. If
         // APZ is disabled globally, we can check that once and incorporate that
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -627,22 +627,22 @@ GeckoChildProcessHost::PerformAsyncLaunc
   if (ShouldHaveDirectoryService()) {
     MOZ_ASSERT(gGREBinPath);
     nsCString path;
     NS_CopyUnicodeToNative(nsDependentString(gGREBinPath), path);
 #  if defined(OS_LINUX) || defined(OS_BSD)
     const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH");
     nsCString new_ld_lib_path(path.get());
 
-#   if (MOZ_WIDGET_GTK == 3)
+#   ifdef MOZ_WIDGET_GTK
     if (mProcessType == GeckoProcessType_Plugin) {
       new_ld_lib_path.AppendLiteral("/gtk2:");
       new_ld_lib_path.Append(path.get());
     }
-#   endif // (MOZ_WIDGET_GTK == 3)
+#   endif // MOZ_WIDGET_GTK
     if (ld_library_path && *ld_library_path) {
       new_ld_lib_path.Append(':');
       new_ld_lib_path.Append(ld_library_path);
     }
     mLaunchOptions->env_map["LD_LIBRARY_PATH"] = new_ld_lib_path.get();
 
 #  elif OS_MACOSX // defined(OS_LINUX) || defined(OS_BSD)
     mLaunchOptions->env_map["DYLD_LIBRARY_PATH"] = path.get();
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2977,17 +2977,17 @@ static void MOZ_gdk_display_close(GdkDis
   g_object_get(settings, "gtk-theme-name", &theme_name, nullptr);
   if (theme_name) {
     skip_display_close = strcmp(theme_name, "Qt") == 0;
     if (skip_display_close)
       NS_WARNING("wallpaper bug 417163 for Qt theme");
     g_free(theme_name);
   }
 
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
   // A workaround for https://bugzilla.gnome.org/show_bug.cgi?id=703257
   if (gtk_check_version(3,9,8) != NULL)
     skip_display_close = true;
 #endif
 
   // Get a (new) Pango context that holds a reference to the fontmap that
   // GTK has been using.  gdk_pango_context_get() must be called while GTK
   // has a default display.
@@ -3873,17 +3873,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
   {
     nsAutoCString program(gAppData->name);
     ToLowerCase(program);
     g_set_prgname(program.get());
   }
 
   // Initialize GTK here for splash.
 
-#if (MOZ_WIDGET_GTK == 3) && defined(MOZ_X11)
+#if defined(MOZ_WIDGET_GTK) && defined(MOZ_X11)
   // Disable XInput2 support due to focus bugginess. See bugs 1182700, 1170342.
   const char* useXI2 = PR_GetEnv("MOZ_USE_XINPUT2");
   if (!useXI2 || (*useXI2 == '0'))
     gdk_disable_multidevice();
 #endif
 
   // Open the display ourselves instead of using gtk_init, so that we can
   // close it without fear that one day gtk might clean up the display it
@@ -3965,17 +3965,17 @@ XREMain::XRE_mainStartup(bool* aExitFlag
         }
 #ifdef MOZ_WAYLAND
         else if (GDK_IS_WAYLAND_DISPLAY(mGdkDisplay)) {
             SaveWordToEnv("WAYLAND_DISPLAY", nsDependentCString(display_name));
         }
 #endif
       }
     }
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
     else {
       mGdkDisplay = gdk_display_manager_open_display(gdk_display_manager_get(),
                                                      nullptr);
     }
 #endif
   }
   else {
     mDisableRemote = true;
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -972,15 +972,15 @@ XRE_ShutdownTestShell()
     NS_RELEASE(gContentParent);
     return ret;
 }
 
 #ifdef MOZ_X11
 void
 XRE_InstallX11ErrorHandler()
 {
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
   InstallGdkErrorHandler();
 #else
   InstallX11ErrorHandler();
 #endif
 }
 #endif
--- a/toolkit/xre/nsGDKErrorHandler.h
+++ b/toolkit/xre/nsGDKErrorHandler.h
@@ -1,8 +1,8 @@
 /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
 void InstallGdkErrorHandler();
 #endif
--- a/view/nsView.cpp
+++ b/view/nsView.cpp
@@ -257,17 +257,17 @@ LayoutDeviceIntRect nsView::CalcWidgetBo
                             NSIntPixelsToAppUnits(screenPoint.y, p2a));
     }
   }
 
   // Compute widget bounds in device pixels
   LayoutDeviceIntRect newBounds =
     LayoutDeviceIntRect::FromUnknownRect(viewBounds.ToNearestPixels(p2a));
 
-#if defined(XP_MACOSX) || (MOZ_WIDGET_GTK == 3)
+#if defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
   // cocoa and GTK round widget coordinates to the nearest global "display
   // pixel" integer value. So we avoid fractional display pixel values by
   // rounding to the nearest value that won't yield a fractional display pixel.
   nsIWidget* widget = parentWidget ? parentWidget : mWindow.get();
   uint32_t round;
   if (aType == eWindowType_popup && widget &&
       ((round = widget->RoundsWidgetCoordinatesTo()) > 1)) {
     LayoutDeviceIntSize pixelRoundedSize = newBounds.Size();
--- a/widget/WidgetUtils.cpp
+++ b/widget/WidgetUtils.cpp
@@ -11,17 +11,17 @@
 #include "mozilla/Unused.h"
 #include "nsContentUtils.h"
 #include "nsIBidiKeyboard.h"
 #include "nsIStringBundle.h"
 #include "nsTArray.h"
 #ifdef XP_WIN
 #include "WinUtils.h"
 #endif
-#if MOZ_WIDGET_GTK == 3
+#ifdef MOZ_WIDGET_GTK
 #include "mozilla/WidgetUtilsGtk.h"
 #endif
 
 namespace mozilla {
 
 gfx::Matrix
 ComputeTransformForRotation(const nsIntRect& aBounds,
                               ScreenRotation aRotation)
@@ -104,17 +104,17 @@ nsIntRect RotateRect(nsIntRect aRect,
 
 namespace widget {
 
 uint32_t
 WidgetUtils::IsTouchDeviceSupportPresent()
 {
 #ifdef XP_WIN
   return WinUtils::IsTouchDeviceSupportPresent();
-#elif MOZ_WIDGET_GTK == 3
+#elif defined(MOZ_WIDGET_GTK)
   return WidgetUtilsGTK::IsTouchDeviceSupportPresent();
 #else
   return 0;
 #endif
 }
 
 // static
 void
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -767,17 +767,17 @@ IMContextWrapper::SetInputContext(nsWind
     if (changingEnabledState && mInputContext.mIMEState.MaybeEditable()) {
         EndIMEComposition(mLastFocusedWindow);
         Blur();
     }
 
     mInputContext = *aContext;
 
     if (changingEnabledState) {
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
         static bool sInputPurposeSupported = !gtk_check_version(3, 6, 0);
         if (sInputPurposeSupported && mInputContext.mIMEState.MaybeEditable()) {
             GtkIMContext* currentContext = GetCurrentContext();
             if (currentContext) {
                 GtkInputPurpose purpose = GTK_INPUT_PURPOSE_FREE_FORM;
                 const nsString& inputType = mInputContext.mHTMLInputType;
                 // Password case has difficult issue.  Desktop IMEs disable
                 // composition if input-purpose is password.
@@ -807,17 +807,17 @@ IMContextWrapper::SetInputContext(nsWind
                     purpose = GTK_INPUT_PURPOSE_PHONE;
                 } else if (inputType.EqualsLiteral("number")) {
                     purpose = GTK_INPUT_PURPOSE_NUMBER;
                 }
 
                 g_object_set(currentContext, "input-purpose", purpose, nullptr);
             }
         }
-#endif // #if (MOZ_WIDGET_GTK == 3)
+#endif // #ifdef MOZ_WIDGET_GTK
 
         // Even when aState is not enabled state, we need to set IME focus.
         // Because some IMs are updating the status bar of them at this time.
         // Be aware, don't use aWindow here because this method shouldn't move
         // focus actually.
         Focus();
 
         // XXX Should we call Blur() when it's not editable?  E.g., it might be
--- a/widget/gtk/NativeKeyBindings.cpp
+++ b/widget/gtk/NativeKeyBindings.cpp
@@ -66,17 +66,17 @@ delete_from_cursor_cb(GtkWidget *w, GtkD
   g_signal_stop_emission_by_name(w, "delete_from_cursor");
   if (count == 0) {
     // Nothing to do.
     return;
   }
 
   bool forward = count > 0;
 
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
   // Ignore GTK's Ctrl-K keybinding introduced in GTK 3.14 and removed in
   // 3.18 if the user has custom bindings set. See bug 1176929.
   if (del_type == GTK_DELETE_PARAGRAPH_ENDS && forward && GTK_IS_ENTRY(w) &&
       !gtk_check_version(3, 14, 1) && gtk_check_version(3, 17, 9)) {
     GtkStyleContext* context = gtk_widget_get_style_context(w);
     GtkStateFlags flags = gtk_widget_get_state_flags(w);
 
     GPtrArray* array;
--- a/widget/gtk/nsAppShell.cpp
+++ b/widget/gtk/nsAppShell.cpp
@@ -51,17 +51,17 @@ PollWrapper(GPollFD *ufds, guint nfsd, g
     {
         AUTO_PROFILER_THREAD_SLEEP;
         result = (*sPollFunc)(ufds, nfsd, timeout_);
     }
     mozilla::HangMonitor::NotifyActivity();
     return result;
 }
 
-#if MOZ_WIDGET_GTK == 3
+#ifdef MOZ_WIDGET_GTK
 // For bug 726483.
 static decltype(GtkContainerClass::check_resize) sReal_gtk_window_check_resize;
 
 static void
 wrap_gtk_window_check_resize(GtkContainer *container)
 {
     GdkWindow* gdk_window = gtk_widget_get_window(&container->widget);
     if (gdk_window) {
@@ -184,17 +184,17 @@ nsAppShell::Init()
         // See https://bugzilla.gnome.org/show_bug.cgi?id=747634
         nsAutoString brandName;
         mozilla::widget::WidgetUtils::GetBrandShortName(brandName);
         if (!brandName.IsEmpty()) {
             gdk_set_program_class(NS_ConvertUTF16toUTF8(brandName).get());
         }
     }
 
-#if MOZ_WIDGET_GTK == 3
+#ifdef MOZ_WIDGET_GTK
     if (!sReal_gtk_window_check_resize &&
         gtk_check_version(3,8,0) != nullptr) { // GTK 3.0 to GTK 3.6.
         // GtkWindow is a static class and so will leak anyway but this ref
         // makes sure it isn't recreated.
         gpointer gtk_plug_class = g_type_class_ref(GTK_TYPE_WINDOW);
         auto check_resize = &GTK_CONTAINER_CLASS(gtk_plug_class)->check_resize;
         sReal_gtk_window_check_resize = *check_resize;
         *check_resize = wrap_gtk_window_check_resize;
--- a/widget/gtk/nsClipboardX11.cpp
+++ b/widget/gtk/nsClipboardX11.cpp
@@ -62,17 +62,17 @@ selection_request_filter(GdkXEvent *gdk_
 
 nsRetrievalContextX11::nsRetrievalContextX11()
   : mState(INITIAL)
   , mData(nullptr)
   , mClipboardRequestNumber(0)
 {
     // A custom event filter to workaround attempting to dereference a null
     // selection requestor in GTK3 versions before 3.11.3. See bug 1178799.
-#if (MOZ_WIDGET_GTK == 3) && defined(MOZ_X11)
+#if defined(MOZ_WIDGET_GTK) && defined(MOZ_X11)
     if (gtk_check_version(3, 11, 3))
         gdk_window_add_filter(nullptr, selection_request_filter, nullptr);
 #endif
 }
 
 nsRetrievalContextX11::~nsRetrievalContextX11()
 {
     gdk_window_remove_filter(nullptr, selection_request_filter, nullptr);
--- a/widget/gtk/nsDeviceContextSpecG.cpp
+++ b/widget/gtk/nsDeviceContextSpecG.cpp
@@ -217,17 +217,17 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::In
   gtk_print_settings_set_paper_size(mGtkPrintSettings, properPaperSize);
   gtk_page_setup_set_paper_size_and_default_margins(mGtkPageSetup, properPaperSize);
   gtk_paper_size_free(standardGtkPaperSize);
 
   return NS_OK;
 }
 
 static void
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
 print_callback(GtkPrintJob *aJob, gpointer aData, const GError *aError) {
 #else
 print_callback(GtkPrintJob *aJob, gpointer aData, GError *aError) {
 #endif
   g_object_unref(aJob);
   ((nsIFile*) aData)->Remove(false);
 }
 
--- a/widget/gtk/nsDragService.cpp
+++ b/widget/gtk/nsDragService.cpp
@@ -374,23 +374,23 @@ nsDragService::InvokeDragSessionImpl(nsI
     // Put the drag widget in the window group of the source node so that the
     // gtk_grab_add during gtk_drag_begin is effective.
     // gtk_window_get_group(nullptr) returns the default window group.
     GtkWindowGroup *window_group =
         gtk_window_get_group(GetGtkWindow(mSourceDocument));
     gtk_window_group_add_window(window_group,
                                 GTK_WINDOW(mHiddenWidget));
 
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
     // Get device for event source
     GdkDisplay *display = gdk_display_get_default();
     GdkDeviceManager *device_manager = gdk_display_get_device_manager(display);
     event.button.device = gdk_device_manager_get_client_pointer(device_manager);
 #endif
-  
+
     // start our drag.
     GdkDragContext *context = gtk_drag_begin(mHiddenWidget,
                                              sourceList,
                                              action,
                                              1,
                                              &event);
 
     mSourceRegion = nullptr;
--- a/widget/gtk/nsFilePicker.cpp
+++ b/widget/gtk/nsFilePicker.cpp
@@ -166,17 +166,17 @@ MakeCaseInsensitiveShellGlob(const char*
 }
 
 NS_IMPL_ISUPPORTS(nsFilePicker, nsIFilePicker)
 
 nsFilePicker::nsFilePicker()
   : mSelectedType(0)
   , mRunning(false)
   , mAllowURLs(false)
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
   , mFileChooserDelegate(nullptr)
 #endif
 {
 }
 
 nsFilePicker::~nsFilePicker()
 {
 }
@@ -443,17 +443,17 @@ nsFilePicker::Open(nsIFilePickerShownCal
       defaultPath->AppendNative(defaultName);
       nsAutoCString path;
       defaultPath->GetNativePath(path);
       gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_chooser), path.get());
     } else {
       nsAutoCString directory;
       defaultPath->GetNativePath(directory);
 
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
       // Workaround for problematic refcounting in GTK3 before 3.16.
       // We need to keep a reference to the dialog's internal delegate.
       // Otherwise, if our dialog gets destroyed, we'll lose the dialog's
       // delegate by the time this gets processed in the event loop.
       // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1166741
       GtkDialog *dialog = GTK_DIALOG(file_chooser);
       GtkContainer *area = GTK_CONTAINER(gtk_dialog_get_content_area(dialog));
       gtk_container_forall(area, [](GtkWidget *widget,
@@ -580,17 +580,17 @@ nsFilePicker::Done(GtkWidget* file_choos
   // When response_id is GTK_RESPONSE_DELETE_EVENT or when called from
   // OnDestroy, the widget would be destroyed anyway but it is fine if
   // gtk_widget_destroy is called more than once.  gtk_widget_destroy has
   // requests that any remaining references be released, but the reference
   // count will not be decremented again if GtkWindow's reference has already
   // been released.
   gtk_widget_destroy(file_chooser);
 
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
       if (mFileChooserDelegate) {
         // Properly deref our acquired reference. We call this after
         // gtk_widget_destroy() to try and ensure that pending file info
         // queries caused by updating the current folder have been cancelled.
         // However, we do not know for certain when the callback will run after
         // cancelled.
         g_idle_add([](gpointer data) -> gboolean {
             g_object_unref(data);
--- a/widget/gtk/nsFilePicker.h
+++ b/widget/gtk/nsFilePicker.h
@@ -69,14 +69,14 @@ protected:
   nsString  mDefaultExtension;
 
   nsTArray<nsCString> mFilters;
   nsTArray<nsCString> mFilterNames;
 
 private:
   static nsIFile *mPrevDisplayDirectory;
 
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
   GtkFileChooserWidget *mFileChooserDelegate;
 #endif
 };
 
 #endif
--- a/widget/gtk/nsGtkKeyUtils.cpp
+++ b/widget/gtk/nsGtkKeyUtils.cpp
@@ -8,17 +8,17 @@
 #include "mozilla/Logging.h"
 
 #include "nsGtkKeyUtils.h"
 
 #include <gdk/gdkkeysyms.h>
 #include <algorithm>
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
 #include <gdk/gdkkeysyms-compat.h>
 #endif
 #include <X11/XKBlib.h>
 #include "WidgetUtils.h"
 #include "keysym2ucs.h"
 #include "nsContentUtils.h"
 #include "nsGtkUtils.h"
 #include "nsIBidiKeyboard.h"
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -510,17 +510,17 @@ nsNativeThemeGTK::GetGtkWidgetAndState(u
   case NS_THEME_RESIZER:
     aGtkWidgetType = MOZ_GTK_RESIZER;
     break;
   case NS_THEME_NUMBER_INPUT:
   case NS_THEME_TEXTFIELD:
     aGtkWidgetType = MOZ_GTK_ENTRY;
     break;
   case NS_THEME_TEXTFIELD_MULTILINE:
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
     aGtkWidgetType = MOZ_GTK_TEXT_VIEW;
 #else
     aGtkWidgetType = MOZ_GTK_ENTRY;
 #endif
     break;
   case NS_THEME_LISTBOX:
   case NS_THEME_TREEVIEW:
     aGtkWidgetType = MOZ_GTK_TREEVIEW;
@@ -1643,17 +1643,17 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
 
       nsIntMargin border;
       nsNativeThemeGTK::GetWidgetBorder(aFrame->PresContext()->DeviceContext(),
                                         aFrame, aWidgetType, &border);
       aResult->width += border.left + border.right;
       aResult->height += border.top + border.bottom;
     }
     break;
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
   case NS_THEME_NUMBER_INPUT:
   case NS_THEME_TEXTFIELD:
     {
       moz_gtk_get_entry_min_height(&aResult->height);
     }
     break;
 #endif
   case NS_THEME_SEPARATOR:
@@ -1891,17 +1891,17 @@ nsNativeThemeGTK::ThemeSupportsWidget(ns
   case NS_THEME_MENUITEM:
   case NS_THEME_MENUARROW:
   case NS_THEME_MENUSEPARATOR:
   case NS_THEME_CHECKMENUITEM:
   case NS_THEME_RADIOMENUITEM:
   case NS_THEME_SPLITTER:
   case NS_THEME_WINDOW:
   case NS_THEME_DIALOG:
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
   case NS_THEME_GTK_INFO_BAR:
 #endif
     return !IsWidgetStyled(aPresContext, aFrame, aWidgetType);
 
   case NS_THEME_WINDOW_BUTTON_CLOSE:
   case NS_THEME_WINDOW_BUTTON_MINIMIZE:
   case NS_THEME_WINDOW_BUTTON_MAXIMIZE:
   case NS_THEME_WINDOW_BUTTON_RESTORE:
@@ -1973,17 +1973,17 @@ nsNativeThemeGTK::GetWidgetTransparency(
   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:
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
     // Make scrollbar tracks opaque on the window's scroll frame to prevent
     // leaf layers from overlapping. See bug 1179780.
     if (!(CheckBooleanAttr(aFrame, nsGkAtoms::root_) &&
           aFrame->PresContext()->IsRootContentDocument() &&
           IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)))
       return eTransparent;
 #endif
     return eOpaque;
--- a/widget/gtk/nsWidgetFactory.cpp
+++ b/widget/gtk/nsWidgetFactory.cpp
@@ -18,17 +18,17 @@
 #include "nsTransferable.h"
 #include "nsHTMLFormatConverter.h"
 #include "HeadlessClipboard.h"
 #ifdef MOZ_X11
 #include "nsClipboardHelper.h"
 #include "nsClipboard.h"
 #include "nsDragService.h"
 #endif
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
 #include "nsApplicationChooser.h"
 #endif
 #include "nsColorPicker.h"
 #include "nsFilePicker.h"
 #include "nsSound.h"
 #include "nsBidiKeyboard.h"
 #include "nsGTKToolkit.h"
 #include "WakeLockListener.h"
@@ -151,17 +151,17 @@ nsFilePickerConstructor(nsISupports *aOu
 
   if (!picker) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   return picker->QueryInterface(aIID, aResult);
 }
 
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
 static nsresult
 nsApplicationChooserConstructor(nsISupports *aOuter, REFNSIID aIID,
                                 void **aResult)
 {
   *aResult = nullptr;
   if (aOuter != nullptr) {
     return NS_ERROR_NO_AGGREGATION;
   }
@@ -215,17 +215,17 @@ nsClipboardConstructor(nsISupports *aOut
   return inst->QueryInterface(aIID, aResult);
 }
 
 NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
 NS_DEFINE_NAMED_CID(NS_CHILD_CID);
 NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
 NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID);
 NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
 NS_DEFINE_NAMED_CID(NS_APPLICATIONCHOOSER_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_SOUND_CID);
 NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
 #ifdef MOZ_X11
 NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
 NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
 NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
@@ -249,17 +249,17 @@ NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
 
 
 static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
     { &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor },
     { &kNS_CHILD_CID, false, nullptr, nsWindowConstructor },
     { &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor, Module::ALLOW_IN_GPU_PROCESS },
     { &kNS_COLORPICKER_CID, false, nullptr, nsColorPickerConstructor, Module::MAIN_PROCESS_ONLY },
     { &kNS_FILEPICKER_CID, false, nullptr, nsFilePickerConstructor, Module::MAIN_PROCESS_ONLY },
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
     { &kNS_APPLICATIONCHOOSER_CID, false, nullptr, nsApplicationChooserConstructor, Module::MAIN_PROCESS_ONLY },
 #endif
     { &kNS_SOUND_CID, false, nullptr, nsISoundConstructor, Module::MAIN_PROCESS_ONLY },
     { &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor },
 #ifdef MOZ_X11
     { &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor, Module::MAIN_PROCESS_ONLY },
     { &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor },
     { &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor, Module::MAIN_PROCESS_ONLY },
@@ -285,17 +285,17 @@ static const mozilla::Module::CIDEntry k
 };
 
 static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
     { "@mozilla.org/widget/window/gtk;1", &kNS_WINDOW_CID },
     { "@mozilla.org/widgets/child_window/gtk;1", &kNS_CHILD_CID },
     { "@mozilla.org/widget/appshell/gtk;1", &kNS_APPSHELL_CID, Module::ALLOW_IN_GPU_PROCESS },
     { "@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID, Module::MAIN_PROCESS_ONLY },
     { "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID, Module::MAIN_PROCESS_ONLY },
-#if (MOZ_WIDGET_GTK == 3)
+#ifdef MOZ_WIDGET_GTK
     { "@mozilla.org/applicationchooser;1", &kNS_APPLICATIONCHOOSER_CID, Module::MAIN_PROCESS_ONLY },
 #endif
     { "@mozilla.org/sound;1", &kNS_SOUND_CID, Module::MAIN_PROCESS_ONLY },
     { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
 #ifdef MOZ_X11
     { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID, Module::MAIN_PROCESS_ONLY },
     { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID },
     { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, Module::MAIN_PROCESS_ONLY },
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -33,32 +33,28 @@
 #include "nsIScreenManager.h"
 #include "SystemTimeConverter.h"
 
 #include "nsGtkKeyUtils.h"
 #include "nsGtkCursors.h"
 #include "ScreenHelperGTK.h"
 
 #include <gtk/gtk.h>
-#if (MOZ_WIDGET_GTK == 3)
 #include <gtk/gtkx.h>
-#endif
 
 #ifdef MOZ_WAYLAND
 #include <gdk/gdkwayland.h>
 #endif /* MOZ_WAYLAND */
 
 #ifdef MOZ_X11
 #include <gdk/gdkx.h>
 #include <X11/Xatom.h>
 #include <X11/extensions/XShm.h>
 #include <X11/extensions/shape.h>
-#if (MOZ_WIDGET_GTK == 3)
 #include <gdk/gdkkeysyms-compat.h>
-#endif
 #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>
@@ -231,21 +227,19 @@ static void     theme_changed_cb        
                                            nsWindow *data);
 static void     check_resize_cb           (GtkContainer* container,
                                            gpointer user_data);
 static void     screen_composited_changed_cb     (GdkScreen* screen,
                                                   gpointer user_data);
 static void     widget_composited_changed_cb     (GtkWidget* widget,
                                                   gpointer user_data);
 
-#if (MOZ_WIDGET_GTK == 3)
 static void     scale_changed_cb          (GtkWidget* widget,
                                            GParamSpec* aPSpec,
                                            gpointer aPointer);
-#endif
 #if GTK_CHECK_VERSION(3,4,0)
 static gboolean touch_event_cb            (GtkWidget* aWidget,
                                            GdkEventTouch* aEvent);
 #endif
 static nsWindow* GetFirstNSWindowForGDKWindow (GdkWindow *aGdkWindow);
 
 #ifdef __cplusplus
 extern "C" {
@@ -513,21 +507,17 @@ nsWindow::~nsWindow()
     Destroy();
 }
 
 /* static */ void
 nsWindow::ReleaseGlobals()
 {
   for (auto & cursor : gCursorCache) {
     if (cursor) {
-#if (MOZ_WIDGET_GTK == 3)
       g_object_unref(cursor);
-#else
-      gdk_cursor_unref(cursor);
-#endif
       cursor = nullptr;
     }
   }
 }
 
 void
 nsWindow::CommonCreate(nsIWidget *aParent, bool aListenForResizes)
 {
@@ -1684,21 +1674,17 @@ nsWindow::SetCursor(imgIContainer* aCurs
                                                    aHotspotX, aHotspotY);
     g_object_unref(pixbuf);
     nsresult rv = NS_ERROR_OUT_OF_MEMORY;
     if (cursor) {
         if (mContainer) {
             gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(mContainer)), cursor);
             rv = NS_OK;
         }
-#if (MOZ_WIDGET_GTK == 3)
         g_object_unref(cursor);
-#else
-        gdk_cursor_unref(cursor);
-#endif
     }
 
     return rv;
 }
 
 void
 nsWindow::Invalidate(const LayoutDeviceIntRect& aRect)
 {
@@ -3810,17 +3796,16 @@ nsWindow::Create(nsIWidget* aParent,
                mIsCSDAvailable = isCSDAvailable;
             }
         }
 
         // Create a container to hold child windows and child GtkWidgets.
         GtkWidget *container = moz_container_new();
         mContainer = MOZ_CONTAINER(container);
 
-#if (MOZ_WIDGET_GTK == 3)
         // "csd" style is set when widget is realized so we need to call
         // it explicitly now.
         gtk_widget_realize(mShell);
 
         /* There are two cases here:
          *
          * 1) We're running on Gtk+ without client side decorations.
          *    Content is rendered to mShell window and we listen
@@ -3831,17 +3816,16 @@ nsWindow::Create(nsIWidget* aParent,
          * 3) We're running on Wayland. All gecko content is rendered
          *    to mContainer and we listen to the Gtk+ events on mContainer.
          */
         GtkStyleContext* style = gtk_widget_get_style_context(mShell);
         drawToContainer =
             !mIsX11Display ||
             (mIsCSDAvailable && GetCSDSupportLevel() == CSD_SUPPORT_FLAT ) ||
             gtk_style_context_has_class(style, "csd");
-#endif
         eventWidget = (drawToContainer) ? container : mShell;
 
         gtk_widget_add_events(eventWidget, kEvents);
         if (drawToContainer)
             gtk_widget_add_events(mShell, GDK_PROPERTY_CHANGE_MASK);
 
         // Prevent GtkWindow from painting a background to avoid flickering.
         gtk_widget_set_app_paintable(eventWidget, TRUE);
@@ -3980,20 +3964,18 @@ nsWindow::Create(nsIWidget* aParent,
     if (mContainer) {
         // Widget signals
         g_signal_connect(mContainer, "unrealize",
                          G_CALLBACK(container_unrealize_cb), nullptr);
         g_signal_connect_after(mContainer, "size_allocate",
                                G_CALLBACK(size_allocate_cb), nullptr);
         g_signal_connect(mContainer, "hierarchy-changed",
                          G_CALLBACK(hierarchy_changed_cb), nullptr);
-#if (MOZ_WIDGET_GTK == 3)
         g_signal_connect(mContainer, "notify::scale-factor",
                          G_CALLBACK(scale_changed_cb), nullptr);
-#endif
         // 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
@@ -6044,33 +6026,31 @@ widget_composited_changed_cb (GtkWidget*
 {
     RefPtr<nsWindow> window = get_window_for_gtk_widget(widget);
     if (!window) {
       return;
     }
     window->OnCompositedChanged();
 }
 
-#if (MOZ_WIDGET_GTK == 3)
 static void
 scale_changed_cb (GtkWidget* widget, GParamSpec* aPSpec, gpointer aPointer)
 {
     RefPtr<nsWindow> window = get_window_for_gtk_widget(widget);
     if (!window) {
       return;
     }
     window->OnDPIChanged();
 
     // configure_event is already fired before scale-factor signal,
     // but size-allocate isn't fired by changing scale
     GtkAllocation allocation;
     gtk_widget_get_allocation(widget, &allocation);
     window->OnSizeAllocate(&allocation);
 }
-#endif
 
 #if GTK_CHECK_VERSION(3,4,0)
 static gboolean
 touch_event_cb(GtkWidget* aWidget, GdkEventTouch* aEvent)
 {
     UpdateLastInputEventTime(aEvent);
 
     nsWindow* window = GetFirstNSWindowForGDKWindow(aEvent->window);
@@ -6883,21 +6863,19 @@ nsWindow::SynthesizeNativeMouseEvent(Lay
   if (aNativeMessage == GDK_BUTTON_PRESS || aNativeMessage == GDK_BUTTON_RELEASE) {
     GdkEvent event;
     memset(&event, 0, sizeof(GdkEvent));
     event.type = (GdkEventType)aNativeMessage;
     event.button.button = 1;
     event.button.window = mGdkWindow;
     event.button.time = GDK_CURRENT_TIME;
 
-#if (MOZ_WIDGET_GTK == 3)
     // Get device for event source
     GdkDeviceManager *device_manager = gdk_display_get_device_manager(display);
     event.button.device = gdk_device_manager_get_client_pointer(device_manager);
-#endif
 
     event.button.x_root = DevicePixelsToGdkCoordRoundDown(aPoint.x);
     event.button.y_root = DevicePixelsToGdkCoordRoundDown(aPoint.y);
 
     LayoutDeviceIntPoint pointInWindow = aPoint - WidgetToScreenOffset();
     event.button.x = DevicePixelsToGdkCoordRoundDown(pointInWindow.x);
     event.button.y = DevicePixelsToGdkCoordRoundDown(pointInWindow.y);
 
@@ -6930,22 +6908,20 @@ nsWindow::SynthesizeNativeMouseScrollEve
     return NS_OK;
   }
 
   GdkEvent event;
   memset(&event, 0, sizeof(GdkEvent));
   event.type = GDK_SCROLL;
   event.scroll.window = mGdkWindow;
   event.scroll.time = GDK_CURRENT_TIME;
-#if (MOZ_WIDGET_GTK == 3)
   // Get device for event source
   GdkDisplay* display = gdk_window_get_display(mGdkWindow);
   GdkDeviceManager *device_manager = gdk_display_get_device_manager(display);
   event.scroll.device = gdk_device_manager_get_client_pointer(device_manager);
-#endif
   event.scroll.x_root = DevicePixelsToGdkCoordRoundDown(aPoint.x);
   event.scroll.y_root = DevicePixelsToGdkCoordRoundDown(aPoint.y);
 
   LayoutDeviceIntPoint pointInWindow = aPoint - WidgetToScreenOffset();
   event.scroll.x = DevicePixelsToGdkCoordRoundDown(pointInWindow.x);
   event.scroll.y = DevicePixelsToGdkCoordRoundDown(pointInWindow.y);
 
   // The delta values are backwards on Linux compared to Windows and Cocoa,