Bug 384336 - Firefox window should be maximized on first run on small screens. r=MattN
☠☠ backed out by 9ad78f315cf7 ☠ ☠
authorDão Gottwald <dao@mozilla.com>
Tue, 22 Dec 2015 13:10:35 +0100
changeset 277282 3cc8559d0d65d5704eedc72238a82c09b4b630cd
parent 277281 b9e86a8c9c7b9db86323cb8c71b1818d6b190897
child 277283 b51ef0d55c49235fa392b4fe3ba8c49b78ac2fe3
push id16743
push userdgottwald@mozilla.com
push dateTue, 22 Dec 2015 12:10:48 +0000
treeherderfx-team@3cc8559d0d65 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs384336
milestone46.0a1
Bug 384336 - Firefox window should be maximized on first run on small screens. r=MattN
browser/base/content/browser.js
devtools/client/tilt/test/browser_tilt_zoom.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -992,45 +992,27 @@ var gBrowserInit = {
     // Certain kinds of automigration rely on this notification to complete
     // their tasks BEFORE the browser window is shown. SessionStore uses it to
     // restore tabs into windows AFTER important parts like gMultiProcessBrowser
     // have been initialized.
     Services.obs.notifyObservers(window, "browser-window-before-show", "");
 
     // Set a sane starting width/height for all resolutions on new profiles.
     if (!document.documentElement.hasAttribute("width")) {
-      let defaultWidth;
-      let defaultHeight;
-
-      // Very small: maximize the window
-      // Portrait  : use about full width and 3/4 height, to view entire pages
-      //             at once (without being obnoxiously tall)
-      // Widescreen: use about half width, to suggest side-by-side page view
-      // Otherwise : use 3/4 height and width
-      if (screen.availHeight <= 600) {
+      const TARGET_WIDTH = 1280;
+      const TARGET_HEIGHT = 1040;
+      let width = Math.min(screen.availWidth * .9, TARGET_WIDTH);
+      let height = Math.min(screen.availHeight * .9, TARGET_HEIGHT);
+
+      document.documentElement.setAttribute("width", width);
+      document.documentElement.setAttribute("height", height);
+
+      if (width < TARGET_WIDTH && height < TARGET_HEIGHT) {
         document.documentElement.setAttribute("sizemode", "maximized");
-        defaultWidth = 610;
-        defaultHeight = 450;
       }
-      else {
-        if (screen.availWidth <= screen.availHeight) {
-          defaultWidth = screen.availWidth * .9;
-          defaultHeight = screen.availHeight * .75;
-        }
-        else if (screen.availWidth >= 2048) {
-          defaultWidth = (screen.availWidth / 2) - 20;
-          defaultHeight = screen.availHeight - 10;
-        }
-        else {
-          defaultWidth = screen.availWidth * .75;
-          defaultHeight = screen.availHeight * .75;
-        }
-      }
-      document.documentElement.setAttribute("width", defaultWidth);
-      document.documentElement.setAttribute("height", defaultHeight);
     }
 
     if (!window.toolbar.visible) {
       // adjust browser UI for popups
       if (gURLBar) {
         gURLBar.setAttribute("readonly", "true");
         gURLBar.setAttribute("enablehistory", "false");
       }
--- a/devtools/client/tilt/test/browser_tilt_zoom.js
+++ b/devtools/client/tilt/test/browser_tilt_zoom.js
@@ -15,16 +15,35 @@ function test() {
   if (!isWebGLSupported()) {
     aborting();
     info("Skipping controller test because WebGL isn't supported.");
     return;
   }
 
   waitForExplicitFinish();
 
+  if (window.windowState == window.STATE_MAXIMIZED) {
+    registerCleanupFunction(function () {
+      window.maximize();
+    });
+
+    window.addEventListener("resize", function onResize(event) {
+      if (event.target == window) {
+        window.removeEventListener("resize", onResize, false);
+        executeSoon(testTilt);
+      }
+    }, false);
+
+    window.restore();
+  } else {
+    testTilt();
+  }
+}
+
+function testTilt() {
   createTab(function() {
     TiltUtils.setDocumentZoom(window, ZOOM);
 
     createTilt({
       onTiltOpen: function(instance)
       {
         tiltOpened = true;
 
@@ -46,42 +65,47 @@ function test() {
         ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1),
           "The renderer height wasn't set correctly before the resize.");
 
         ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1),
           "The arcball width wasn't set correctly before the resize.");
         ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1),
           "The arcball height wasn't set correctly before the resize.");
 
-
+        window.addEventListener("resize", onResize, false);
         window.resizeBy(-RESIZE * ZOOM, -RESIZE * ZOOM);
 
-        executeSoon(function() {
+        function onResize(event) {
+          if (event.target == window) {
+            window.removeEventListener("resize", onResize, false);
+            executeSoon(afterResize);
+          }
+        }
+
+        function afterResize() {
           ok(isApprox(contentWindow.innerWidth + RESIZE, initialWidth, 1),
             "The content window width wasn't set correctly after the resize.");
           ok(isApprox(contentWindow.innerHeight + RESIZE, initialHeight, 1),
             "The content window height wasn't set correctly after the resize.");
 
           ok(isApprox(contentWindow.innerWidth * ZOOM, renderer.width, 1),
             "The renderer width wasn't set correctly after the resize.");
           ok(isApprox(contentWindow.innerHeight * ZOOM, renderer.height, 1),
             "The renderer height wasn't set correctly after the resize.");
 
           ok(isApprox(contentWindow.innerWidth * ZOOM, arcball.width, 1),
             "The arcball width wasn't set correctly after the resize.");
           ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1),
             "The arcball height wasn't set correctly after the resize.");
 
-
           window.resizeBy(RESIZE * ZOOM, RESIZE * ZOOM);
 
-
           Services.obs.addObserver(cleanup, DESTROYED, false);
           Tilt.destroy(Tilt.currentWindowId);
-        });
+        }
       }
     }, false, function suddenDeath()
     {
       ok(false, "Tilt could not be initialized properly.");
       cleanup();
     });
   });
 }