Bug 799333: Make reflow-on-zoom reset after a double-tap to zoom out. [r=blassey]
authorScott Johnson <sjohnson@mozilla.com>
Thu, 25 Oct 2012 10:40:30 -0500
changeset 111539 df865cb16fb049544033a50b2ca61d9aff486fe8
parent 111538 15c00f89393920d668b1038a4f59c753cd33061a
child 111540 86ccf7c918ce6392d8d5eb20acb05fdcf6936c11
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersblassey
bugs799333
milestone19.0a1
Bug 799333: Make reflow-on-zoom reset after a double-tap to zoom out. [r=blassey]
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3579,16 +3579,23 @@ var BrowserEventHandler = {
     document.addEventListener("MozMagnifyGestureStart", this, true);
     document.addEventListener("MozMagnifyGestureUpdate", this, true);
     document.addEventListener("MozMagnifyGesture", this, true);
 
     Services.prefs.addObserver("browser.zoom.reflowOnZoom", this, false);
     this.updateReflozPref();
   },
 
+  resetMaxLineBoxWidth: function() {
+    let webNav = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation);
+    let docShell = webNav.QueryInterface(Ci.nsIDocShell);
+    let docViewer = docShell.contentViewer.QueryInterface(Ci.nsIMarkupDocumentViewer);
+    docViewer.changeMaxLineBoxWidth(0);
+  },
+
   updateReflozPref: function() {
      this.mReflozPref = Services.prefs.getBoolPref("browser.zoom.reflowOnZoom");
   },
 
   handleEvent: function(aEvent) {
     switch (aEvent.type) {
       case 'touchstart':
         this._handleTouchStart(aEvent);
@@ -3742,16 +3749,17 @@ var BrowserEventHandler = {
     } else if (aTopic == "nsPref:changed") {
       if (aData == "browser.zoom.reflowOnZoom") {
         this.updateReflozPref();
       }
     }
   },
 
   _zoomOut: function() {
+    BrowserEventHandler.resetMaxLineBoxWidth();
     sendMessageToJava({ gecko: { type: "Browser:ZoomToPageWidth"} });
   },
 
   _isRectZoomedIn: function(aRect, aViewport) {
     // This function checks to see if the area of the rect visible in the
     // viewport (i.e. the "overlapArea" variable below) is approximately
     // the max area of the rect we can show. It also checks that the rect
     // is actually on-screen by testing the left and right edges of the rect.
@@ -3834,16 +3842,20 @@ var BrowserEventHandler = {
       // the 1.2 multiplier is just a little fuzz to compensate for bRect including horizontal
       // margins but not vertical ones.
       let cssTapY = viewport.cssY + aClickY;
       if ((bRect.height > rect.h) && (cssTapY > rect.y + (rect.h * 1.2))) {
         rect.y = cssTapY - (rect.h / 2);
       }
     }
 
+    if (rect.w > viewport.cssWidth || rect.h > viewport.cssHeight) {
+      BrowserEventHandler.resetMaxLineBoxWidth();
+    }
+
     sendMessageToJava({ gecko: rect });
   },
 
   _zoomInAndSnapToElement: function(aX, aY, aElement) {
     let viewport = BrowserApp.selectedTab.getViewport();
     if (viewport.zoom < 1.0) {
       // We don't want to do this on zoom out.
       return;