amend-windows-compositing draft
authorKris Maglione <maglione.k@gmail.com>
Mon, 29 May 2017 14:58:48 -0700
changeset 586223 d16aafd6d14329a00700071f94118c3e6aec4ed0
parent 586222 1e43d52c671d08ec6fc78098c46338d2329daeac
child 586224 4d82ee47e7cb8ad47879702c8af19e8723e2b62e
push id61333
push usermaglione.k@gmail.com
push dateTue, 30 May 2017 00:33:14 +0000
milestone55.0a1
amend-windows-compositing MozReview-Commit-ID: EFA6Wg8D8jv
browser/components/extensions/test/browser/head.js
modules/libpref/init/all.js
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/test/mochitest/head.js
widget/windows/nsWindow.cpp
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -36,16 +36,17 @@ const {CustomizableUI} = Cu.import("reso
 
 // We run tests under two different configurations, from browser.ini and
 // browser-remote.ini. When running from browser-remote.ini, the tests are
 // copied to the sub-directory "test-oop-extensions", which we detect here, and
 // use to select our configuration.
 if (gTestPath.includes("test-oop-extensions")) {
   SpecialPowers.pushPrefEnv({set: [
     ["extensions.webextensions.remote", true],
+    ["layers.popups.compositing.enabled", true],
   ]});
   // We don't want to reset this at the end of the test, so that we don't have
   // to spawn a new extension child process for each test unit.
   SpecialPowers.setIntPref("dom.ipc.keepProcessesAlive.extension", 1);
 }
 
 // Bug 1239884: Our tests occasionally hit a long GC pause at unpredictable
 // times in debug builds, which results in intermittent timeouts. Until we have
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4838,16 +4838,18 @@ pref("extensions.webextensions.keepStora
 pref("extensions.webextensions.keepUuidOnUninstall", false);
 // Redirect basedomain used by identity api
 pref("extensions.webextensions.identity.redirectDomain", "extensions.allizom.org");
 // Whether or not webextension themes are supported.
 pref("extensions.webextensions.themes.enabled", false);
 pref("extensions.webextensions.themes.icons.enabled", false);
 pref("extensions.webextensions.remote", false);
 
+pref("layers.popups.compositing.enabled", false);
+
 // Report Site Issue button
 pref("extensions.webcompat-reporter.newIssueEndpoint", "https://webcompat.com/issues/new");
 #ifdef NIGHTLY_BUILD
 pref("extensions.webcompat-reporter.enabled", true);
 #else
 pref("extensions.webcompat-reporter.enabled", false);
 #endif
 
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -706,16 +706,21 @@ this.Extension = class extends Extension
       StartupCache.clearAddonData(addonData.id);
     }
 
     this.remote = ExtensionManagement.useRemoteWebExtensions;
 
     if (this.remote && processCount !== 1) {
       throw new Error("Out-of-process WebExtensions are not supported with multiple child processes");
     }
+    if (this.remote && !Services.prefs.getBoolPref("layers.popups.compositing.enabled", false)) {
+      Cu.reportError(new Error("Remote extensions should not be enabled without also setting " +
+                               "the layers.popups.compositing.enabled preference to true"));
+    }
+
     // This is filled in the first time an extension child is created.
     this.parentMessageManager = null;
 
     this.id = addonData.id;
     this.baseURI = NetUtil.newURI(this.getURL("")).QueryInterface(Ci.nsIURL);
     this.principal = this.createPrincipal();
 
     this.onStartup = null;
--- a/toolkit/components/extensions/test/mochitest/head.js
+++ b/toolkit/components/extensions/test/mochitest/head.js
@@ -6,16 +6,17 @@ var {AppConstants} = SpecialPowers.Cu.im
 
 // We run tests under two different configurations, from mochitest.ini and
 // mochitest-remote.ini. When running from mochitest-remote.ini, the tests are
 // copied to the sub-directory "test-oop-extensions", which we detect here, and
 // use to select our configuration.
 if (location.pathname.includes("test-oop-extensions")) {
   SpecialPowers.pushPrefEnv({set: [
     ["extensions.webextensions.remote", true],
+    ["layers.popups.compositing.enabled", true],
   ]});
   // We don't want to reset this at the end of the test, so that we don't have
   // to spawn a new extension child process for each test unit.
   SpecialPowers.setIntPref("dom.ipc.keepProcessesAlive.extension", 1);
 }
 
 {
   let chromeScript = SpecialPowers.loadChromeScript(
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -364,16 +364,19 @@ static const int32_t kGlassMarginAdjustm
 // this is the minimum amount of space along the edge of resizable windows
 // we will always display a resize cursor in, regardless of the underlying
 // content.
 static const int32_t kResizableBorderMinSize = 3;
 
 // Cached pointer events enabler value, True if pointer events are enabled.
 static bool gIsPointerEventsEnabled = false;
 
+// True if we should use compositing for popup widgets.
+static bool gIsPopupCompositingEnabled = false;
+
 // We should never really try to accelerate windows bigger than this. In some
 // cases this might lead to no D3D9 acceleration where we could have had it
 // but D3D9 does not reliably report when it supports bigger windows. 8192
 // is as safe as we can get, we know at least D3D10 hardware always supports
 // this, other hardware we expect to report correctly in D3D9.
 #define MAX_ACCELERATED_DIMENSION 8192
 
 // On window open (as well as after), Windows has an unfortunate habit of
@@ -666,16 +669,20 @@ nsWindow::nsWindow()
     RedirectedKeyDownMessageManager::Forget();
     if (mPointerEvents.ShouldEnableInkCollector()) {
       InkCollector::sInkCollector = new InkCollector();
     }
 
     Preferences::AddBoolVarCache(&gIsPointerEventsEnabled,
                                  "dom.w3c_pointer_events.enabled",
                                  gIsPointerEventsEnabled);
+
+    Preferences::AddBoolVarCache(&gIsPopupCompositingEnabled,
+                                 "layers.popups.compositing.enabled",
+                                 gIsPopupCompositingEnabled);
   } // !sInstanceCount
 
   mIdleService = nullptr;
 
   mSizeConstraintsScale = GetDefaultScale().scale;
 
   sInstanceCount++;
 }
@@ -7164,17 +7171,17 @@ nsWindow::IsPopup()
 }
 
 bool
 nsWindow::ShouldUseOffMainThreadCompositing()
 {
   // We don't currently support using an accelerated layer manager with
   // transparent windows so don't even try. I'm also not sure if we even
   // want to support this case. See bug 593471
-  if (!HasRemoteContent() && mTransparencyMode == eTransparencyTransparent) {
+  if (!(HasRemoteContent() && gIsPopupCompositingEnabled) && mTransparencyMode == eTransparencyTransparent) {
     return false;
   }
 
   return nsBaseWidget::ShouldUseOffMainThreadCompositing();
 }
 
 void
 nsWindow::WindowUsesOMTC()