Bug 1425541: Expose reader mode state on the browser accessible using a "reader" object attribute. r=eeejay,Gijs
☠☠ backed out by 10400d85b711 ☠ ☠
authorJames Teh <jteh@mozilla.com>
Fri, 15 Dec 2017 14:47:01 -0600
changeset 453645 196006c746bde8b894252ec1310a4b5124e04c14
parent 453644 e140335f123762045a9a3bfcd31e83736f968150
child 453646 a0cf39ae0b3d4db3bf77e0b669258e7393288079
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay, Gijs
bugs1425541
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1425541: Expose reader mode state on the browser accessible using a "reader" object attribute. r=eeejay,Gijs This makes it easy for accessibility clients to retrieve the reader mode state programmatically. There are three possibilities: 1. Reader mode is available for the current page (reader:available). 2. Reader mode is being used now (reader:active). 3. Reader is not available (the reader attribute is not present). We do this by setting/removing the aria-reader attribute on the node. This is not a real ARIA attribute, but it causes Gecko to expose it as an object attribute. MozReview-Commit-ID: B38G3AYyBnS
browser/modules/ReaderParent.jsm
--- a/browser/modules/ReaderParent.jsm
+++ b/browser/modules/ReaderParent.jsm
@@ -53,34 +53,44 @@ var ReaderParent = {
     let win = browser.ownerGlobal;
     if (browser != win.gBrowser.selectedBrowser) {
       return;
     }
 
     let button = win.document.getElementById("reader-mode-button");
     let command = win.document.getElementById("View:ReaderView");
     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;
       let closeText = gStringBundle.GetStringFromName("readerView.close");
       button.setAttribute("tooltiptext", closeText);
       command.setAttribute("label", closeText);
       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;
       let enterText = gStringBundle.GetStringFromName("readerView.enter");
       button.setAttribute("tooltiptext", enterText);
       command.setAttribute("label", enterText);
       command.setAttribute("hidden", !browser.isArticle);
       command.setAttribute("accesskey", gStringBundle.GetStringFromName("readerView.enter.accesskey"));
       key.setAttribute("disabled", !browser.isArticle);
+      if (browser.isArticle) {
+        browser.setAttribute("aria-reader", "available");
+      } else {
+        browser.removeAttribute("aria-reader");
+      }
     }
   },
 
   forceShowReaderIcon(browser) {
     browser.isArticle = true;
     this.updateReaderButton(browser);
   },