Bug 630736 - Fix restoreViewportPosition regressions [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Mon, 14 Feb 2011 20:37:56 -0800
changeset 67390 5cc71c89b84b1ab3dda6eb4c0a6688d1fd440f00
parent 67389 0318fed779caeeed52598dad4a76d393ccf352a0
child 67391 ec2b8e10fc44c6aa4e88400f4a2cb3bf366baceb
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
bugs630736
Bug 630736 - Fix restoreViewportPosition regressions [r=mfinkle]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -2434,23 +2434,21 @@ Tab.prototype = {
 
   restoreViewportPosition: function restoreViewportPosition(aOldWidth, aNewWidth) {
     let browser = this._browser;
 
     // zoom to keep the same portion of the document visible
     let oldScale = browser.scale;
     let newScale = this.clampZoomLevel(oldScale * aNewWidth / aOldWidth);
     let scaleRatio = newScale / oldScale;
-  
-    // Recalculate whether the visible area is actually in bounds
+
     let view = browser.getRootView();
-    view.scrollBy(0,0);
-
     let pos = view.getPosition();
     browser.fuzzyZoom(newScale, pos.x * scaleRatio, pos.y * scaleRatio);
+    browser.finishFuzzyZoom();
   },
 
   startLoading: function startLoading() {
     if (this._loading) throw "Already Loading!";
     this._loading = true;
   },
 
   endLoading: function endLoading() {
@@ -2761,27 +2759,27 @@ var ViewableAreaObserver = {
     Browser.styles["viewable-height"].maxHeight = newHeight + "px";
 
     Browser.styles["viewable-width"].width = newWidth + "px";
     Browser.styles["viewable-width"].maxWidth = newWidth + "px";
 
     let startup = !oldHeight && !oldWidth;
     for (let i = Browser.tabs.length - 1; i >= 0; i--) {
       let tab = Browser.tabs[i];
-      tab.updateViewportSize();
-      
+      let oldContentWindowWidth = tab.browser.contentWindowWidth;
+      tab.updateViewportSize(); // contentWindowWidth may change here.
+
       // Don't bother updating the zoom level on startup
-      if (!startup)
+      if (!startup) {
+        // If the viewport width is still the same, the page layout has not
+        // changed, so we can keep keep the same content on-screen.
+        if (tab.browser.contentWindowWidth == oldContentWindowWidth)
+          tab.restoreViewportPosition(oldWidth, newWidth);
+
         tab.updateDefaultZoomLevel();
-
-      // If the viewport width is still the same, the page layout has not
-      // changed, so we can keep keep the same content on-screen.
-      if (tab.browser.contentWindowWidth == oldWidth) {
-        tab.restoreViewportPosition(oldWidth, newWidth);
-        tab.browser.finishFuzzyZoom();
       }
     }
 
     // setTimeout(callback, 0) to ensure the resize event handler dispatch is finished
     setTimeout(function() {
       let event = document.createEvent("Events");
       event.initEvent("SizeChanged", true, false);
       Elements.browsers.dispatchEvent(event);