Bug 1134940 - Modernize ReaderMode function declarations. r=nalexander
authorMatt Howell <mhowell@mozilla.com>
Wed, 23 Sep 2015 14:09:43 -0700
changeset 264283 5906d37343fa76675acba45ef38c686edfeb3815
parent 264197 19b55237cb368ce684bc8626cf9e8abe37ff1d0a
child 264284 5aeeb7979d4fbcc7c7efd93d7068b8fdd180643d
push id65590
push userkwierso@gmail.com
push dateFri, 25 Sep 2015 00:14:23 +0000
treeherdermozilla-inbound@0ab67cace54f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1134940
milestone44.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 1134940 - Modernize ReaderMode function declarations. r=nalexander
toolkit/components/reader/AboutReader.jsm
--- a/toolkit/components/reader/AboutReader.jsm
+++ b/toolkit/components/reader/AboutReader.jsm
@@ -211,17 +211,17 @@ AboutReader.prototype = {
       // Returns requested status of current ReadingList Sidebar.
       case "ReadingList:VisibilityStatus": {
         this._updateListButtonStyle(message.data.isOpen);
         break;
       }
     }
   },
 
-  handleEvent: function Reader_handleEvent(aEvent) {
+  handleEvent: function(aEvent) {
     if (!aEvent.isTrusted)
       return;
 
     switch (aEvent.type) {
       case "click":
         let target = aEvent.target;
         while (target && target.id != "reader-popup")
           target = target.parentNode;
@@ -250,30 +250,30 @@ AboutReader.prototype = {
         this._mm.removeMessageListener("Reader:Removed", this);
         this._mm.removeMessageListener("Sidebar:VisibilityChange", this);
         this._mm.removeMessageListener("ReadingList:VisibilityStatus", this);
         this._windowUnloaded = true;
         break;
     }
   },
 
-  _updateToggleButton: function Reader_updateToggleButton() {
+  _updateToggleButton: function() {
     let button = this._doc.getElementById("toggle-button");
 
     if (this._isReadingListItem == 1) {
       button.classList.add("on");
       button.setAttribute("title", gStrings.GetStringFromName("aboutReader.toolbar.removeFromReadingList"));
     } else {
       button.classList.remove("on");
       button.setAttribute("title", gStrings.GetStringFromName("aboutReader.toolbar.addToReadingList"));
     }
     this._updateFooter();
   },
 
-  _requestReadingListStatus: function Reader_requestReadingListStatus() {
+  _requestReadingListStatus: function() {
     let handleListStatusData = (message) => {
       this._mm.removeMessageListener("Reader:ListStatusData", handleListStatusData);
 
       let args = message.data;
       if (args.url == this._article.url) {
         if (this._isReadingListItem != args.inReadingList) {
           let isInitialStateChange = (this._isReadingListItem == -1);
           this._isReadingListItem = args.inReadingList;
@@ -291,42 +291,42 @@ AboutReader.prototype = {
         }
       }
     };
 
     this._mm.addMessageListener("Reader:ListStatusData", handleListStatusData);
     this._mm.sendAsyncMessage("Reader:ListStatusRequest", { url: this._article.url });
   },
 
-  _onReaderClose: function Reader_onToggle() {
+  _onReaderClose: function() {
     this._win.location.href = this._getOriginalUrl();
   },
 
-  _onReaderToggle: function Reader_onToggle(aMethod) {
+  _onReaderToggle: function(aMethod) {
     if (!this._article)
       return;
 
     if (this._isReadingListItem == 0) {
       this._mm.sendAsyncMessage("Reader:AddToList", { article: this._article });
       UITelemetry.addEvent("save.1", aMethod, null, "reader");
     } else {
       this._mm.sendAsyncMessage("Reader:RemoveFromList", { url: this._article.url });
       UITelemetry.addEvent("unsave.1", aMethod, null, "reader");
     }
   },
 
-  _onPocketToggle: function Reader_onPocketToggle(aMethod) {
+  _onPocketToggle: function(aMethod) {
     if (!this._article)
       return;
 
     this._mm.sendAsyncMessage("Reader:AddToPocket", { article: this._article });
     UITelemetry.addEvent("pocket.1", aMethod, null, "reader");
   },
 
-  _onShare: function Reader_onShare() {
+  _onShare: function() {
     if (!this._article)
       return;
 
     this._mm.sendAsyncMessage("Reader:Share", {
       url: this._article.url,
       title: this._article.title
     });
     UITelemetry.addEvent("share.1", "list", null);
@@ -371,17 +371,17 @@ AboutReader.prototype = {
       this._setButtonTip("list-button", "aboutReader.toolbar.closeReadingList");
     } else {
       classes.remove("on");
       // When off, action tip is "open".
       this._setButtonTip("list-button", "aboutReader.toolbar.openReadingList");
     }
   },
 
-  _setFontSize: function Reader_setFontSize(newFontSize) {
+  _setFontSize: function(newFontSize) {
     let containerClasses = this._doc.getElementById("container").classList;
 
     if (this._fontSize > 0)
       containerClasses.remove("font-size" + this._fontSize);
 
     this._fontSize = newFontSize;
     containerClasses.add("font-size" + this._fontSize);
 
@@ -447,27 +447,27 @@ AboutReader.prototype = {
       }
 
       currentSize--;
       updateControls();
       this._setFontSize(currentSize);
     }, true);
   },
 
-  _updateFooter: function RupdateFooter() {
+  _updateFooter: function() {
     let footer = this._doc.getElementById("reader-footer");
     if (!this._article || this._isReadingListItem == 0 ||
         footer.getAttribute("readinglist-enabled") != "true") {
       footer.style.display = "none";
       return;
     }
     footer.style.display = null;
   },
 
-  _handleDeviceLight: function Reader_handleDeviceLight(newLux) {
+  _handleDeviceLight: function(newLux) {
     // Desired size of the this._luxValues array.
     let luxValuesSize = 10;
     // Add new lux value at the front of the array.
     this._luxValues.unshift(newLux);
     // Add new lux value to this._totalLux for averaging later.
     this._totalLux += newLux;
 
     // Don't update when length of array is less than luxValuesSize except when it is 1.
@@ -483,45 +483,45 @@ AboutReader.prototype = {
 
     this._updateColorScheme(averageLuxValue);
     // Pop the oldest value off the array.
     let oldLux = this._luxValues.pop();
     // Subtract oldLux since it has been discarded from the array.
     this._totalLux -= oldLux;
   },
 
-  _handleVisibilityChange: function Reader_handleVisibilityChange() {
+  _handleVisibilityChange: function() {
     // ReadingList / Sidebar state might change while we're not the selected tab.
     if (this._doc.visibilityState === "visible") {
       this._updateListButton();
     }
 
     let colorScheme = Services.prefs.getCharPref("reader.color_scheme");
     if (colorScheme != "auto") {
       return;
     }
 
     // Turn off the ambient light sensor if the page is hidden
     this._enableAmbientLighting(!this._doc.hidden);
   },
 
   // Setup or teardown the ambient light tracking system.
-  _enableAmbientLighting: function Reader_enableAmbientLighting(enable) {
+  _enableAmbientLighting: function(enable) {
     if (enable) {
       this._win.addEventListener("devicelight", this, false);
       this._luxValues = [];
       this._totalLux = 0;
     } else {
       this._win.removeEventListener("devicelight", this, false);
       delete this._luxValues;
       delete this._totalLux;
     }
   },
 
-  _updateColorScheme: function Reader_updateColorScheme(luxValue) {
+  _updateColorScheme: function(luxValue) {
     // Upper bound value for "dark" color scheme beyond which it changes to "light".
     let upperBoundDark = 50;
     // Lower bound value for "light" color scheme beyond which it changes to "dark".
     let lowerBoundLight = 10;
     // Threshold for color scheme change.
     let colorChangeThreshold = 20;
 
     // Ignore changes that are within a certain threshold of previous lux values.
@@ -530,43 +530,43 @@ AboutReader.prototype = {
       return;
 
     if (luxValue < colorChangeThreshold)
       this._setColorScheme("dark");
     else
       this._setColorScheme("light");
   },
 
-  _setColorScheme: function Reader_setColorScheme(newColorScheme) {
+  _setColorScheme: function(newColorScheme) {
     // "auto" is not a real color scheme
     if (this._colorScheme === newColorScheme || newColorScheme === "auto")
       return;
 
     let bodyClasses = this._doc.body.classList;
 
     if (this._colorScheme)
       bodyClasses.remove(this._colorScheme);
 
     this._colorScheme = newColorScheme;
     bodyClasses.add(this._colorScheme);
   },
 
   // Pref values include "dark", "light", and "auto", which automatically switches
   // between light and dark color schemes based on the ambient light level.
-  _setColorSchemePref: function Reader_setColorSchemePref(colorSchemePref) {
+  _setColorSchemePref: function(colorSchemePref) {
     this._enableAmbientLighting(colorSchemePref === "auto");
     this._setColorScheme(colorSchemePref);
 
     this._mm.sendAsyncMessage("Reader:SetCharPref", {
       name: "reader.color_scheme",
       value: colorSchemePref
     });
   },
 
-  _setFontType: function Reader_setFontType(newFontType) {
+  _setFontType: function(newFontType) {
     if (this._fontType === newFontType)
       return;
 
     let bodyClasses = this._doc.body.classList;
 
     if (this._fontType)
       bodyClasses.remove(this._fontType);
 
@@ -574,21 +574,21 @@ AboutReader.prototype = {
     bodyClasses.add(this._fontType);
 
     this._mm.sendAsyncMessage("Reader:SetCharPref", {
       name: "reader.font_type",
       value: this._fontType
     });
   },
 
-  _getToolbarVisibility: function Reader_getToolbarVisibility() {
+  _getToolbarVisibility: function() {
     return this._toolbarElement.hasAttribute("visible");
   },
 
-  _setToolbarVisibility: function Reader_setToolbarVisibility(visible) {
+  _setToolbarVisibility: function(visible) {
     let dropdown = this._doc.getElementById("style-dropdown");
     dropdown.classList.remove("open");
 
     if (this._getToolbarVisibility() === visible) {
       return;
     }
 
     if (visible) {
@@ -599,21 +599,21 @@ AboutReader.prototype = {
     this._setSystemUIVisibility(visible);
 
     if (!visible) {
       this._mm.sendAsyncMessage("Reader:ToolbarHidden");
     }
     this._updateFooter();
   },
 
-  _toggleToolbarVisibility: function Reader_toggleToolbarVisibility() {
+  _toggleToolbarVisibility: function() {
     this._setToolbarVisibility(!this._getToolbarVisibility());
   },
 
-  _setSystemUIVisibility: function Reader_setSystemUIVisibility(visible) {
+  _setSystemUIVisibility: function(visible) {
     this._mm.sendAsyncMessage("Reader:SystemUIVisibility", { visible: visible });
   },
 
   _setupPocketButton: Task.async(function* () {
     let pocketEnabledPromise = new Promise((resolve, reject) => {
       let listener = (message) => {
         this._mm.removeMessageListener("Reader:PocketEnabledData", listener);
         resolve(message.data.enabled);
@@ -663,40 +663,40 @@ AboutReader.prototype = {
         this._mm.removeMessageListener("Reader:ArticleData", listener);
         resolve(message.data.article);
       };
       this._mm.addMessageListener("Reader:ArticleData", listener);
       this._mm.sendAsyncMessage("Reader:ArticleGet", { url: url });
     });
   },
 
-  _requestFavicon: function Reader_requestFavicon() {
+  _requestFavicon: function() {
     let handleFaviconReturn = (message) => {
       this._mm.removeMessageListener("Reader:FaviconReturn", handleFaviconReturn);
       this._loadFavicon(message.data.url, message.data.faviconUrl);
     };
 
     this._mm.addMessageListener("Reader:FaviconReturn", handleFaviconReturn);
     this._mm.sendAsyncMessage("Reader:FaviconRequest", { url: this._article.url });
   },
 
-  _loadFavicon: function Reader_loadFavicon(url, faviconUrl) {
+  _loadFavicon: function(url, faviconUrl) {
     if (this._article.url !== url)
       return;
 
     let doc = this._doc;
 
     let link = doc.createElement('link');
     link.rel = 'shortcut icon';
     link.href = faviconUrl;
 
     doc.getElementsByTagName('head')[0].appendChild(link);
   },
 
-  _updateImageMargins: function Reader_updateImageMargins() {
+  _updateImageMargins: function() {
     let windowWidth = this._win.innerWidth;
     let bodyWidth = this._doc.body.clientWidth;
 
     let setImageMargins = function(img) {
       // If the image is at least as wide as the window, make it fill edge-to-edge on mobile.
       if (img.naturalWidth >= windowWidth) {
         img.setAttribute("moz-reader-full-width", true);
       } else {
@@ -743,33 +743,33 @@ AboutReader.prototype = {
     this._messageElement.style.display = "block";
 
     this._doc.title = errorMessage;
 
     this._error = true;
   },
 
   // This function is the JS version of Java's StringUtils.stripCommonSubdomains.
-  _stripHost: function Reader_stripHost(host) {
+  _stripHost: function(host) {
     if (!host)
       return host;
 
     let start = 0;
 
     if (host.startsWith("www."))
       start = 4;
     else if (host.startsWith("m."))
       start = 2;
     else if (host.startsWith("mobile."))
       start = 7;
 
     return host.substring(start);
   },
 
-  _showContent: function Reader_showContent(article) {
+  _showContent: function(article) {
     this._messageElement.style.display = "none";
 
     this._article = article;
 
     this._domainElement.href = article.url;
     let articleUri = Services.io.newURI(article.url, null, null);
     this._domainElement.textContent = this._stripHost(articleUri.host);
     this._creditsElement.textContent = article.byline;
@@ -793,22 +793,22 @@ AboutReader.prototype = {
 
     this._showListIntro();
     this._requestFavicon();
     this._doc.body.classList.add("loaded");
 
     Services.obs.notifyObservers(null, "AboutReader:Ready", "");
   },
 
-  _hideContent: function Reader_hideContent() {
+  _hideContent: function() {
     this._headerElement.style.display = "none";
     this._contentElement.style.display = "none";
   },
 
-  _showProgressDelayed: function Reader_showProgressDelayed() {
+  _showProgressDelayed: function() {
     this._win.setTimeout(function() {
       // No need to show progress if the article has been loaded,
       // if the window has been unloaded, or if there was an error
       // trying to load the article.
       if (this._article || this._windowUnloaded || this._error) {
         return;
       }
 
@@ -823,17 +823,17 @@ AboutReader.prototype = {
   /**
    * Returns the original article URL for this about:reader view.
    */
   _getOriginalUrl: function(win) {
     let url = win ? win.location.href : this._win.location.href;
     return ReaderMode.getOriginalUrl(url) || url;
   },
 
-  _setupSegmentedButton: function Reader_setupSegmentedButton(id, options, initialValue, callback) {
+  _setupSegmentedButton: function(id, options, initialValue, callback) {
     let doc = this._doc;
     let segmentedButton = doc.getElementById(id);
 
     for (let i = 0; i < options.length; i++) {
       let option = options[i];
 
       let item = doc.createElement("button");
 
@@ -903,17 +903,17 @@ AboutReader.prototype = {
    * and dynamically as button state changes.
    * @param   Localizable string providing UI element usage tip.
    */
   _setButtonTip: function(id, titleEntity) {
     let button = this._doc.getElementById(id);
     button.setAttribute("title", gStrings.GetStringFromName(titleEntity));
   },
 
-  _setupStyleDropdown: function Reader_setupStyleDropdown() {
+  _setupStyleDropdown: function() {
     let doc = this._doc;
     let win = this._win;
 
     let dropdown = doc.getElementById("style-dropdown");
     let dropdownToggle = dropdown.querySelector(".dropdown-toggle");
     let dropdownPopup = dropdown.querySelector(".dropdown-popup");
 
     // Helper function used to position the popup on desktop,