[Pkg-mozext-commits] [tabmixplus] 18/147: Replace remaining usages of bind(this) with arrow function

David Prévot taffit at moszumanska.debian.org
Sat Aug 5 15:27:32 UTC 2017


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 7987b8aa2d1ce89e12403539a8b2737828384810
Author: onemen <tabmix.onemen at gmail.com>
Date:   Sun Oct 30 13:26:44 2016 +0200

    Replace remaining usages of bind(this) with arrow function
---
 chrome/content/changecode.js           |  4 ++--
 chrome/content/minit/tabView.js        |  4 ++--
 chrome/content/session/session.js      | 20 ++++++++++----------
 chrome/content/session/sessionStore.js |  4 ++--
 chrome/content/tab/tab.js              | 12 +++++-------
 chrome/content/utils.js                |  7 ++++---
 modules/ContentClick.jsm               |  4 ++--
 modules/DynamicRules.jsm               |  6 +++---
 modules/MergeWindows.jsm               | 10 +++++-----
 modules/SingleWindowModeUtils.jsm      |  7 ++++---
 modules/TabGroupsMigrator.jsm          |  2 +-
 modules/log.jsm                        |  8 ++++----
 12 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/chrome/content/changecode.js b/chrome/content/changecode.js
index 25f9003..76c4c65 100644
--- a/chrome/content/changecode.js
+++ b/chrome/content/changecode.js
@@ -115,7 +115,7 @@ Tabmix.changeCode = function(aParent, afnName, aOptions) {
         return p1 + p2.replace(/\s/g, '_');
       };
 
-      let setDescriptor = function(type) {
+      let setDescriptor = type => {
         let fnType = "__lookup#ter__".replace("#", type);
         type = type.toLowerCase();
         let code = aCode && aCode[type + "ter"] ||
@@ -129,7 +129,7 @@ Tabmix.changeCode = function(aParent, afnName, aOptions) {
         } else if (typeof code != "undefined") {
           descriptor[type] = code;
         }
-      }.bind(this);
+      };
 
       setDescriptor("Get");
       setDescriptor("Set");
diff --git a/chrome/content/minit/tabView.js b/chrome/content/minit/tabView.js
index 4ca1436..2ad9a7d 100644
--- a/chrome/content/minit/tabView.js
+++ b/chrome/content/minit/tabView.js
@@ -81,14 +81,14 @@
 
     // add our function to the TabView initFrameCallbacks
     // we don't need our patch for the first run
-    var callback = function callback_TMP_TabView_patchTabviewFrame() {
+    var callback = () => {
       try {
         TabmixSessionManager._groupItemPushAway();
         this._patchTabviewFrame();
       } catch (ex) {
         Tabmix.assert(ex);
       }
-    }.bind(this);
+    };
 
     if (TabView._window)
       callback();
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index 00f2e89..f094806 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -284,11 +284,11 @@ TabmixSessionManager = {
       return;
     this._inited = true;
 
-    let initializeSM = function() {
+    let initializeSM = () => {
       this._init();
       if (this.notifyObservers)
         this._sendRestoreCompletedNotifications(false);
-    }.bind(this);
+    };
 
     TabmixSvc.ss.promiseInitialized
       .then(() => TMP_TabView.init())
@@ -1958,10 +1958,10 @@ TabmixSessionManager = {
       }
     }
     var count = nodes.length;
-    let restoreSession = function(event) {
+    let restoreSession = event => {
       this.restoreSession(event.originalTarget);
       event.stopPropagation();
-    }.bind(this);
+    };
 
     let backups = [TabmixSvc.getSMString("sm.tabview.backup.session"),
       TabmixSvc.getSMString("sm.tabview.backup.crashed")];
@@ -2167,9 +2167,9 @@ TabmixSessionManager = {
     var prevtoLast = this.containerEmpty(this.gSessionPath[2]); // previous to last
     var savedSession = this.containerEmpty(this._rdfRoot + '/windows'); // saved session
     var isAllEmpty = lastSession && prevtoLast && savedSession;
-    var callBack = function(aResult) {
+    var callBack = aResult => {
       this.afterCrashPromptCallBack(aResult);
-    }.bind(this);
+    };
     this.callBackData = {label: null, whatToLoad: "session"};
     this.waitForCallBack = true;
     if (!this.containerEmpty(this.gSessionPath[3])) { // if Crashed Session is not empty
@@ -2329,10 +2329,10 @@ TabmixSessionManager = {
         if (afterCrash)
           msg += "\n\n" + TabmixSvc.getSMString("sm.start.msg1");
         buttons = ["", TabmixSvc.setLabel("sm.button.continue")].join("\n");
-        let callBack = function(aResult) {
+        let callBack = aResult => {
           this.enableCrashRecovery(aResult);
           this._sendRestoreCompletedNotifications(true);
-        }.bind(this);
+        };
         this.waitForCallBack = true;
         this.promptService([Tabmix.BUTTON_CANCEL, Tabmix.HIDE_MENUANDTEXT, chkBoxState],
                            [title, msg, "", chkBoxLabel, buttons], window, callBack);
@@ -2389,9 +2389,9 @@ TabmixSessionManager = {
         msg += "\n\n" + TabmixSvc.getSMString("sm.afterCrash.msg1");
         buttons = [TabmixSvc.setLabel("sm.afterCrash.button0"),
           TabmixSvc.setLabel("sm.afterCrash.button1")].join("\n");
-        let callBack = function(aResult) {
+        let callBack = aResult => {
           this.onFirstWindowPromptCallBack(aResult);
-        }.bind(this);
+        };
         this.waitForCallBack = true;
         this.promptService([Tabmix.BUTTON_OK, Tabmix.SHOW_MENULIST, chkBoxState, Tabmix.SELECT_DEFAULT],
                            [title, msg, "", chkBoxLabel, buttons], window, callBack);
diff --git a/chrome/content/session/sessionStore.js b/chrome/content/session/sessionStore.js
index 7e7a7e0..b2158f5 100644
--- a/chrome/content/session/sessionStore.js
+++ b/chrome/content/session/sessionStore.js
@@ -688,10 +688,10 @@ var TabmixConvertSession = {
   selectFile: function cs_selectFile(aWindow) {
     const nsIFilePicker = Ci.nsIFilePicker;
     var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
-    var fpCallback = function fpCallback_done(aResult) {
+    var fpCallback = aResult => {
       if (aResult == nsIFilePicker.returnOK)
         this.convertFile(fp.fileURL.spec);
-    }.bind(this);
+    };
 
     fp.init(aWindow, this.getString("selectfile"), nsIFilePicker.modeOpen);
     fp.defaultString = "session.rdf";
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index abd50d5..55dd9a3 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -621,9 +621,7 @@ Tabmix.tabsUtils = {
     XPCOMUtils.defineLazyGetter(Tabmix, "rtl", () => {
       return window.getComputedStyle(tabbrowser, null).direction == "rtl";
     });
-    XPCOMUtils.defineLazyGetter(Tabmix, "ltr", () => {
-      return !Tabmix.rtl;
-    });
+    XPCOMUtils.defineLazyGetter(Tabmix, "ltr", () => !Tabmix.rtl);
 
     // don't set button to left side if it is not inside tab-content
     let button = document.getAnonymousElementByAttribute(tab, "anonid", "tmp-close-button") ||
@@ -1216,10 +1214,10 @@ gTMPprefObserver = {
     Tabmix.prefs.clearUserPref("setDefault");
     Tabmix.prefs.clearUserPref("PrefObserver.error");
 
-    let addObserver = function(pref, condition) {
+    let addObserver = (pref, condition) => {
       if (condition)
         this.OBSERVING.push(pref);
-    }.bind(this);
+    };
     addObserver("layout.css.devPixelsPerPx", TabmixSvc.australis);
     addObserver("browser.tabs.onTop", !Tabmix.isVersion(290));
     addObserver("browser.tabs.closeButtons", !Tabmix.isVersion(310));
@@ -1718,12 +1716,12 @@ gTMPprefObserver = {
     if (parseInt(marginStart) < parseInt(marginEnd))
       return;
 
-    let tabmix_setRule = function(aRule) {
+    let tabmix_setRule = aRule => {
       let newRule = aRule.replace(/%S/g, "tab-icon-image").replace("%PX", marginEnd);
       this.insertRule(newRule);
       newRule = aRule.replace(/%S/g, "tab-lock-icon").replace("%PX", marginEnd);
       this.insertRule(newRule);
-    }.bind(this);
+    };
     iconRule = '.tabbrowser-tabs%favhideclose%[closebuttons-side="left"][closebuttons="alltabs"] > ' +
                '.tabbrowser-tab:not([pinned]):not([protected])%faviconized% .%S ,' +
                '.tabbrowser-tabs%favhideclose%[closebuttons-side="left"][closebuttons="activetab"] > ' +
diff --git a/chrome/content/utils.js b/chrome/content/utils.js
index 607ae35..441a8af 100644
--- a/chrome/content/utils.js
+++ b/chrome/content/utils.js
@@ -248,10 +248,11 @@ var Tabmix = {
     XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
       "resource:///modules/RecentWindow.jsm");
 
-    window.addEventListener("unload", function tabmix_destroy() {
-      window.removeEventListener("unload", tabmix_destroy, false);
+    const destroy = () => {
+      window.removeEventListener("unload", destroy, false);
       this.destroy();
-    }.bind(this), false);
+    };
+    window.addEventListener("unload", destroy, false);
 
     var methods = ["changeCode", "setNewFunction", "nonStrictMode",
       "getObject", "log", "getCallerNameByIndex", "callerName",
diff --git a/modules/ContentClick.jsm b/modules/ContentClick.jsm
index 8813817..e50f576 100644
--- a/modules/ContentClick.jsm
+++ b/modules/ContentClick.jsm
@@ -342,10 +342,10 @@ ContentClickInternal = {
 
   whereToOpen: function TMP_whereToOpen(event, href, wrappedNode, wrappedOnClickNode) {
     let eventWhere;
-    let TMP_tabshifted = function TMP_tabshifted(aEvent) {
+    let TMP_tabshifted = aEvent => {
       var where = eventWhere || this._window.whereToOpenLink(aEvent);
       return where == "tabshifted" ? "tabshifted" : "tab";
-    }.bind(this);
+    };
 
   ///XXX check again how SubmitToTab work
     if (typeof (this._window.SubmitToTab) != 'undefined') {
diff --git a/modules/DynamicRules.jsm b/modules/DynamicRules.jsm
index 775a716..a054651 100644
--- a/modules/DynamicRules.jsm
+++ b/modules/DynamicRules.jsm
@@ -83,7 +83,7 @@ this.DynamicRules = {
   },
 
   registerMutationObserver: function(window) {
-    function tabsMutate(aMutations) {
+    const tabsMutate = aMutations => {
       for (let mutation of aMutations) {
         if (mutation.attributeName == "orient") {
           this.orient = mutation.target.orient;
@@ -91,8 +91,8 @@ this.DynamicRules = {
           return;
         }
       }
-    }
-    let Observer = new window.MutationObserver(tabsMutate.bind(this));
+    };
+    let Observer = new window.MutationObserver(tabsMutate);
     Observer.observe(window.gBrowser.tabContainer, {attributes: true});
     window.addEventListener("unload", function unload() {
       window.removeEventListener("unload", unload);
diff --git a/modules/MergeWindows.jsm b/modules/MergeWindows.jsm
index 2a76cbb..c9bd572 100644
--- a/modules/MergeWindows.jsm
+++ b/modules/MergeWindows.jsm
@@ -105,10 +105,10 @@ this.MergeWindows = {
     features += aPrivate ? ",private" : ",non-private";
     var newWindow = aWindows[0].openDialog("chrome://browser/content/browser.xul",
       "_blank", features, null);
-    let mergePopUps = function _mergePopUps() {
-      newWindow.removeEventListener("SSWindowStateReady", _mergePopUps, false);
+    let mergePopUps = () => {
+      newWindow.removeEventListener("SSWindowStateReady", mergePopUps, false);
       this.concatTabsAndMerge(newWindow, aWindows);
-    }.bind(this);
+    };
     newWindow.addEventListener("SSWindowStateReady", mergePopUps, false);
   },
 
@@ -247,7 +247,7 @@ this.MergeWindows = {
                        "private" in aOptions;
 
     let privateNotMatch = 0;
-    let isSuitableBrowserWindow = function(win) {
+    let isSuitableBrowserWindow = win => {
       let suitable = win != aWindow && !win.closed;
       if (!suitable || !checkPrivacy)
         return suitable;
@@ -256,7 +256,7 @@ this.MergeWindows = {
         return true;
       privateNotMatch++;
       return false;
-    }.bind(this);
+    };
 
     let windows = [], popUps = [];
     let isWINNT = Services.appinfo.OS == "WINNT";
diff --git a/modules/SingleWindowModeUtils.jsm b/modules/SingleWindowModeUtils.jsm
index b2ae143..be91c57 100644
--- a/modules/SingleWindowModeUtils.jsm
+++ b/modules/SingleWindowModeUtils.jsm
@@ -46,13 +46,14 @@ this.SingleWindowModeUtils = {
     if (!aWindow.arguments || aWindow.arguments.length === 0)
       return false;
 
-    aWindow.addEventListener("load", function _onLoad(aEvent) {
+    const onLoad = aEvent => {
       let window = aEvent.currentTarget;
-      window.removeEventListener("load", _onLoad, false);
+      window.removeEventListener("load", onLoad, false);
       let docElement = window.document.documentElement;
       if (docElement.getAttribute("windowtype") == "navigator:browser")
         this.onLoad(window);
-    }.bind(this), false);
+    };
+    aWindow.addEventListener("load", onLoad, false);
 
     aWindow.gTMPprefObserver.setLink_openPrefs();
 
diff --git a/modules/TabGroupsMigrator.jsm b/modules/TabGroupsMigrator.jsm
index 7623bab..d465eac 100644
--- a/modules/TabGroupsMigrator.jsm
+++ b/modules/TabGroupsMigrator.jsm
@@ -280,7 +280,7 @@ this.TabmixGroupsMigrator = {
   },
 
   getSessionsFolder: function(folder) {
-    return this.promiseItemId(folder).catch(this.createSessionsFolder.bind(this));
+    return this.promiseItemId(folder).catch(() => this.createSessionsFolder());
   },
 
   bookmarkAllGroupsFromState: function(groupData, guid, name) {
diff --git a/modules/log.jsm b/modules/log.jsm
index 9c9e09e..91cc4af 100644
--- a/modules/log.jsm
+++ b/modules/log.jsm
@@ -47,7 +47,7 @@ this.console = {
       if (typeof (aDelay) == "undefined")
         aDelay = 500;
 
-      let logMethod = function _logMethod() {
+      let logMethod = () => {
         let result = "", isObj = typeof aMethod == "object";
         if (typeof aMethod != "function") {
           result = isObj ? aMethod.obj[aMethod.name] :
@@ -55,16 +55,16 @@ this.console = {
           result = " = " + result.toString();
         }
         this.clog((isObj ? aMethod.fullName : aMethod) + result, this.caller);
-      }.bind(this);
+      };
 
       if (aDelay >= 0) {
         let timerID = gNextID++;
         let timer = Object.create(Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer));
-        timer.clear = function() {
+        timer.clear = () => {
           if (timerID in this._timers)
             delete this._timers[timerID];
           timer.cancel();
-        }.bind(this);
+        };
         if (aWindow) {
           aWindow.addEventListener("unload", function unload(event) {
             event.currentTarget.removeEventListener("unload", unload, false);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list