Bug 1003962 - Force-set browser size to ensure we set CSS viewport size before doc checks it. r=myk, a=sledru
authorJames Hugman <jhugman@mozilla.com>
Fri, 11 Jul 2014 09:24:37 -0700
changeset 209140 4f934dd2701009dbf1edb77ee769e361d6b3fa4b
parent 209139 86f3313577835eea2e1d1aecaffa5355d6807e20
child 209141 434889d480f8ab935f88e7fc74a36a95da601ec9
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmyk, sledru
bugs1003962
milestone32.0a2
Bug 1003962 - Force-set browser size to ensure we set CSS viewport size before doc checks it. r=myk, a=sledru
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -4126,16 +4126,23 @@ Tab.prototype = {
     sendMessageToJava(message);
 
     // The search term is only valid for this location change event, so reset it here.
     this.userSearch = "";
 
     if (!sameDocument) {
       // XXX This code assumes that this is the earliest hook we have at which
       // browser.contentDocument is changed to the new document we're loading
+
+      // We have a new browser and a new window, so the old browserWidth and
+      // browserHeight are no longer valid.  We need to force-set the browser
+      // size to ensure it sets the CSS viewport size before the document
+      // has a chance to check it.
+      this.setBrowserSize(kDefaultCSSViewportWidth, kDefaultCSSViewportHeight, true);
+
       this.contentDocumentIsDisplayed = false;
       this.hasTouchListener = false;
     } else {
       this.sendViewportUpdate();
     }
   },
 
   // Properties used to cache security state used to update the UI
@@ -4429,19 +4436,21 @@ Tab.prototype = {
       defaultZoom: metadata.defaultZoom || window.devicePixelRatio,
       minZoom: metadata.minZoom || 0,
       maxZoom: metadata.maxZoom || 0,
       isRTL: metadata.isRTL,
       tabID: this.id
     });
   },
 
-  setBrowserSize: function(aWidth, aHeight) {
-    if (fuzzyEquals(this.browserWidth, aWidth) && fuzzyEquals(this.browserHeight, aHeight)) {
-      return;
+  setBrowserSize: function(aWidth, aHeight, aForce) {
+    if (!aForce) {
+      if (fuzzyEquals(this.browserWidth, aWidth) && fuzzyEquals(this.browserHeight, aHeight)) {
+        return;
+      }
     }
 
     this.browserWidth = aWidth;
     this.browserHeight = aHeight;
 
     if (!this.browser.contentWindow)
       return;
     let cwu = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);