backout d57ca248d65f (Bug 1152743) that had unexpected string changes, a=rkent
authorR Kent James <rkent@caspia.com>
Thu, 08 Oct 2015 09:10:15 -0700
changeset 26396 aa4e7f50b9c8b8ae7c621c965e79d648c3bb7deb
parent 26395 d796372149d321b5374db1e395f473b6c74e4dc6
child 26397 362678f780fb30dbf48b9503a95bde888b75f68d
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent
bugs1152743
backs outd57ca248d65fdea87b671b6fd25c38eaee5d50e6
backout d57ca248d65f (Bug 1152743) that had unexpected string changes, a=rkent
mail/components/downloads/content/aboutDownloads.js
mail/components/downloads/content/aboutDownloads.xul
mail/locales/en-US/chrome/messenger/aboutDownloads.dtd
mail/themes/linux/mail/downloads/aboutDownloads.css
mail/themes/osx/mail/downloads/aboutDownloads.css
mail/themes/windows/mail/downloads/aboutDownloads.css
--- a/mail/components/downloads/content/aboutDownloads.js
+++ b/mail/components/downloads/content/aboutDownloads.js
@@ -5,17 +5,17 @@
   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 
 XPCOMUtils.defineLazyModuleGetter(this, "Downloads", "resource://gre/modules/Downloads.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "DownloadUtils", "resource://gre/modules/DownloadUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
 
 const DownloadsView = {
   init() {
     window.controllers.insertControllerAt(0, this);
@@ -53,17 +53,17 @@ const DownloadsView = {
   },
 
   onDownloadAdded(aDownload) {
     let isPurgedFromDisk = download => {
       if (!download.succeeded) {
         return false;
       }
       let targetFile = Cc["@mozilla.org/file/local;1"]
-                         .createInstance(Ci.nsIFile);
+                        .createInstance(Ci.nsIFile);
       targetFile.initWithPath(download.target.path);
       return !targetFile.exists();
     }
     if (isPurgedFromDisk(aDownload)) {
       Downloads.getList(Downloads.ALL)
                .then(list => list.remove(aDownload))
       return;
     }
@@ -93,87 +93,76 @@ const DownloadsView = {
       Cu.reportError("No DownloadItem found for download");
       return;
     }
 
     this.items.delete(aDownload);
     this.listElement.removeChild(item.element);
   },
 
-  onDownloadContextMenu() {
+  onDownloadContextMenu(aEvent) {
+    let element = this.listElement.selectedItem;
+    if (!element) {
+      return;
+    }
+
     this.updateCommands();
   },
 
   clearDownloads() {
     Downloads.getList(Downloads.ALL)
              .then(list => list.removeFinished())
              .then(null, Cu.reportError);
   },
 
-  searchDownloads() {
-    let searchString = document.getElementById("searchBox").value;
-    for (let i = 0; i < this.listElement.itemCount; i++) {
-      let downloadElem = this.listElement.getItemAtIndex(i);
-      downloadElem.collapsed =
-        !downloadElem.downloadItem.fileName.includes(searchString);
+  supportsCommand(aCommand) {
+    if (!(this.commands.some(command => command == aCommand)) &&
+        !(DownloadItem.prototype.supportsCommand(aCommand))) {
+      return false;
     }
-    this.listElement.clearSelection();
-  },
-
-  supportsCommand(aCommand) {
-    return (this.commands.includes(aCommand) ||
-            (DownloadItem.prototype.supportsCommand(aCommand)));
+    return true;
   },
 
   isCommandEnabled(aCommand) {
-    switch (aCommand) {
-      case "msgDownloadsCmd_clearDownloads":
-      case "msgDownloadsCmd_searchDownloads":
-        // We could disable these if there are no downloads in the list, but
-        // updating the commands when new items become available is tricky.
+    if (aCommand == "msgDownloadsCmd_clearDownloads") {
         return true;
     }
 
     let element = this.listElement.selectedItem;
     if (element) {
       return element.downloadItem.isCommandEnabled(aCommand);
     }
 
     return false;
   },
 
   doCommand(aCommand) {
-    switch (aCommand) {
-      case "msgDownloadsCmd_clearDownloads":
+    if (aCommand == "msgDownloadsCmd_clearDownloads") {
         this.clearDownloads();
         return;
-      case "msgDownloadsCmd_searchDownloads":
-        this.searchDownloads();
-        return;
     }
 
-    if (this.listElement.selectedCount == 0) {
+    if (this.listElement.selectedItems.length == 0) {
       return;
     }
 
-    for (let element of this.listElement.selectedItems) {
+    for (let [, element] in Iterator(this.listElement.selectedItems)) {
       element.downloadItem.doCommand(aCommand);
     }
   },
 
   onEvent() { },
 
   updateCommands() {
     this.commands.forEach(goUpdateCommand);
     DownloadItem.prototype.commands.forEach(goUpdateCommand);
   },
 
   commands: [
     "msgDownloadsCmd_clearDownloads",
-    "msgDownloadsCmd_searchDownloads"
   ]
 };
 
 function DownloadItem(aDownload) {
   this._download = aDownload;
   this._updateFromDownload();
 
   if (aDownload._unknownProperties && aDownload._unknownProperties.sender) {
@@ -265,17 +254,17 @@ DownloadItem.prototype = {
     Downloads.getList(Downloads.ALL)
              .then(list => list.remove(this.download))
              .then(() => this.download.finalize(true))
              .then(null, Cu.reportError);
   },
 
   show() {
     if (this.download.succeeded) {
-      let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
+      let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
       file.initWithPath(this._filePath);
       file.reveal();
     }
   },
 
   onDownloadChanged() {
     this._updateFromDownload();
     this.updateElement(this.element);
@@ -295,17 +284,17 @@ DownloadItem.prototype = {
       bytes = this.download.currentBytes;
     }
     return DownloadUtils.convertByteUnits(bytes).join("");
   },
 
   get startDate() { return this._startDate; },
 
   supportsCommand(aCommand) {
-    return this.commands.includes(aCommand);
+    return this.commands.some(command => command == aCommand);
   },
 
   isCommandEnabled(aCommand) {
     switch (aCommand) {
       case "msgDownloadsCmd_open":
       case "msgDownloadsCmd_show":
         return this.download.succeeded;
       case "msgDownloadsCmd_remove":
@@ -326,11 +315,11 @@ DownloadItem.prototype = {
         this.remove();
         break;
     }
   },
 
   commands: [
     "msgDownloadsCmd_remove",
     "msgDownloadsCmd_open",
-    "msgDownloadsCmd_show"
+    "msgDownloadsCmd_show",
   ]
 };
--- a/mail/components/downloads/content/aboutDownloads.xul
+++ b/mail/components/downloads/content/aboutDownloads.xul
@@ -18,64 +18,40 @@
         onload="DownloadsView.init();">
   <xhtml:link rel="shortcut icon"
               href="chrome://messenger/skin/downloads/download.svg"/>
   <script type="application/javascript"
           src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript"
           src="chrome://messenger/content/downloads/aboutDownloads.js"/>
 
+  <stack flex="1">
+    <richlistbox id="msgDownloadsRichListBox"
+                 flex="1"
+                 seltype="multiple"
+                 context="msgDownloadsContextMenu"
+                 oncontextmenu="DownloadsView.onDownloadContextMenu(event);"/>
+    <description id="msgDownloadsListEmptyDescription"
+                 value="&aboutDownloads.empty;"
+                 mousethrough="always"/>
+  </stack>
+
   <commandset id="msgDownloadCommands"
               commandupdater="true"
               events="focus,select,contextmenu">
     <command id="msgDownloadsCmd_open"
              oncommand="goDoCommand('msgDownloadsCmd_open')"/>
     <command id="msgDownloadsCmd_show"
              oncommand="goDoCommand('msgDownloadsCmd_show')"/>
     <command id="msgDownloadsCmd_remove"
              oncommand="goDoCommand('msgDownloadsCmd_remove')"/>
     <command id="msgDownloadsCmd_clearDownloads"
              oncommand="goDoCommand('msgDownloadsCmd_clearDownloads')"/>
-    <command id="msgDownloadsCmd_searchDownloads"
-             oncommand="goDoCommand('msgDownloadsCmd_searchDownloads')"/>
   </commandset>
 
-  <keyset id="downloadKeys">
-    <key keycode="&cmd.searchDownloads.key;" modifiers="accel"
-         oncommand="document.getElementById('searchBox').focus();"/>
-  </keyset>
-
-  <hbox align="center">
-    <button id="clearDownloads"
-            command="msgDownloadsCmd_clearDownloads"
-            label="&cmd.clearList.label;"
-            accesskey="&cmd.clearList.accesskey;"
-            tooltiptext="&cmd.clearList.tooltip;"/>
-
-    <spacer flex="1"/>
-    <textbox id="searchBox"
-             type="search"
-             command="msgDownloadsCmd_searchDownloads"
-             placeholder="&cmd.searchDownloads.label;"/>
-  </hbox>
-
-  <separator class="thin"/>
-
-  <stack flex="1">
-    <richlistbox id="msgDownloadsRichListBox"
-                 flex="1"
-                 seltype="multiple"
-                 context="msgDownloadsContextMenu"
-                 oncontextmenu="DownloadsView.onDownloadContextMenu();"/>
-    <description id="msgDownloadsListEmptyDescription"
-                 value="&aboutDownloads.empty;"
-                 mousethrough="always"/>
-  </stack>
-
-
   <menupopup id="msgDownloadsContextMenu">
     <menuitem command="msgDownloadsCmd_remove"
               class="msgDownloadRemoveFromHistoryMenuItem"
               label="&cmd.removeFromHistory.label;"
               accesskey="&cmd.removeFromHistory.accesskey;"/>
     <menuitem command="msgDownloadsCmd_open"
               label="&cmd.open.label;"
               accesskey="&cmd.open.accesskey;"/>
@@ -85,13 +61,12 @@
               label="&cmd.showMac.label;"
               accesskey="&cmd.showMac.accesskey;"
 #else
               label="&cmd.show.label;"
               accesskey="&cmd.show.accesskey;"
 #endif
               />
     <menuitem command="msgDownloadsCmd_clearDownloads"
-              label="&cmd.clearList.label;"
-              accesskey="&cmd.clearList.accesskey;"
-              tooltiptext="&cmd.clearList.tooltip;"/>
+              label="&cmd.clearDownloads.label;"
+              accesskey="&cmd.clearDownloads.accesskey;"/>
   </menupopup>
 </window>
--- a/mail/locales/en-US/chrome/messenger/aboutDownloads.dtd
+++ b/mail/locales/en-US/chrome/messenger/aboutDownloads.dtd
@@ -12,13 +12,10 @@
 <!ENTITY cmd.show.label                            "Open Containing Folder">
 <!ENTITY cmd.show.accesskey                        "F">
 <!ENTITY cmd.showMac.label                         "Show In Finder">
 <!ENTITY cmd.showMac.accesskey                     "F">
 <!ENTITY cmd.open.label                            "Open">
 <!ENTITY cmd.open.accesskey                        "O">
 <!ENTITY cmd.removeFromHistory.label               "Remove From History">
 <!ENTITY cmd.removeFromHistory.accesskey           "e">
-<!ENTITY cmd.clearList.label                       "Clear List">
-<!ENTITY cmd.clearList.accesskey                   "C">
-<!ENTITY cmd.clearList.tooltip                     "Remove all entries from the list of saved files, except ongoing downloads.">
-<!ENTITY cmd.searchDownloads.label                 "Search…">
-<!ENTITY cmd.searchDownloads.key                   "F">
+<!ENTITY cmd.clearDownloads.label                  "Clear Downloads">
+<!ENTITY cmd.clearDownloads.accesskey              "D">
--- a/mail/themes/linux/mail/downloads/aboutDownloads.css
+++ b/mail/themes/linux/mail/downloads/aboutDownloads.css
@@ -20,25 +20,16 @@
   /** The default listbox appearance comes with an unwanted margin. **/
   -moz-appearance: none;
   margin: 0;
 }
 
 #msgDownloadsRichListBox > richlistitem.download {
   height: 5em;
   padding: 5px 8px;
-  border-bottom: 1px solid #f1f1f1;
-}
-
-#clearDownloads {
-  margin-inline-start: 0;
-}
-
-#searchBox {
-  margin-inline-end: 0;
 }
 
 .fileTypeIcon {
   -moz-margin-end: 8px;
   /* Prevent flickering when changing states. */
   min-height: 32px;
   min-width: 32px;
 }
--- a/mail/themes/osx/mail/downloads/aboutDownloads.css
+++ b/mail/themes/osx/mail/downloads/aboutDownloads.css
@@ -20,25 +20,16 @@
   /** The default listbox appearance comes with an unwanted margin. **/
   -moz-appearance: none;
   margin: 0;
 }
 
 #msgDownloadsRichListBox > richlistitem.download {
   height: 6em;
   padding: 5px 8px;
-  border-bottom: 1px solid #f1f1f1;
-}
-
-#clearDownloads {
-  margin-inline-start: 0;
-}
-
-#searchBox {
-  margin-inline-end: 0;
 }
 
 .fileTypeIcon {
   -moz-margin-end: 8px;
   /* Ensure icons are displayed at 32px size even on Retina display */
   height: 32px;
   width: 32px;
 }
--- a/mail/themes/windows/mail/downloads/aboutDownloads.css
+++ b/mail/themes/windows/mail/downloads/aboutDownloads.css
@@ -19,25 +19,16 @@
 #msgDownloadsRichListBox {
   /** The default listbox appearance comes with an unwanted margin. **/
   -moz-appearance: none;
   margin: 0;
 }
 
 #msgDownloadsRichListBox > richlistitem.download {
   height: 6em;
-  border-bottom: 1px solid #f1f1f1;
-}
-
-#clearDownloads {
-  margin-inline-start: 0;
-}
-
-#searchBox {
-  margin-inline-end: 0;
 }
 
 @media (-moz-os-version: windows-xp) {
   #msgDownloadsRichListBox > richlistitem.download {
     padding: 5px 8px;
   }
 }