mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 10:33:33 +00:00
Bug 583828 - Fix zoom level calculation in _getZoomRectForRect [r=stechz]
This commit is contained in:
parent
103eb5da04
commit
0a217bf85c
@ -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);
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user