Bug 672411 - Calculate the viewport height correctly for non-scalable pages [r=wesj]
authorMatt Brubeck <mbrubeck@mozilla.com>
Fri, 29 Jul 2011 07:18:50 -0700
changeset 73540 10cb6aeef3859a6aac439039f3074b5b15c05dd5
parent 73539 691c76a1a4559b8acab01b8ec50ce206b3d2047f
child 73541 32b8eb4569b7cebc359706ffc10a6925b1e6287f
push id857
push usermbrubeck@mozilla.com
push dateFri, 29 Jul 2011 14:20:37 +0000
treeherdermozilla-inbound@10cb6aeef385 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs672411
milestone8.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 672411 - Calculate the viewport height correctly for non-scalable pages [r=wesj]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -2726,18 +2726,18 @@ Tab.prototype = {
       } else if (!validW && !validH) {
         viewportW = this.useFallbackWidth ? kFallbackBrowserWidth : kDefaultBrowserWidth;
         viewportH = kDefaultBrowserWidth * (screenH / screenW);
       }
     }
 
     // Make sure the viewport height is not shorter than the window when
     // the page is zoomed out to show its full width.
-    if (viewportH * this.clampZoomLevel(this.getPageZoomLevel()) < screenH)
-      viewportH = Math.max(viewportH, screenH * (browser.contentDocumentWidth / screenW));
+    let minScale = this.clampZoomLevel(this.getPageZoomLevel());
+    viewportH = Math.max(viewportH, screenH / minScale);
 
     if (browser.contentWindowWidth != viewportW || browser.contentWindowHeight != viewportH)
       browser.setWindowSize(viewportW, viewportH);
   },
 
   restoreViewportPosition: function restoreViewportPosition(aOldWidth, aNewWidth) {
     let browser = this._browser;
 
@@ -2860,20 +2860,23 @@ Tab.prototype = {
       this._browser = null;
       this._loading = false;
 
       Elements.browsers.removeChild(notification);
     }
   },
 
   clampZoomLevel: function clampZoomLevel(aScale) {
+    let md = this.metadata;
+    if (!this.allowZoom)
+      return (md && md.defaultZoom) ? md.defaultZoom : this.getPageZoomLevel();
+
     let browser = this._browser;
     let bounded = Util.clamp(aScale, ZoomManager.MIN, ZoomManager.MAX);
 
-    let md = this.metadata;
     if (md && md.minZoom)
       bounded = Math.max(bounded, md.minZoom);
     if (md && md.maxZoom)
       bounded = Math.min(bounded, md.maxZoom);
 
     bounded = Math.max(bounded, this.getPageZoomLevel());
 
     let rounded = Math.round(bounded * kBrowserViewZoomLevelPrecision) / kBrowserViewZoomLevelPrecision;