Bug 630942 - Make sure we update the cache viewport after orientation changes [r=stechz]
authorWes Johnston <wjohnston@mozilla.com>
Wed, 02 Feb 2011 16:21:47 -0800
changeset 2734 ecb8351218370e1543e8cf40c287c37a6099987d
parent 2733 aa7daa3816c8624247b3e7d36709fdfe2adaee72
child 2735 1165fcc932427cf7ba66dffd5c800753a4dd4c3e
push id2296
push userwjohnston@mozilla.com
push dateThu, 03 Feb 2011 00:22:44 +0000
reviewersstechz
bugs630942
Bug 630942 - Make sure we update the cache viewport after orientation changes [r=stechz]
chrome/content/bindings/browser.xml
chrome/content/browser.js
--- a/chrome/content/bindings/browser.xml
+++ b/chrome/content/bindings/browser.xml
@@ -577,16 +577,33 @@
       <field name="_active">false</field>
       <property name="active" onget="return this._active;">
         <setter><![CDATA[
           // Do not change displayport on local tabs!
           this._active = val;
         ]]></setter>
       </property>
 
+      <!-- Transform the viewport without updating the displayport. -->
+      <method name="fuzzyZoom">
+        <parameter name="scale"/>
+        <parameter name="x"/>
+        <parameter name="y"/>
+        <body><![CDATA[
+          this.getRootView().scrollTo(x, y);
+        ]]></body>
+      </method>
+
+      <!-- After fuzzy zoom, sync the displayport with the new viewport. -->
+      <method name="finishFuzzyZoom">
+        <body><![CDATA[
+          return;
+        ]]></body>
+      </method>
+
     </implementation>
   </binding>
 
   <binding id="remote-browser" extends="#local-browser">
     <implementation type="application/javascript" implements="nsIAccessibleProvider, nsIObserver, nsIDOMEventListener, nsIFrameMessageListener">
       <property name="accessibleType" readonly="true">
         <getter>
           <![CDATA[
--- a/chrome/content/browser.js
+++ b/chrome/content/browser.js
@@ -313,16 +313,17 @@ var Browser = {
       let [scrollbox, scrollInterface] = ScrollUtils.getScrollboxFromElement(currentElement);
       if (scrollbox && scrollInterface && currentElement && currentElement != scrollbox) {
         // retrieve the direct child of the scrollbox
         while (currentElement.parentNode != scrollbox)
           currentElement = currentElement.parentNode;
 
         setTimeout(function() { scrollInterface.ensureElementIsVisible(currentElement) }, 0);
       }
+      getBrowser().finishFuzzyZoom();
     }
     window.addEventListener("resize", resizeHandler, false);
 
     function fullscreenHandler() {
       if (!window.fullScreen)
         document.getElementById("toolbar-main").setAttribute("fullscreen", "true");
       else
         document.getElementById("toolbar-main").removeAttribute("fullscreen");
@@ -2529,21 +2530,18 @@ Tab.prototype = {
   restoreViewportPosition: function restoreViewportPosition(aOldWidth, aNewWidth) {
     let browser = this._browser;
     let view = browser.getRootView();
     let pos = view.getPosition();
 
     // zoom to keep the same portion of the document visible
     let oldScale = browser.scale;
     let newScale = this.clampZoomLevel(oldScale * aNewWidth / aOldWidth);
-    browser.scale = newScale;
-
-    // ...and keep the same top-left corner of the visible rect
     let scaleRatio = newScale / oldScale;
-    view.scrollTo(pos.x * scaleRatio, pos.y * scaleRatio);
+    browser.fuzzyZoom(newScale, pos.x * scaleRatio, pos.y * scaleRatio);
   },
 
   startLoading: function startLoading() {
     if (this._loading) throw "Already Loading!";
     this._loading = true;
   },
 
   endLoading: function endLoading() {