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 67345 e2054b050332ef94709463e7c53fe4fe28de4da9
parent 67344 7bbfd73102ab81cce0c8ed453ec637084d1f6fbc
child 67346 3f3341d2bd07587107bd11380d1fd7f9bb09aa6c
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
bugs630942
Bug 630942 - Make sure we update the cache viewport after orientation changes [r=stechz]
mobile/chrome/content/bindings/browser.xml
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/bindings/browser.xml
+++ b/mobile/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/mobile/chrome/content/browser.js
+++ b/mobile/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() {