Bug 554979 - zoomin and zoomout should use better/nonlinear increments [r=mfinkle]

This commit is contained in:
Matt Brubeck 2010-04-12 22:42:35 -04:00
parent 7985bf2c03
commit f3f922def7
3 changed files with 9 additions and 7 deletions

View File

@ -40,12 +40,9 @@
let Ci = Components.interfaces;
const kBrowserViewZoomLevelMin = 0.2;
const kBrowserViewZoomLevelMax = 4.0;
const kBrowserFormZoomLevelMin = 1.0;
const kBrowserFormZoomLevelMax = 2.0;
const kBrowserViewZoomLevelPrecision = 10000;
const kBrowserViewZoomLevelIncrement = 0.1;
const kBrowserViewPrefetchBeginIdleWait = 1; // seconds
const kBrowserViewPrefetchBeginIdleWaitLoading = 10; // seconds
const kBrowserViewCacheSize = 6;
@ -156,7 +153,7 @@ BrowserView.Util = {
},
clampZoomLevel: function clampZoomLevel(zl) {
let bounded = Math.min(Math.max(kBrowserViewZoomLevelMin, zl), kBrowserViewZoomLevelMax);
let bounded = Math.min(Math.max(ZoomManager.MIN, zl), ZoomManager.MAX);
let rounded = Math.round(bounded * kBrowserViewZoomLevelPrecision) / kBrowserViewZoomLevelPrecision;
return (rounded) ? rounded : 1.0;
},

View File

@ -1022,9 +1022,13 @@ var Browser = {
/** Zoom one step in (negative) or out (positive). */
zoom: function zoom(aDirection) {
let bv = this._browserView;
let zoomLevel = bv.getZoomLevel() + (aDirection > 0 ? -1 : 1) * kBrowserViewZoomLevelIncrement;
let zoomLevel = bv.getZoomLevel();
let zoomValues = ZoomManager.zoomValues;
var i = zoomValues.indexOf(ZoomManager.snap(zoomLevel)) + (aDirection < 0 ? 1 : -1);
if (i >= 0 && i < zoomValues.length)
zoomLevel = zoomValues[i];
zoomLevel = BrowserView.Util.adjustZoomLevel(zoomLevel, kBrowserViewZoomLevelIncrement / 2);
zoomLevel = Math.max(zoomLevel, bv.getPageZoomLevel());
let center = this.getVisibleRect().center().map(bv.viewportToBrowser);
@ -1076,7 +1080,7 @@ var Browser = {
x = bv.browserToViewport(x);
y = bv.browserToViewport(y);
zoomLevel = Math.min(kBrowserViewZoomLevelMax, zoomLevel);
zoomLevel = Math.min(ZoomManager.MAX, zoomLevel);
let zoomRatio = zoomLevel / bv.getZoomLevel();
let newVisW = vis.width / zoomRatio, newVisH = vis.height / zoomRatio;
let result = new Rect(x - newVisW / 2, y - newVisH / 2, newVisW, newVisH);

View File

@ -71,6 +71,7 @@
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
<script type="application/javascript" src="chrome://browser/content/commandUtil.js"/>
<script type="application/javascript" src="chrome://browser/content/exceptions.js"/>
<script type="application/javascript" src="chrome://browser/content/browser.js"/>