From 90d9557cc375f9a8bafdeac6d042b359769468eb Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Mon, 20 Feb 2017 12:58:22 +0900 Subject: [PATCH] Bug 1340947 - Part 2: Use for-of when iterating over fixIterator in mail/. r=jorgk --HG-- extra : rebase_source : 921b3e605b51d957e4a9830df9069fd2fea93570 --- mail/base/content/FilterListDialog.js | 2 +- mail/base/content/editContactOverlay.js | 2 +- mail/base/content/folderDisplay.js | 2 +- mail/base/content/folderPane.js | 14 +++++++------- mail/base/content/mailCommands.js | 4 ++-- mail/base/modules/MailUtils.js | 6 +++--- mail/base/modules/displayNameUtils.js | 4 ++-- mail/base/modules/searchSpec.js | 14 +++++++------- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/mail/base/content/FilterListDialog.js b/mail/base/content/FilterListDialog.js index e5be9fc1ac..4abffd5347 100644 --- a/mail/base/content/FilterListDialog.js +++ b/mail/base/content/FilterListDialog.js @@ -849,7 +849,7 @@ function getServerThatCanHaveFilters() // If it cannot, check all accounts to find a server // that can have filters. let allServers = MailServices.accounts.allServers; - for (let currentServer in fixIterator(allServers, + for (let currentServer of fixIterator(allServers, Components.interfaces.nsIMsgIncomingServer)) { if (currentServer.canHaveFilters) diff --git a/mail/base/content/editContactOverlay.js b/mail/base/content/editContactOverlay.js index 9124108b50..6e14791929 100644 --- a/mail/base/content/editContactOverlay.js +++ b/mail/base/content/editContactOverlay.js @@ -146,7 +146,7 @@ var editContactInlineUI = { !list.isMailList) continue; - for (let card in fixIterator(list.addressLists)) { + for (let card of fixIterator(list.addressLists)) { if (card instanceof Components.interfaces.nsIAbCard && card.primaryEmail == this._cardDetails.card.primaryEmail) { inMailList = true; diff --git a/mail/base/content/folderDisplay.js b/mail/base/content/folderDisplay.js index ab2e4804ef..e03651b78b 100644 --- a/mail/base/content/folderDisplay.js +++ b/mail/base/content/folderDisplay.js @@ -2163,7 +2163,7 @@ FolderDisplayWidget.prototype = { const nsIMsgIdentity = Components.interfaces.nsIMsgIdentity; let allEnabled = undefined; - for (let identity in fixIterator(serverIdentities, nsIMsgIdentity)) { + for (let identity of fixIterator(serverIdentities, nsIMsgIdentity)) { if (allEnabled === undefined) { allEnabled = identity.archiveEnabled; } diff --git a/mail/base/content/folderPane.js b/mail/base/content/folderPane.js index 6bc6238bc5..08abaa4d33 100644 --- a/mail/base/content/folderPane.js +++ b/mail/base/content/folderPane.js @@ -1109,7 +1109,7 @@ var gFolderTreeView = { _subFoldersWithStringProperty: function ftv_subFoldersWithStringProperty(folder, folders, aFolderName, deep) { - for (let child in fixIterator(folder.subFolders, Components.interfaces.nsIMsgFolder)) { + for (let child of fixIterator(folder.subFolders, Components.interfaces.nsIMsgFolder)) { // if the folder selection is based on a string propery, use that if (aFolderName == getSmartFolderName(child)) { folders.push(child); @@ -1139,7 +1139,7 @@ var gFolderTreeView = { for (let acct of accounts) { let foldersWithFlag = acct.incomingServer.rootFolder.getFoldersWithFlags(aFolderFlag); if (foldersWithFlag.length > 0) { - for (let folderWithFlag in fixIterator(foldersWithFlag, + for (let folderWithFlag of fixIterator(foldersWithFlag, Components.interfaces.nsIMsgFolder)) { folders.push(folderWithFlag); // Add sub-folders of Sent and Archive to the result. @@ -2011,7 +2011,7 @@ var gFolderTreeView = { const Ci = Components.interfaces; let folders = []; - for (let server in fixIterator(MailServices.accounts.allServers, Ci.nsIMsgIncomingServer)) { + for (let server of fixIterator(MailServices.accounts.allServers, Ci.nsIMsgIncomingServer)) { // Skip deferred accounts if (server instanceof Ci.nsIPop3IncomingServer && server.deferredToAccount) @@ -2032,7 +2032,7 @@ var gFolderTreeView = { * @param folders the array to add the folders to. */ addSubFolders : function ftv_addSubFolders (folder, folders) { - for (let f in fixIterator(folder.subFolders, Components.interfaces.nsIMsgFolder)) { + for (let f of fixIterator(folder.subFolders, Components.interfaces.nsIMsgFolder)) { folders.push(f); this.addSubFolders(f, folders); } @@ -2416,7 +2416,7 @@ ftvItem.prototype = { this._children = []; // Out of all children, only keep those that match the _folderFilter // and those that contain such children. - for (let folder in iter) { + for (let folder of iter) { if (!this._folderFilter || this._folderFilter(folder)) { this._children.push(new ftvItem(folder, this._folderFilter)); } @@ -2826,13 +2826,13 @@ ftv_SmartItem.prototype = { if (!this._children) { this._children = []; let iter = fixIterator(this._folder.subFolders, Ci.nsIMsgFolder); - for (let folder in iter) { + for (let folder of iter) { if (!smartMode.isSmartFolder(folder)) { this._children.push(new ftv_SmartItem(folder)); } else if (folder.flags & nsMsgFolderFlags.Inbox) { let subIter = fixIterator(folder.subFolders, Ci.nsIMsgFolder); - for (let subfolder in subIter) { + for (let subfolder of subIter) { if (!smartMode.isSmartFolder(subfolder)) this._children.push(new ftv_SmartItem(subfolder)); } diff --git a/mail/base/content/mailCommands.js b/mail/base/content/mailCommands.js index 61e3b31dd4..06f915b98a 100644 --- a/mail/base/content/mailCommands.js +++ b/mail/base/content/mailCommands.js @@ -29,7 +29,7 @@ function getBestIdentity(identities, optionalHint, useDefault = false) let hints = optionalHint.toLowerCase().split(","); for (let i = 0 ; i < hints.length; i++) { - for (let identity in fixIterator(identities, + for (let identity of fixIterator(identities, Components.interfaces.nsIMsgIdentity)) { if (!identity.email) continue; @@ -87,7 +87,7 @@ function getIdentityForHeader(hdr, type) deliveredTos.reverse(); for (let i = 0; i < deliveredTos.length; i++) { - for (let identity in fixIterator(accountManager.allIdentities, + for (let identity of fixIterator(accountManager.allIdentities, Components.interfaces.nsIMsgIdentity)) { if (!identity.email) continue; diff --git a/mail/base/modules/MailUtils.js b/mail/base/modules/MailUtils.js index b979a07ad7..a0c24cd36e 100644 --- a/mail/base/modules/MailUtils.js +++ b/mail/base/modules/MailUtils.js @@ -29,7 +29,7 @@ var MailUtils = */ discoverFolders: function MailUtils_discoverFolders() { let servers = MailServices.accounts.allServers; - for (let server in fixIterator(servers, Ci.nsIMsgIncomingServer)) { + for (let server of fixIterator(servers, Ci.nsIMsgIncomingServer)) { // Bug 466311 Sometimes this can throw file not found, we're unsure // why, but catch it and log the fact. try { @@ -58,7 +58,7 @@ var MailUtils = function MailUtils_getFolderForFileInProfile(aFile) { let folders = MailServices.accounts.allFolders; - for (let folder in fixIterator(folders, Ci.nsIMsgFolder)) { + for (let folder of fixIterator(folders, Ci.nsIMsgFolder)) { if (folder.filePath.equals(aFile)) return folder; } @@ -352,7 +352,7 @@ var MailUtils = // - worker function function* folder_string_setter_worker() { - for (let folder in fixIterator(allFolders, Ci.nsIMsgFolder)) { + for (let folder of fixIterator(allFolders, Ci.nsIMsgFolder)) { // set the property; this may open the database... let value = (typeof aPropertyValue == "function" ? aPropertyValue(folder) : aPropertyValue); diff --git a/mail/base/modules/displayNameUtils.js b/mail/base/modules/displayNameUtils.js index 74e886cea4..c40d208930 100644 --- a/mail/base/modules/displayNameUtils.js +++ b/mail/base/modules/displayNameUtils.js @@ -29,7 +29,7 @@ function GetCardForEmail(aEmailAddress) { // the cardForEmailAddress function. // Future expansion could be to domain matches let books = MailServices.ab.directories; - for (let book in fixIterator(books, Components.interfaces.nsIAbDirectory)) { + for (let book of fixIterator(books, Components.interfaces.nsIAbDirectory)) { try { let card = book.cardForEmailAddress(aEmailAddress); if (card) @@ -43,7 +43,7 @@ function GetCardForEmail(aEmailAddress) { function _getIdentityForAddress(aEmailAddress) { let emailAddress = aEmailAddress.toLowerCase(); - for (let identity in fixIterator(MailServices.accounts.allIdentities, + for (let identity of fixIterator(MailServices.accounts.allIdentities, Components.interfaces.nsIMsgIdentity)) { if (!identity.email) continue; diff --git a/mail/base/modules/searchSpec.js b/mail/base/modules/searchSpec.js index 7ce873113d..edd9000fbc 100644 --- a/mail/base/modules/searchSpec.js +++ b/mail/base/modules/searchSpec.js @@ -160,7 +160,7 @@ SearchSpec.prototype = { aCloneTerms){ let iTerm = 0, term; let outTerms = aCloneTerms ? [] : aTerms; - for (term in fixIterator(aTerms, Ci.nsIMsgSearchTerm)) { + for (term of fixIterator(aTerms, Ci.nsIMsgSearchTerm)) { if (aCloneTerms) { let cloneTerm = this.session.createTerm(); cloneTerm.value = term.value; @@ -207,7 +207,7 @@ SearchSpec.prototype = { let term; let outTerms = aCloneTerms ? [] : aTerms; let inGroup = false; - for (term in fixIterator(aTerms, Components.interfaces.nsIMsgSearchTerm)) { + for (term of fixIterator(aTerms, Components.interfaces.nsIMsgSearchTerm)) { // If we're in a group, all that is forbidden is the creation of new // groups. if (inGroup) { @@ -369,7 +369,7 @@ SearchSpec.prototype = { // -- apply terms if (this._virtualFolderTerms) { - for (let term in fixIterator(this._virtualFolderTerms, + for (let term of fixIterator(this._virtualFolderTerms, nsIMsgSearchTerm)) { if (term.attrib == nsMsgSearchAttrib.Body) haveBodyTerm = true; @@ -378,7 +378,7 @@ SearchSpec.prototype = { } if (this._viewTerms) { - for (let term in fixIterator(this._viewTerms, + for (let term of fixIterator(this._viewTerms, nsIMsgSearchTerm)) { if (term.attrib == nsMsgSearchAttrib.Body) haveBodyTerm = true; @@ -387,7 +387,7 @@ SearchSpec.prototype = { } if (this._userTerms) { - for (let term in fixIterator(this._userTerms, + for (let term of fixIterator(this._userTerms, nsIMsgSearchTerm)) { if (term.attrib == nsMsgSearchAttrib.Body) haveBodyTerm = true; @@ -434,7 +434,7 @@ SearchSpec.prototype = { let offlineValidityTable = validityManager.getTable(offlineScope); let offlineAvailable = true; let onlineAvailable = true; - for (let term in fixIterator(session.searchTerms, + for (let term of fixIterator(session.searchTerms, nsIMsgSearchTerm)) { if (!term.matchAll) { // for custom terms, we need to getAvailable from the custom term @@ -475,7 +475,7 @@ SearchSpec.prototype = { let s = ''; - for (let term in fixIterator(aSearchTerms, nsIMsgSearchTerm)) { + for (let term of fixIterator(aSearchTerms, nsIMsgSearchTerm)) { s += ' ' + term.termAsString + '\n'; }