From b12d0e2b397d637d7b2a90618b7fa3dc74ea2dd9 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Mon, 20 Apr 2015 00:16:23 +0900 Subject: [PATCH] Bug 1151475 - Part 1: Remove use of expression closure from mail/base/. r=mkmelin --- mail/base/content/folderPane.js | 16 +++++----- mail/base/content/glodaFacetBindings.xml | 2 +- mail/base/content/glodaFacetView.js | 4 +-- mail/base/content/glodaFacetVis.js | 31 +++++++++---------- mail/base/content/mailWidgets.xml | 8 ++--- mail/base/content/msgHdrViewOverlay.js | 2 +- mail/base/content/msgMail3PaneWindow.js | 6 ++-- mail/base/content/specialTabs.js | 2 +- .../base/modules/Windows8WindowFrameColor.jsm | 2 +- mail/base/modules/oauth.jsm | 8 ++--- 10 files changed, 40 insertions(+), 41 deletions(-) diff --git a/mail/base/content/folderPane.js b/mail/base/content/folderPane.js index c95958364d..ad7b9bea96 100644 --- a/mail/base/content/folderPane.js +++ b/mail/base/content/folderPane.js @@ -1134,7 +1134,7 @@ let gFolderTreeView = { let folderItem = new ftvItem(subFolders[0]); folderItem._level = 0; if (flag & nsMsgFolderFlags.Inbox) - folderItem.__defineGetter__("children", function() []); + folderItem.__defineGetter__("children", () => []); if (position == undefined) map.push(folderItem); else @@ -1183,7 +1183,7 @@ let gFolderTreeView = { // don't show sub-folders of the inbox, but I think Archives/Sent, etc // should have the sub-folders. if (flag & nsMsgFolderFlags.Inbox) - child.__defineGetter__("children", function() []); + child.__defineGetter__("children", () => []); // If we have consecutive children with the same server, then both // should display as folder - server. if (prevChild && (child._folder.server == prevChild._folder.server)) { @@ -1507,7 +1507,7 @@ let gFolderTreeView = { // There are no children in this view! for (let folder of map) { - folder.__defineGetter__("children", function() []); + folder.__defineGetter__("children", () => []); folder.addServerName = true; } sortFolderItems(map); @@ -1602,7 +1602,7 @@ let gFolderTreeView = { // There are no children in this view! for (let item of faves) { let name = item._folder.abbreviatedName.toLocaleLowerCase(); - item.__defineGetter__("children", function() []); + item.__defineGetter__("children", () => []); item.addServerName = dupeNames.has(name); } sortFolderItems(faves); @@ -1655,7 +1655,7 @@ let gFolderTreeView = { // And we want to display the account name to distinguish folders w/ // the same name. for (let folder of items) { - folder.__defineGetter__("children", function() []); + folder.__defineGetter__("children", () => []); folder.addServerName = true; } @@ -1755,7 +1755,7 @@ let gFolderTreeView = { get _allSmartFlags() { delete this._allSmartFlags; return this._allSmartFlags = this._flagNameList.reduce( - function (res, [flag,, isDeep,]) res | flag, 0); + (res, [flag,, isDeep,]) => res | flag, 0); }, /** @@ -1764,7 +1764,7 @@ let gFolderTreeView = { get _allShallowFlags() { delete this._allShallowFlags; return this._allShallowFlags = this._flagNameList.reduce( - function (res, [flag,, isDeep,]) isDeep ? res : (res | flag), 0); + (res, [flag,, isDeep,]) => isDeep ? res : (res | flag), 0); }, /** @@ -2023,7 +2023,7 @@ let gFolderTreeView = { newChild.useServerNameOnly = true; } if (aItem.flags & nsMsgFolderFlags.Inbox) - newChild.__defineGetter__("children", function() []); + newChild.__defineGetter__("children", () => []); if (parent) this._addChildToView(parent, parentIndex, newChild); else { diff --git a/mail/base/content/glodaFacetBindings.xml b/mail/base/content/glodaFacetBindings.xml index 44f388df85..eb5cfe4dfd 100644 --- a/mail/base/content/glodaFacetBindings.xml +++ b/mail/base/content/glodaFacetBindings.xml @@ -1655,7 +1655,7 @@ // Sort the matches by index, just to be sure. // They are probably already sorted, but if they aren't it could // mess things up at the next step. - matches.sort(function(a, b) a[0] - b[0]); + matches.sort((a, b) => a[0] - b[0]); // Convert the byte offsets and lengths into character indexes. let charCodeToByteCount = function(c) { diff --git a/mail/base/content/glodaFacetView.js b/mail/base/content/glodaFacetView.js index 8e7d5ced60..8f781dea9f 100644 --- a/mail/base/content/glodaFacetView.js +++ b/mail/base/content/glodaFacetView.js @@ -343,11 +343,11 @@ var FacetContext = { else scores = Gloda.scoreNounItems(items); let scoredItems = items.map(function(item, index) { return [scores[index], item]; }); - scoredItems.sort(function(a,b) b[0]-a[0]); + scoredItems.sort((a, b) => b[0]-a[0]); this._relevantSortedItems = scoredItems.map(scoredItem => scoredItem[1]); this._dateSortedItems = - this._relevantSortedItems.concat().sort(function(a,b) b.date-a.date); + this._relevantSortedItems.concat().sort((a, b) => b.date-a.date); }, initialBuild: function() { diff --git a/mail/base/content/glodaFacetVis.js b/mail/base/content/glodaFacetVis.js index 4219bf1690..a62a218622 100644 --- a/mail/base/content/glodaFacetVis.js +++ b/mail/base/content/glodaFacetVis.js @@ -265,13 +265,13 @@ DateFacetVis.prototype = { vis.add(pv.Bar) .data(bins) .bottom(0) - .height(function (d) Math.floor(d.items.length * binScale)) - .width(function() barWidth) - .left(function() isRTL ? null : (this.index * barPix)) - .right(function() isRTL ? (this.index * barPix) : null) + .height(d => Math.floor(d.items.length * binScale)) + .width(() => barWidth) + .left(function() { return isRTL ? null : (this.index * barPix); }) + .right(function() { return isRTL ? (this.index * barPix) : null; }) .fillStyle("#add2fb") - .event("mouseover", function(d) this.fillStyle("#3465a4")) - .event("mouseout", function(d) this.fillStyle("#add2fb")) + .event("mouseover", function(d) { return this.fillStyle("#3465a4"); }) + .event("mouseout", function(d) { return this.fillStyle("#add2fb"); }) .event("click", function(d) { dis.constraints = [[d.startDate, d.endDate]]; dis.binding.setAttribute("zoomedout", "false"); @@ -283,9 +283,9 @@ DateFacetVis.prototype = { this.hotBars = vis.add(pv.Bar) .data(this.emptyBins) .bottom(0) - .height(function (d) Math.floor(d * binScale)) - .width(function() barWidth) - .left(function() this.index * barPix) + .height(d => Math.floor(d * binScale)) + .width(() => barWidth) + .left(function() { return this.index * barPix; }) .fillStyle("#3465a4"); for (let labelTier of labelTiers) { @@ -293,13 +293,12 @@ DateFacetVis.prototype = { .data(labelTier.displayValues) .bottom(-totalAxisLabelHeight + labelTier.vertOffset) .height(labelTier.vertHeight) - .left(function(d) isRTL ? null : Math.floor(width * d[0])) - .right(function(d) isRTL ? Math.floor(width * d[0]) : null) - .width(function(d) - Math.floor(width * d[1]) - Math.floor(width * d[0]) - 1) + .left(d => isRTL ? null : Math.floor(width * d[0])) + .right(d => isRTL ? Math.floor(width * d[0]) : null) + .width(d => Math.floor(width * d[1]) - Math.floor(width * d[0]) - 1) .fillStyle("#dddddd") - .event("mouseover", function(d) this.fillStyle("#3465a4")) - .event("mouseout", function(d) this.fillStyle("#dddddd")) + .event("mouseover", function(d) { return this.fillStyle("#3465a4"); }) + .event("mouseout", function(d) { return this.fillStyle("#dddddd"); }) .event("click", function(d) { dis.constraints = [[d[3], d[4]]]; dis.binding.setAttribute("zoomedout", "false"); @@ -313,7 +312,7 @@ DateFacetVis.prototype = { .textAlign("center") .textBaseline("top") .textStyle("black") - .text(function(d) d[2]); + .text(d => d[2]); } } diff --git a/mail/base/content/mailWidgets.xml b/mail/base/content/mailWidgets.xml index 856b1ea8f7..98165bcc39 100644 --- a/mail/base/content/mailWidgets.xml +++ b/mail/base/content/mailWidgets.xml @@ -25,12 +25,12 @@ aChild.getAttribute("selected") == "true") .forEach(this.selectedItems.push, this.selectedItems); - children.filter(function(aChild) !aChild.hasAttribute("context")) - .forEach(function(aChild) aChild.setAttribute("context", - this.getAttribute("itemcontext")), this); + children.filter(aChild => !aChild.hasAttribute("context")) + .forEach(aChild => aChild.setAttribute("context", + this.getAttribute("itemcontext"))); this.sizes = {small: 16, large: 32, tile: 32}; this.messenger = Components.classes["@mozilla.org/messenger;1"] diff --git a/mail/base/content/msgHdrViewOverlay.js b/mail/base/content/msgHdrViewOverlay.js index 03ffbc34db..4309e2f98b 100644 --- a/mail/base/content/msgHdrViewOverlay.js +++ b/mail/base/content/msgHdrViewOverlay.js @@ -1173,7 +1173,7 @@ function HideMessageHeaderPane() function OutputNewsgroups(headerEntry, headerValue) { headerValue.split(",").forEach( - function(newsgroup) headerEntry.enclosingBox.addNewsgroupView(newsgroup)); + newsgroup => headerEntry.enclosingBox.addNewsgroupView(newsgroup)); headerEntry.enclosingBox.buildViews(); } diff --git a/mail/base/content/msgMail3PaneWindow.js b/mail/base/content/msgMail3PaneWindow.js index ac4d205717..ccfe8f6765 100644 --- a/mail/base/content/msgMail3PaneWindow.js +++ b/mail/base/content/msgMail3PaneWindow.js @@ -1797,9 +1797,9 @@ let TabsInTitlebar = { }, _update: function (aForce=false) { - function $(id) document.getElementById(id); - function rect(ele) ele.getBoundingClientRect(); - function verticalMargins(cstyle) parseFloat(cstyle.marginBottom) + parseFloat(cstyle.marginTop); + function $(id) { return document.getElementById(id); } + function rect(ele) { return ele.getBoundingClientRect(); } + function verticalMargins(cstyle) { return parseFloat(cstyle.marginBottom) + parseFloat(cstyle.marginTop); } if (!this._initialized || window.fullScreen) return; diff --git a/mail/base/content/specialTabs.js b/mail/base/content/specialTabs.js index 5e686950ca..04cb44e04c 100644 --- a/mail/base/content/specialTabs.js +++ b/mail/base/content/specialTabs.js @@ -985,7 +985,7 @@ var specialTabs = { } }, - shouldSwitchTo: function ({ chromePage: x }) + shouldSwitchTo: ({ chromePage: x }) => contentTabBaseType.shouldSwitchTo({ contentPage: x }), /** diff --git a/mail/base/modules/Windows8WindowFrameColor.jsm b/mail/base/modules/Windows8WindowFrameColor.jsm index 5f04962d8d..4fbe76df3e 100644 --- a/mail/base/modules/Windows8WindowFrameColor.jsm +++ b/mail/base/modules/Windows8WindowFrameColor.jsm @@ -31,7 +31,7 @@ const Windows8WindowFrameColor = { // Zero-pad the number just to make sure that it is 8 digits. customizationColorHex = ("00000000" + customizationColorHex).substr(-8); let customizationColorArray = customizationColorHex.match(/../g); - let [unused, fgR, fgG, fgB] = customizationColorArray.map(function(val) parseInt(val, 16)); + let [unused, fgR, fgG, fgB] = customizationColorArray.map(val => parseInt(val, 16)); let colorizationColorBalance = Registry.readRegKey(HKCU, dwmKey, "ColorizationColorBalance") || 78; // Window frame base color when Color Intensity is at 0, see bug 1004576. diff --git a/mail/base/modules/oauth.jsm b/mail/base/modules/oauth.jsm index 6078c5da3a..678f30ef60 100644 --- a/mail/base/modules/oauth.jsm +++ b/mail/base/modules/oauth.jsm @@ -112,7 +112,7 @@ OAuth.prototype = { if (queryIndex != -1) { urlSpec = url.slice(0, queryIndex); dataParams = url.slice(queryIndex + 1).split("&") - .map(function(p) p.split("=").map(percentEncode)); + .map(p => p.split("=").map(percentEncode)); } this.log.info("in sign and send url = " + url + "\nurlSpec = " + urlSpec); this.log.info("dataParams = " + dataParams); @@ -123,8 +123,8 @@ OAuth.prototype = { let signatureBase = aMethod + "&" + encodeURIComponent(urlSpec) + "&" + params.concat(dataParams) - .sort(function(a,b) (a[0] < b[0]) ? -1 : (a[0] > b[0]) ? 1 : 0) - .map(function(p) p.map(percentEncode).join("%3D")) + .sort((a, b) => (a[0] < b[0]) ? -1 : (a[0] > b[0]) ? 1 : 0) + .map(p => p.map(percentEncode).join("%3D")) .join("%26"); this.log.info("sig base = " + signatureBase); @@ -150,7 +150,7 @@ OAuth.prototype = { params.push(["oauth_signature", signature]); let authorization = - "OAuth " + params.map(function (p) p[0] + "=\"" + p[1] + "\"").join(", "); + "OAuth " + params.map(p => p[0] + "=\"" + p[1] + "\"").join(", "); let options = { headers: (aHeaders || []).concat([["Authorization", authorization]]), postData: aPOSTData,