Bug 783208 - Force a zoom out on double-tap if we're already zoomed in to the maximum allowed zoom. r=wesj
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 21 Aug 2012 12:44:37 -0400
changeset 102946 dff40a793fab02d253ad2a69f7ed38b0d9b02479
parent 102945 27b3a3e33f9246961a38378d078290c6d1fb928a
child 102947 3c39fdebf3862b9f0bc7348ca6ba461feb259540
push id23317
push userryanvm@gmail.com
push dateWed, 22 Aug 2012 02:05:02 +0000
treeherdermozilla-central@abc17059522b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj
bugs783208
milestone17.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 783208 - Force a zoom out on double-tap if we're already zoomed in to the maximum allowed zoom. r=wesj
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3410,16 +3410,23 @@ var BrowserEventHandler = {
     // This function checks to see if the area of the rect visible in the
     // viewport (i.e. the "overlapArea" variable below) is approximately
     // the max area of the rect we can show. It also checks that the rect
     // is actually on-screen by testing the left and right edges of the rect.
     // In effect, this tells us whether or not zooming in to this rect
     // will significantly change what the user is seeing.
     const minDifference = -20;
     const maxDifference = 20;
+    const maxZoomAllowed = 4; // keep this in sync with mobile/android/base/ui/PanZoomController.MAX_ZOOM
+
+    if (Math.abs(aViewport.zoom - maxZoomAllowed) < 1e-6) {
+      // we're already at the max zoom, so even if the block isn't taking up most of the viewport we can't
+      // zoom in any more. return true so that we zoom out
+      return true;
+    }
 
     let vRect = new Rect(aViewport.cssX, aViewport.cssY, aViewport.cssWidth, aViewport.cssHeight);
     let overlap = vRect.intersect(aRect);
     let overlapArea = overlap.width * overlap.height;
     let availHeight = Math.min(aRect.width * vRect.height / vRect.width, aRect.height);
     let showing = overlapArea / (aRect.width * availHeight);
     let dw = (aRect.width - vRect.width);
     let dx = (aRect.x - vRect.x);