Bug 1370034 - Allow disabling window transforms using a pref. r?spohl draft
authorMarkus Stange <mstange@themasta.com>
Fri, 09 Jun 2017 11:16:48 -0400
changeset 596347 09e3d93c1bcb133e6d0157a856751c331451500f
parent 596346 db46a233c5d9f40f957daed476795ed76aaa300f
child 596348 b18a48b2cc8002a8887a7dad9484d4116b938b45
push id64588
push userbmo:mstange@themasta.com
push dateMon, 19 Jun 2017 05:46:08 +0000
Bug 1370034 - Allow disabling window transforms using a pref. r?spohl MozReview-Commit-ID: T5NWKMA4qz
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -691,16 +691,18 @@ private:
   DECL_GFX_PREF(Live, "webgl.max-perf-warnings",               WebGLMaxPerfWarnings, int32_t, 0);
   DECL_GFX_PREF(Live, "webgl.max-acceptable-fb-status-invals", WebGLMaxAcceptableFBStatusInvals, int32_t, 0);
   DECL_GFX_PREF(Live, "webgl.webgl2-compat-mode",              WebGL2CompatMode, bool, false);
   DECL_GFX_PREF(Live, "webrender.blob-images",                 WebRenderBlobImages, bool, false);
   DECL_GFX_PREF(Live, "webrender.highlight-painted-layers",    WebRenderHighlightPaintedLayers, bool, false);
+  DECL_GFX_PREF(Live, "widget.window-transforms.disabled",     WindowTransformsDisabled, bool, false);
   // WARNING:
   // Please make sure that you've added your new preference to the list above in alphabetical order.
   // Please do not just append it to the end of the list.
   // Manage the singleton:
   static gfxPrefs& GetSingleton()
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4771,16 +4771,18 @@ pref("gfx.apitrace.enabled",false);
 #ifdef MOZ_X11
 pref("widget.chrome.allow-gtk-dark-theme", false);
 pref("widget.content.allow-gtk-dark-theme", false);
+pref("widget.window-transforms.disabled", false);
 #ifdef XP_WIN
 // Whether to disable the automatic detection and use of direct2d.
 pref("gfx.direct2d.disabled", false);
 // Whether to attempt to enable Direct2D regardless of automatic detection or
 // blacklisting
 pref("gfx.direct2d.force-enabled", false);
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -31,16 +31,17 @@
 #include "nsNativeThemeCocoa.h"
 #include "nsChildView.h"
 #include "nsCocoaFeatures.h"
 #include "nsIScreenManager.h"
 #include "nsIWidgetListener.h"
 #include "nsIPresShell.h"
 #include "gfxPlatform.h"
+#include "gfxPrefs.h"
 #include "qcms.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/Preferences.h"
 #include <algorithm>
 namespace mozilla {
@@ -2197,16 +2198,23 @@ void
 nsCocoaWindow::SetWindowTransform(const gfx::Matrix& aTransform)
   if (!mWindow) {
+  if (gfxPrefs::WindowTransformsDisabled()) {
+    // CGSSetWindowTransform is a private API. In case calling it causes
+    // problems either now or in the future, we'll want to have an easy kill
+    // switch. So we allow disabling it with a pref.
+    return;
+  }
   gfx::Matrix transform = aTransform;
   // aTransform is a transform that should be applied to the window relative
   // to its regular position: If aTransform._31 is 100, then we want the
   // window to be displayed 100 pixels to the right of its regular position.
   // The transform that CGSSetWindowTransform accepts has a different meaning:
   // It's used to answer the question "For the screen pixel at x,y (with the
   // origin at the top left), what pixel in the window's buffer (again with