From 6ad3d5bf366e7fb21254ab8ed6f5263db1df5041 Mon Sep 17 00:00:00 2001 From: "berkay.barlas" Date: Wed, 27 Mar 2019 10:56:03 +0000 Subject: [PATCH] Bug 1536620 return default size in reader mode r=Gijs Call Reader:ResetZoom only in readermode and make resetFontSize async *** make resetFontSize async *** call Reader:ResetZoom only in readermode *** Differential Revision: https://phabricator.services.mozilla.com/D24445 --HG-- extra : moz-landing-system : lando --- browser/base/content/browser-fullZoom.js | 22 +++++++++++++--------- toolkit/components/reader/AboutReader.jsm | 12 ++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/browser/base/content/browser-fullZoom.js b/browser/base/content/browser-fullZoom.js index b5cd44fbe53e..d96d7d750c4b 100644 --- a/browser/base/content/browser-fullZoom.js +++ b/browser/base/content/browser-fullZoom.js @@ -313,15 +313,19 @@ var FullZoom = { * @return A promise which resolves when the zoom reset has been applied. */ reset: function FullZoom_reset(browser = gBrowser.selectedBrowser) { - 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; + if (browser.currentURI.spec.startsWith("about:reader")) { + browser.messageManager.sendAsyncMessage("Reader:ResetZoom"); + } 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; + } }, /** diff --git a/toolkit/components/reader/AboutReader.jsm b/toolkit/components/reader/AboutReader.jsm index a6962f692888..efa42a14bf44 100644 --- a/toolkit/components/reader/AboutReader.jsm +++ b/toolkit/components/reader/AboutReader.jsm @@ -39,6 +39,7 @@ var AboutReader = function(mm, win, articlePromise) { this._mm.addMessageListener("Reader:GetStoredArticleData", this); this._mm.addMessageListener("Reader:ZoomIn", this); this._mm.addMessageListener("Reader:ZoomOut", this); + this._mm.addMessageListener("Reader:ResetZoom", this); this._docRef = Cu.getWeakReference(doc); this._winRef = Cu.getWeakReference(win); @@ -268,6 +269,10 @@ AboutReader.prototype = { this._changeFontSize(-1); break; } + case "Reader:ResetZoom": { + this._resetFontSize(); + break; + } } }, @@ -326,6 +331,7 @@ AboutReader.prototype = { this._mm.removeMessageListener("Reader:GetStoredArticleData", this); this._mm.removeMessageListener("Reader:ZoomIn", this); this._mm.removeMessageListener("Reader:ZoomOut", this); + this._mm.removeMessageListener("Reader:ResetZoom", this); this._windowUnloaded = true; break; } @@ -348,6 +354,12 @@ AboutReader.prototype = { ReaderMode.leaveReaderMode(this._mm.docShell, this._win); }, + async _resetFontSize() { + await AsyncPrefs.reset("reader.font_size"); + let currentSize = Services.prefs.getIntPref("reader.font_size"); + this._setFontSize(currentSize); + }, + _setFontSize(newFontSize) { this._fontSize = newFontSize; let size = (10 + 2 * this._fontSize) + "px";