Bug 1370034 - Allow disabling window transforms using a pref. r=spohl
authorMarkus Stange <mstange@themasta.com>
Fri, 09 Jun 2017 11:16:48 -0400
changeset 596539 1934338496755f08f6ca627f5d8dc22cdaae1643
parent 596538 f84d7ac5105d70faa7666484fdaca2a1bad140c0
child 596540 37c332642a18ce4c89f359a46ae014ce92044ef2
push id64675
push usermak77@bonardo.net
push dateMon, 19 Jun 2017 12:08:05 +0000
reviewersspohl
bugs1370034
milestone56.0a1
Bug 1370034 - Allow disabling window transforms using a pref. r=spohl MozReview-Commit-ID: T5NWKMA4qz
gfx/thebes/gfxPrefs.h
modules/libpref/init/all.js
widget/cocoa/nsCocoaWindow.mm
--- 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.
 
 public:
   // Manage the singleton:
   static gfxPrefs& GetSingleton()
   {
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4774,16 +4774,18 @@ pref("gfx.apitrace.enabled",false);
 #ifdef MOZ_X11
 #ifdef MOZ_WIDGET_GTK
 pref("gfx.xrender.enabled",false);
 pref("widget.chrome.allow-gtk-dark-theme", false);
 pref("widget.content.allow-gtk-dark-theme", false);
 #endif
 #endif
 
+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)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!mWindow) {
     return;
   }
 
+  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