summaryrefslogtreecommitdiffstats
path: root/browser/modules
diff options
context:
space:
mode:
authorAscrod <32915892+Ascrod@users.noreply.github.com>2018-05-07 19:45:46 -0400
committerAscrod <32915892+Ascrod@users.noreply.github.com>2018-05-15 21:06:41 -0500
commitb70d884598e1e14b99190e1e5c349553ff59849b (patch)
treeb66af009469ec85d52bf2655afdf8e08dd881abb /browser/modules
parent000ac0cc833c415169ed7aa8c5e3493d0d4525fd (diff)
downloadUXP-b70d884598e1e14b99190e1e5c349553ff59849b.tar
UXP-b70d884598e1e14b99190e1e5c349553ff59849b.tar.gz
UXP-b70d884598e1e14b99190e1e5c349553ff59849b.tar.lz
UXP-b70d884598e1e14b99190e1e5c349553ff59849b.tar.xz
UXP-b70d884598e1e14b99190e1e5c349553ff59849b.zip
Initial updates for Reader View.
Diffstat (limited to 'browser/modules')
-rw-r--r--browser/modules/ReaderParent.jsm69
1 files changed, 19 insertions, 50 deletions
diff --git a/browser/modules/ReaderParent.jsm b/browser/modules/ReaderParent.jsm
index 6fcaada42..fcc0cc92b 100644
--- a/browser/modules/ReaderParent.jsm
+++ b/browser/modules/ReaderParent.jsm
@@ -11,31 +11,27 @@ this.EXPORTED_SYMBOLS = [ "ReaderParent" ];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode", "resource://gre/modules/ReaderMode.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "UITour", "resource:///modules/UITour.jsm");
const gStringBundle = Services.strings.createBundle("chrome://global/locale/aboutReader.properties");
var ReaderParent = {
- _readerModeInfoPanelOpen: false,
-
MESSAGES: [
"Reader:ArticleGet",
"Reader:FaviconRequest",
"Reader:UpdateReaderButton",
],
- init: function() {
+ init() {
let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
for (let msg of this.MESSAGES) {
mm.addMessageListener(msg, this);
}
},
- receiveMessage: function(message) {
+ receiveMessage(message) {
switch (message.name) {
case "Reader:ArticleGet":
this._getArticle(message.data.url, message.target).then((article) => {
@@ -60,7 +56,7 @@ var ReaderParent = {
message.target.messageManager.sendAsyncMessage("Reader:FaviconReturn", {
url: message.data.url,
faviconUrl: favicon.path.replace(/^favicon:/, "")
- })
+ });
},
function onRejection(reason) {
Cu.reportError("Error requesting favicon URL for about:reader content: " + reason);
@@ -80,7 +76,7 @@ var ReaderParent = {
}
},
- updateReaderButton: function(browser) {
+ updateReaderButton(browser) {
let win = browser.ownerGlobal;
if (browser != win.gBrowser.selectedBrowser) {
return;
@@ -88,7 +84,11 @@ var ReaderParent = {
let button = win.document.getElementById("reader-mode-button");
let command = win.document.getElementById("View:ReaderView");
- let key = win.document.getElementById("toggleReaderMode");
+ let key = win.document.getElementById("key_toggleReaderMode");
+ // aria-reader is not a real ARIA attribute. However, this will cause
+ // Gecko accessibility to expose the "reader" object attribute. We do this
+ // so that the reader state is easy for accessibility clients to access
+ // programmatically.
if (browser.currentURI.spec.startsWith("about:reader")) {
button.setAttribute("readeractive", true);
button.hidden = false;
@@ -98,6 +98,7 @@ var ReaderParent = {
command.setAttribute("hidden", false);
command.setAttribute("accesskey", gStringBundle.GetStringFromName("readerView.close.accesskey"));
key.setAttribute("disabled", false);
+ browser.setAttribute("aria-reader", "active");
} else {
button.removeAttribute("readeractive");
button.hidden = !browser.isArticle;
@@ -107,24 +108,15 @@ var ReaderParent = {
command.setAttribute("hidden", !browser.isArticle);
command.setAttribute("accesskey", gStringBundle.GetStringFromName("readerView.enter.accesskey"));
key.setAttribute("disabled", !browser.isArticle);
- }
-
- let currentUriHost = browser.currentURI && browser.currentURI.asciiHost;
- if (browser.isArticle &&
- !Services.prefs.getBoolPref("browser.reader.detectedFirstArticle") &&
- currentUriHost && !currentUriHost.endsWith("mozilla.org")) {
- this.showReaderModeInfoPanel(browser);
- Services.prefs.setBoolPref("browser.reader.detectedFirstArticle", true);
- this._readerModeInfoPanelOpen = true;
- } else if (this._readerModeInfoPanelOpen) {
- if (UITour.isInfoOnTarget(win, "readerMode-urlBar")) {
- UITour.hideInfo(win);
+ if (browser.isArticle) {
+ browser.setAttribute("aria-reader", "available");
+ } else {
+ browser.removeAttribute("aria-reader");
}
- this._readerModeInfoPanelOpen = false;
}
},
- forceShowReaderIcon: function(browser) {
+ forceShowReaderIcon(browser) {
browser.isArticle = true;
this.updateReaderButton(browser);
},
@@ -136,36 +128,13 @@ var ReaderParent = {
this.toggleReaderMode(event);
},
- toggleReaderMode: function(event) {
+ toggleReaderMode(event) {
let win = event.target.ownerGlobal;
let browser = win.gBrowser.selectedBrowser;
browser.messageManager.sendAsyncMessage("Reader:ToggleReaderMode");
},
/**
- * Shows an info panel from the UITour for Reader Mode.
- *
- * @param browser The <browser> that the tour should be started for.
- */
- showReaderModeInfoPanel(browser) {
- let win = browser.ownerGlobal;
- let targetPromise = UITour.getTarget(win, "readerMode-urlBar");
- targetPromise.then(target => {
- let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
- let icon = "chrome://browser/skin/";
- if (win.devicePixelRatio > 1) {
- icon += "reader-tour@2x.png";
- } else {
- icon += "reader-tour.png";
- }
- UITour.showInfo(win, target,
- browserBundle.GetStringFromName("readingList.promo.firstUse.readerView.title"),
- browserBundle.GetStringFromName("readingList.promo.firstUse.readerView.body"),
- icon);
- });
- },
-
- /**
* Gets an article for a given URL. This method will download and parse a document.
*
* @param url The article URL.
@@ -173,8 +142,8 @@ var ReaderParent = {
* @return {Promise}
* @resolves JS object representing the article, or null if no article is found.
*/
- _getArticle: Task.async(function* (url, browser) {
- return yield ReaderMode.downloadAndParseDocument(url).catch(e => {
+ async _getArticle(url, browser) {
+ return await ReaderMode.downloadAndParseDocument(url).catch(e => {
if (e && e.newURL) {
// Pass up the error so we can navigate the browser in question to the new URL:
throw e;
@@ -182,5 +151,5 @@ var ReaderParent = {
Cu.reportError("Error downloading and parsing document: " + e);
return null;
});
- })
+ }
};