Bug 533989 - center page when doing incremental zoom [r=mfinkle]
authorBenjamin Stover <bstover@mozilla.com>
Thu, 10 Dec 2009 11:00:46 -0800
changeset 65900 173108bd5c54a08fc2e3a634d219ddfa583ec829
parent 65899 0c7200cfc1dc183e8b10d56de85844dca000a36b
child 65901 060c00af8353c26372b4dd7fe88c3abfd6b2508a
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
bugs533989
Bug 533989 - center page when doing incremental zoom [r=mfinkle]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -1016,24 +1016,20 @@ var Browser = {
       BrowserUI.unlockToolbar();
       this.floatedWhileDragging = false;
       return true;
     }
     return false;
   },
 
   zoom: function zoom(aDirection) {
-    Browser._browserView.zoom(aDirection);
-    //Browser.forceChromeReflow();  // Zoom causes a width/height change to the
-                                    // BrowserView's containing element, but
-                                    // sometimes doesn't cause the reflow that
-                                    // resizes the parent right away, so we
-                                    // can preempt it here.  Not needed anywhere
-                                    // currently but if this becomes API or is
-                                    // needed then uncomment this line.
+    let bv = this._browserView;
+    let zoomLevel = bv.getZoomLevel() + (aDirection > 0 ? -0.1 : 0.1);
+    let center = this.getVisibleRect().center().map(bv.viewportToBrowser);
+    this.setVisibleRect(this._getZoomRectForPoint(center.x, center.y, zoomLevel));
   },
 
   /**
    * Find the needed zoom level for zooming on an element
    */
   _getZoomLevelForElement: function _getZoomLevelForElement(element) {
     const margin = 15;