Bug 602707 - Fixes for FormHelper zoom [r=mfinkle,vingtetun]
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -2040,17 +2040,17 @@ var FormHelperUI = {
} else {
harmonizedCaretHeight = 30; // fallback height
// use the element as position
harmonizedCaretY = aElementRect.y;
aCaretRect.x = aElementRect.x;
}
- let zoomLevel = browser.scale;
+ let oldZoomLevel = zoomLevel = browser.scale;
let enableZoom = Browser.selectedTab.allowZoom && Services.prefs.getBoolPref("formhelper.autozoom");
if (enableZoom) {
zoomLevel = (viewAreaHeight / caretLines) / harmonizedCaretHeight;
zoomLevel = Util.clamp(zoomLevel, kBrowserFormZoomLevelMin, kBrowserFormZoomLevelMax);
zoomLevel = Browser.selectedTab.clampZoomLevel(zoomLevel);
}
viewAreaWidth /= zoomLevel;
@@ -2059,31 +2059,32 @@ var FormHelperUI = {
// if the viewAreaWidth is smaller than the neutralized position + margins.
// [YES] use the x position of the element minus margins as x position for our visible rect.
// [NO] use the x position of the caret minus margins as the x position for our visible rect.
let x = (marginLeft + marginRight + margin + aCaretRect.x - aElementRect.x) < viewAreaWidth
? aElementRect.x - margin - marginLeft
: aCaretRect.x - viewAreaWidth + margin + marginRight;
// Use the adjusted Caret Y minus a margin for our visible rect
let y = harmonizedCaretY - margin;
- x *= browser.scale;
- y *= browser.scale;
+ x *= oldZoomLevel;
+ y *= oldZoomLevel;
let scroll = browser.getPosition();
// from here on play with zoomed values
// if we want to have it animated, build up zoom rect and animate.
- if (enableZoom && browser.scale != zoomLevel) {
+ if (enableZoom) {
// don't use browser functions they are bogus for this case
- let zoomRatio = zoomLevel / browser.scale;
+ let zoomRatio = zoomLevel / oldZoomLevel;
let visW = window.innerWidth, visH = window.innerHeight;
let newVisW = visW / zoomRatio, newVisH = visH / zoomRatio;
let zoomRect = new Rect(x, y, newVisW, newVisH);
-
+ zoomRect.translateInside(new Rect(0, 0, browser.contentDocumentWidth * oldZoomLevel,
+ browser.contentDocumentHeight * oldZoomLevel));
Browser.animatedZoomTo(zoomRect);
}
else { // no zooming at all
browser.scrollTo(x, y);
}
}
},