Bug 583828 - Fix zoom level calculation in _getZoomRectForRect [r=stechz]
authorMatt Brubeck <mbrubeck@mozilla.com>
Mon, 02 Aug 2010 13:54:52 -0700
changeset 66424 0572e3c9815e58d12aed5f11bbb7400452915797
parent 66423 9881ebe75e0562d11e2524242d835786a3a857ae
child 66425 3a07bb2b13364c3f0536621e0d6b24d28a6be5ee
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)
reviewersstechz
bugs583828
Bug 583828 - Fix zoom level calculation in _getZoomRectForRect [r=stechz]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -1510,17 +1510,17 @@ var FindHelperUI = {
   },
 
   _zoom: function _findHelperZoom(aElementRect) {
     let bv = Browser._browserView;
     let zoomRect = bv.getVisibleRect();
 
     // Zoom to a specified Rect
     if (aElementRect && bv.allowZoom && Services.prefs.getBoolPref("findhelper.autozoom")) {
-      let zoomLevel = Browser._getZoomLevelForRect(bv.browserToViewportRect(aElementRect.clone()));
+      let zoomLevel = Browser._getZoomLevelForRect(aElementRect);
       zoomLevel = Math.min(Math.max(kBrowserFormZoomLevelMin, zoomLevel), kBrowserFormZoomLevelMax);
 
       zoomRect = Browser._getZoomRectForPoint(aElementRect.center().x, aElementRect.y, zoomLevel);
       Browser.animatedZoomTo(zoomRect);
     }
   }
 };
 
@@ -1732,17 +1732,17 @@ var FormHelperUI = {
   /** Zoom and move viewport so that element is legible and touchable. */
   _zoom: function _formHelperZoom(aElementRect, aCaretRect) {
     let bv = Browser._browserView;
     let zoomRect = bv.getVisibleRect();
 
     // Zoom to a specified Rect
     if (aElementRect && bv.allowZoom && Services.prefs.getBoolPref("formhelper.autozoom")) {
       // Zoom to an element by keeping the caret into view
-      let zoomLevel = Browser._getZoomLevelForRect(bv.browserToViewportRect(aElementRect.clone()));
+      let zoomLevel = Browser._getZoomLevelForRect(aElementRect);
       zoomLevel = Math.min(Math.max(kBrowserFormZoomLevelMin, zoomLevel), kBrowserFormZoomLevelMax);
 
       zoomRect = Browser._getZoomRectForPoint(aElementRect.center().x, aElementRect.y, zoomLevel);
       Browser.animatedZoomTo(zoomRect);
     }
 
     // Move the view to show the caret if needed
     if (aCaretRect) {
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -1071,25 +1071,25 @@ var Browser = {
       zoomLevel = zoomValues[i];
 
     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. */
+  /** Rect should be in browser coordinates. */
   _getZoomLevelForRect: function _getZoomLevelForRect(rect) {
     const margin = 15;
 
     let bv = this._browserView;
     let vis = bv.getVisibleRect();
-   
-    return bv.clampZoomLevel(bv.getZoomLevel() * vis.width / (rect.width + margin * 2));
-  }, 
+
+    return bv.clampZoomLevel(vis.width / (rect.width + margin * 2));
+  },
 
   /**
    * Find an appropriate zoom rect for an element bounding rect, if it exists.
    * @return Rect in viewport coordinates
    * */
   _getZoomRectForRect: function _getZoomRectForRect(rect, y) {
     let bv = this._browserView;
     let oldZoomLevel = bv.getZoomLevel();