Bug 717085 - Ensure that when Gecko does a session-restore, it knows how big the screen is. r=pcwalton
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 20 Jan 2012 09:36:08 -0500
changeset 86233 befdbbd1a136611a93d94b4b2534afdd79c627ce
parent 86232 c145acbf470d3e3748d9606473353a1f9c69c9a3
child 86234 abb2ccdb82fde17d0ca72e868c236efb7817a50e
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton
bugs717085
milestone12.0a1
Bug 717085 - Ensure that when Gecko does a session-restore, it knows how big the screen is. r=pcwalton
mobile/android/base/GeckoAppShell.java
mobile/android/chrome/content/browser.js
mobile/android/components/BrowserCLH.js
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -464,16 +464,20 @@ public class GeckoAppShell
         String combinedArgs = apkPath + " -greomni " + apkPath;
         if (args != null)
             combinedArgs += " " + args;
         if (url != null)
             combinedArgs += " -remote " + url;
         if (restoreSession)
             combinedArgs += " -restoresession";
 
+        DisplayMetrics metrics = new DisplayMetrics();
+        GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
+        combinedArgs += " -width " + metrics.widthPixels + " -height " + metrics.heightPixels;
+
         GeckoApp.mAppContext.runOnUiThread(new Runnable() {
                 public void run() {
                     geckoLoaded();
                 }
             });
 
         // and go
         GeckoAppShell.nativeRun(combinedArgs);
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -260,16 +260,20 @@ var BrowserApp = {
 
     let url = "about:home";
     let restoreSession = false;
     if ("arguments" in window) {
       if (window.arguments[0])
         url = window.arguments[0];
       if (window.arguments[1])
         restoreSession = window.arguments[1];
+      if (window.arguments[2])
+        gScreenWidth = window.arguments[2];
+      if (window.arguments[3])
+        gScreenHeight = window.arguments[3];
     }
 
     // XXX maybe we don't do this if the launch was kicked off from external
     Services.io.offline = false;
 
     // Broadcast a UIReady message so add-ons know we are finished with startup
     let event = document.createEvent("Events");
     event.initEvent("UIReady", true, false);
--- a/mobile/android/components/BrowserCLH.js
+++ b/mobile/android/components/BrowserCLH.js
@@ -9,25 +9,31 @@ Cu.import("resource://gre/modules/Servic
 function dump(a) {
   Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(a);
 }
 
 function openWindow(aParent, aURL, aTarget, aFeatures, aArgs) {
   let argsArray = Cc["@mozilla.org/supports-array;1"].createInstance(Ci.nsISupportsArray);
   let urlString = null;
   let restoreSessionBool = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
+  let widthInt = Cc["@mozilla.org/supports-PRInt32;1"].createInstance(Ci.nsISupportsPRInt32);
+  let heightInt = Cc["@mozilla.org/supports-PRInt32;1"].createInstance(Ci.nsISupportsPRInt32);
 
   if ("url" in aArgs) {
     urlString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
     urlString.data = aArgs.url;
   }
   restoreSessionBool.data = "restoreSession" in aArgs ? aArgs.restoreSession : false;
+  widthInt.data = "width" in aArgs ? aArgs.width : 1;
+  heightInt.data = "height" in aArgs ? aArgs.height : 1;
 
   argsArray.AppendElement(urlString, false);
   argsArray.AppendElement(restoreSessionBool, false);
+  argsArray.AppendElement(widthInt, false);
+  argsArray.AppendElement(heightInt, false);
   return Services.ww.openWindow(aParent, aURL, aTarget, aFeatures, argsArray);
 }
 
 
 function resolveURIInternal(aCmdLine, aArgument) {
   let uri = aCmdLine.resolveURI(aArgument);
   if (uri)
     return uri;
@@ -43,35 +49,45 @@ function resolveURIInternal(aCmdLine, aA
 }
 
 function BrowserCLH() {}
 
 BrowserCLH.prototype = {
   handle: function fs_handle(aCmdLine) {
     let urlParam = "about:home";
     let restoreSession = false;
+    let width = 1;
+    let height = 1;
     try {
       urlParam = aCmdLine.handleFlagWithParam("remote", false);
     } catch (e) { /* Optional */ }
     try {
       restoreSession = aCmdLine.handleFlag("restoresession", false);
     } catch (e) { /* Optional */ }
+    try {
+      width = aCmdLine.handleFlagWithParam("width", false);
+    } catch (e) { /* Optional */ }
+    try {
+      height = aCmdLine.handleFlagWithParam("height", false);
+    } catch (e) { /* Optional */ }
 
     try {
       let uri = resolveURIInternal(aCmdLine, urlParam);
       if (!uri)
         return;
 
       let browserWin = Services.wm.getMostRecentWindow("navigator:browser");
       if (browserWin) {
         browserWin.browserDOMWindow.openURI(uri, null, Ci.nsIBrowserDOMWindow.OPEN_NEWTAB, Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
       } else {
         let args = {
           url: urlParam,
-          restoreSession: restoreSession
+          restoreSession: restoreSession,
+          width: width,
+          height: height
         };
         browserWin = openWindow(null, "chrome://browser/content/browser.xul", "_blank", "chrome,dialog=no,all", args);
       }
 
       aCmdLine.preventDefault = true;
     } catch (x) {
       dump("BrowserCLH.handle: " + x);
     }