Bug 583828 - Fix zoom level calculation in _getZoomRectForRect [r=stechz]

This commit is contained in:
Matt Brubeck 2010-08-02 13:54:52 -07:00
parent 103eb5da04
commit 0a217bf85c
2 changed files with 6 additions and 6 deletions

View File

@ -1515,7 +1515,7 @@ var FindHelperUI = {
// Zoom to a specified Rect
if (aElementRect && bv.allowZoom && Services.prefs.getBoolPref("findhelper.autozoom")) {
let zoomLevel = Browser._getZoomLevelForRect(bv.browserToViewportRect(aElementRect.clone()));
let zoomLevel = Browser._getZoomLevelForRect(aElementRect);
zoomLevel = Math.min(Math.max(kBrowserFormZoomLevelMin, zoomLevel), kBrowserFormZoomLevelMax);
zoomRect = Browser._getZoomRectForPoint(aElementRect.center().x, aElementRect.y, zoomLevel);
@ -1737,7 +1737,7 @@ var FormHelperUI = {
// Zoom to a specified Rect
if (aElementRect && bv.allowZoom && Services.prefs.getBoolPref("formhelper.autozoom")) {
// Zoom to an element by keeping the caret into view
let zoomLevel = Browser._getZoomLevelForRect(bv.browserToViewportRect(aElementRect.clone()));
let zoomLevel = Browser._getZoomLevelForRect(aElementRect);
zoomLevel = Math.min(Math.max(kBrowserFormZoomLevelMin, zoomLevel), kBrowserFormZoomLevelMax);
zoomRect = Browser._getZoomRectForPoint(aElementRect.center().x, aElementRect.y, zoomLevel);

View File

@ -1076,15 +1076,15 @@ var Browser = {
this.animatedZoomTo(this._getZoomRectForPoint(center.x, center.y, zoomLevel));
},
/** Rect should be in viewport coordinates. */
/** Rect should be in browser coordinates. */
_getZoomLevelForRect: function _getZoomLevelForRect(rect) {
const margin = 15;
let bv = this._browserView;
let vis = bv.getVisibleRect();
return bv.clampZoomLevel(bv.getZoomLevel() * vis.width / (rect.width + margin * 2));
},
return bv.clampZoomLevel(vis.width / (rect.width + margin * 2));
},
/**
* Find an appropriate zoom rect for an element bounding rect, if it exists.