diff --git a/browser/base/content/browser-fullZoom.js b/browser/base/content/browser-fullZoom.js index b74a3213f7b2..57890c547425 100644 --- a/browser/base/content/browser-fullZoom.js +++ b/browser/base/content/browser-fullZoom.js @@ -384,20 +384,16 @@ var FullZoom = { browser.messageManager.sendAsyncMessage("Reader:ResetZoom"); } else if (this._isPDFViewer(browser)) { browser.messageManager.sendAsyncMessage("PDFJS:ZoomReset"); - } else { - let token = this._getBrowserToken(browser); - let result = this._getGlobalValue(browser).then(value => { - if (token.isCurrent) { - ZoomManager.setZoomForBrowser( - browser, - value === undefined ? 1 : value - ); - this._ignorePendingZoomAccesses(browser); - } - }); - this._removePref(browser); - return result; } + let token = this._getBrowserToken(browser); + let result = this._getGlobalValue(browser).then(value => { + if (token.isCurrent) { + ZoomManager.setZoomForBrowser(browser, value === undefined ? 1 : value); + this._ignorePendingZoomAccesses(browser); + } + }); + this._removePref(browser); + return result; }, /** diff --git a/toolkit/components/reader/AboutReader.jsm b/toolkit/components/reader/AboutReader.jsm index 60842fa37de4..83c8f37b9d25 100644 --- a/toolkit/components/reader/AboutReader.jsm +++ b/toolkit/components/reader/AboutReader.jsm @@ -39,6 +39,11 @@ var gStrings = Services.strings.createBundle( "chrome://global/locale/aboutReader.properties" ); +const zoomOnCtrl = + Services.prefs.getIntPref("mousewheel.with_control.action", 3) == 3; +const zoomOnMeta = + Services.prefs.getIntPref("mousewheel.with_meta.action", 1) == 3; + const gIsFirefoxDesktop = Services.appinfo.ID == "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"; @@ -116,6 +121,7 @@ var AboutReader = function(mm, win, articlePromise) { win.addEventListener("pagehide", this); win.addEventListener("mozvisualscroll", this, { mozSystemGroup: true }); win.addEventListener("resize", this); + win.addEventListener("wheel", this, { passive: false }); Services.obs.addObserver(this, "inner-window-destroyed"); @@ -414,6 +420,36 @@ AboutReader.prototype = { } break; + case "wheel": + let doZoom = + (aEvent.ctrlKey && zoomOnCtrl) || (aEvent.metaKey && zoomOnMeta); + if (!doZoom) { + return; + } + aEvent.preventDefault(); + + // Throttle events to once per 150ms. This avoids excessively fast zooming. + if (aEvent.timeStamp <= this._zoomBackoffTime) { + return; + } + this._zoomBackoffTime = aEvent.timeStamp + 150; + + // Determine the direction of the delta (we don't care about its size); + // This code is adapted from normalizeWheelEventDelta in + // browser/extensions/pdfjs/content/web/viewer.js + let delta = Math.abs(aEvent.deltaX) + Math.abs(aEvent.deltaY); + let angle = Math.atan2(aEvent.deltaY, aEvent.deltaX); + if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) { + delta = -delta; + } + + if (delta > 0) { + this._changeFontSize(+1); + } else if (delta < 0) { + this._changeFontSize(-1); + } + break; + case "devicelight": this._handleDeviceLight(aEvent.value); break;