Bug 640217 - Clamp zoom value at end of animated zoom [r=mfinkle, a=blocking-fennec]
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 09 Mar 2011 13:55:10 -0800
changeset 67494 5d5bb68d29c82e7c1cb2164ec3e7fa725034fef4
parent 67493 87f6e276c420dd9a45c5d2b9674f8d3594dcd05a
child 67495 0771e2c06dbd989de09dc4d5f6aaa429ea8db281
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, blocking-fennec
bugs640217
Bug 640217 - Clamp zoom value at end of animated zoom [r=mfinkle, a=blocking-fennec]
mobile/chrome/content/AnimatedZoom.js
--- a/mobile/chrome/content/AnimatedZoom.js
+++ b/mobile/chrome/content/AnimatedZoom.js
@@ -69,17 +69,18 @@ const AnimatedZoom = {
 
       let event = document.createEvent("Events");
       event.initEvent("AnimatedZoomBegin", true, true);
       window.dispatchEvent(event);
     }
   },
 
   start: function start() {
-    this.browser = getBrowser();
+    this.tab = Browser.selectedTab;
+    this.browser = this.tab.browser;
     this.zoomFrom = this.zoomRect || this.getStartRect();
     this.startScale = this.browser.scale;
     this.beginTime = mozAnimationStartTime;
   },
 
   /** Get the visible rect, in device pixels relative to the content origin. */
   getStartRect: function getStartRect() {
     let browser = this.browser;
@@ -98,17 +99,24 @@ const AnimatedZoom = {
     this.browser.fuzzyZoom(scale, scrollX, scrollY);
 
     this.zoomRect = nextRect;
   },
 
   /** Stop animation, zoom to point, and clean up. */
   finish: function() {
     this.updateTo(this.zoomTo || this.zoomRect);
-    this.browser.finishFuzzyZoom();
+
+    // Check whether the zoom limits have changed since the animation started.
+    let browser = this.browser;
+    let finalScale = this.tab.clampZoomLevel(browser.scale);
+    if (browser.scale != finalScale)
+      browser.scale = finalScale; // scale= calls finishFuzzyZoom.
+    else
+      browser.finishFuzzyZoom();
 
     Browser.hideSidebars();
     Browser.hideTitlebar();
 
     this.beginTime = null;
     this.zoomTo = null;
     this.zoomFrom = null;
     this.zoomRect = null;