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
This commit is contained in:
berkay.barlas 2019-03-27 10:56:03 +00:00
Родитель 6316f05eaf
Коммит 6ad3d5bf36
2 изменённых файлов: 25 добавлений и 9 удалений

Просмотреть файл

@ -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;
}
},
/**

Просмотреть файл

@ -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";