Bug 707935 - Prevent page size changes until document.readyState reads "complete". r=kats
authorPatrick Walton <pwalton@mozilla.com>
Thu, 08 Dec 2011 21:30:26 -0800
changeset 84004 3d9d4b6404419f2e0a0e745938fea228ffa34ad9
parent 84003 ee420d0f03df7b7446ce15d8acc365ad4fa61627
child 84005 c28beca4a896a54dd24b9028cc16a84a390fd922
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs707935
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 707935 - Prevent page size changes until document.readyState reads "complete". r=kats
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1147,32 +1147,37 @@ Tab.prototype = {
 
   get viewport() {
     // Update the viewport to current dimensions
     this._viewport.x = this.browser.contentWindow.scrollX +
                        this.viewportExcess.x;
     this._viewport.y = this.browser.contentWindow.scrollY +
                        this.viewportExcess.y;
 
+    // Transform coordinates based on zoom
+    this._viewport.x = Math.round(this._viewport.x * this._viewport.zoom);
+    this._viewport.y = Math.round(this._viewport.y * this._viewport.zoom);
+
+    /*
+     * Don't alter the page size until we hit DOMContentLoaded, because this causes the page size
+     * to jump around wildly during page load.
+     */
     let doc = this.browser.contentDocument;
-    let pageWidth = this._viewport.width;
-    let pageHeight = this._viewport.height;
-    if (doc != null) {
+    if (doc != null && doc.readyState === 'complete') {
+      let pageWidth = this._viewport.width, pageHeight = this._viewport.height;
       let body = doc.body || { scrollWidth: pageWidth, scrollHeight: pageHeight };
       let html = doc.documentElement || { scrollWidth: pageWidth, scrollHeight: pageHeight };
       pageWidth = Math.max(body.scrollWidth, html.scrollWidth);
       pageHeight = Math.max(body.scrollHeight, html.scrollHeight);
+
+      /* Transform the page width and height based on the zoom factor. */
+      this._viewport.pageWidth = Math.round(pageWidth * this._viewport.zoom);
+      this._viewport.pageHeight = Math.round(pageHeight * this._viewport.zoom);
     }
 
-    // Transform coordinates based on zoom
-    this._viewport.x = Math.round(this._viewport.x * this._viewport.zoom);
-    this._viewport.y = Math.round(this._viewport.y * this._viewport.zoom);
-    this._viewport.pageWidth = Math.round(pageWidth * this._viewport.zoom);
-    this._viewport.pageHeight = Math.round(pageHeight * this._viewport.zoom);
-
     return this._viewport;
   },
 
   updateViewport: function(aReset) {
     let win = this.browser.contentWindow;
     let zoom = (aReset ? this.getDefaultZoomLevel() : this._viewport.zoom);
     let xpos = (aReset ? win.scrollX * zoom : this._viewport.x);
     let ypos = (aReset ? win.scrollY * zoom : this._viewport.y);