Bug 628633 - [Regression] Find in Page does not scroll down when hitting the Down Arrow from the findbar [r=mfinkle,mbrubeck]
authorVivien Nicolas <21@vingtetun.org>
Thu, 03 Feb 2011 18:58:43 +0100
changeset 67349 b634296c5cc5c13dd01817d2bdb451fb217b0856
parent 67348 52f77f69e6f3848f13b4ac1d70f5ae9092357836
child 67350 b7c97a621c577cbb077a03c8ff91d7ebec590b4f
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, mbrubeck
bugs628633
Bug 628633 - [Regression] Find in Page does not scroll down when hitting the Down Arrow from the findbar [r=mfinkle,mbrubeck]
mobile/chrome/content/common-ui.js
--- a/mobile/chrome/content/common-ui.js
+++ b/mobile/chrome/content/common-ui.js
@@ -555,24 +555,32 @@ var FindHelperUI = {
 
   updateCommands: function findHelperUpdateCommands(aValue) {
     let disabled = (this._status == Ci.nsITypeAheadFind.FIND_NOTFOUND) || (aValue == "");
     this._cmdPrevious.setAttribute("disabled", disabled);
     this._cmdNext.setAttribute("disabled", disabled);
   },
 
   _zoom: function _findHelperZoom(aElementRect) {
-    // Zoom to a specified Rect
-    if (aElementRect && Browser.selectedTab.allowZoom && Services.prefs.getBoolPref("findhelper.autozoom")) {
+    let autozoomEnabled = Services.prefs.getBoolPref("findhelper.autozoom");
+    if (!aElementRect || !autozoomEnabled)
+      return;
+
+    if (Browser.selectedTab.allowZoom) {
       let zoomLevel = Browser._getZoomLevelForRect(aElementRect);
       zoomLevel = Math.min(Math.max(kBrowserFormZoomLevelMin, zoomLevel), kBrowserFormZoomLevelMax);
       zoomLevel = Browser.selectedTab.clampZoomLevel(zoomLevel);
 
       let zoomRect = Browser._getZoomRectForPoint(aElementRect.center().x, aElementRect.y, zoomLevel);
       AnimatedZoom.animateTo(zoomRect);
+    } else {
+      // Even if zooming is disabled we could need to reposition the view in
+      // order to keep the element on-screen
+      let zoomRect = Browser._getZoomRectForPoint(aElementRect.center().x, aElementRect.y, getBrowser().scale);
+      AnimatedZoom.animateTo(zoomRect);
     }
   }
 };
 
 /**
  * Responsible for navigating forms and filling in information.
  *  - Navigating forms is handled by next and previous commands.
  *  - When an element is focused, the browser view zooms in to the control.