Bug 576396 - Pinch zoom allows zooming out past minimum (page-fit) level [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.org>
Tue, 13 Jul 2010 10:01:44 -0400
changeset 66360 cf1683f3b814aef073fd542a07ff95329bbad9bd
parent 66359 132dd5270c13c1fe21a8dfd6b51341235819bf29
child 66361 bce4e416fd3ffcff78d5f1a91785d9532f8437a0
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs576396
Bug 576396 - Pinch zoom allows zooming out past minimum (page-fit) level [r=mfinkle]
mobile/chrome/content/BrowserView.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/BrowserView.js
+++ b/mobile/chrome/content/BrowserView.js
@@ -310,16 +310,18 @@ BrowserView.prototype = {
 
     let bvs = this._browserViewportState;
     if (bvs) {
       let md = bvs.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;
     return rounded || 1.0;
   },
 
   beginOffscreenOperation: function beginOffscreenOperation(rect) {
     if (this._offscreenDepth == 0) {
@@ -573,35 +575,35 @@ BrowserView.prototype = {
     return bvs.zoomLevel == bvs.defaultZoomLevel;
   },
 
   getDefaultZoomLevel: function getDefaultZoomLevel() {
     let bvs = this._browserViewportState;
     if (!bvs)
       return 0;
 
+    let md = bvs.metaData;
+    if (md && md.defaultZoom)
+      return this.clampZoomLevel(md.defaultZoom);
+
     let pageZoom = this.getPageZoomLevel();
 
     // If pageZoom is "almost" 100%, zoom in to exactly 100% (bug 454456).
     let granularity = gPrefService.getIntPref("browser.ui.zoom.pageFitGranularity");
     let threshold = 1 - 1 / granularity;
     if (threshold < pageZoom && pageZoom < 1)
       pageZoom = 1;
 
-    let md = bvs.metaData;
-    if (md && md.defaultZoom)
-      return Math.max(pageZoom, this.clampZoomLevel(md.defaultZoom));
-
-    return pageZoom;
+    return this.clampZoomLevel(pageZoom);
   },
 
   getPageZoomLevel: function getPageZoomLevel() {
     let bvs = this._browserViewportState;  // browser exists, so bvs must as well
     let browserW = this.viewportToBrowser(bvs.viewportRect.right);
-    return this.clampZoomLevel(this.getVisibleRect().width / browserW);
+    return this.getVisibleRect().width / browserW;
   },
 
   zoom: function zoom(aDirection) {
     let bvs = this._browserViewportState;
     if (!bvs)
       throw "No browser is set";
 
     if (aDirection == 0)
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -1064,17 +1064,17 @@ var Browser = {
 
     let zoomLevel = bv.getZoomLevel();
 
     let zoomValues = ZoomManager.zoomValues;
     let i = zoomValues.indexOf(ZoomManager.snap(zoomLevel)) + (aDirection < 0 ? 1 : -1);
     if (i >= 0 && i < zoomValues.length)
       zoomLevel = zoomValues[i];
 
-    zoomLevel = Math.max(zoomLevel, bv.getPageZoomLevel());
+    zoomLevel = bv.clampZoomLevel(zoomLevel);
 
     let center = this.getVisibleRect().center().map(bv.viewportToBrowser);
     this.animatedZoomTo(this._getZoomRectForPoint(center.x, center.y, zoomLevel));
   },
 
   /** Rect should be in viewport coordinates. */
   _getZoomLevelForRect: function _getZoomLevelForRect(rect) {
     const margin = 15;