Bug 1452624 - Part 1 - Replace the "filefield" binding with a regular textbox. r=jaws
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 17 Apr 2018 14:26:00 +0100
changeset 414991 c4603a9efe6dbca65b24ac653415fa661257844e
parent 414990 6747ccc87604bc807ea2c4d26be9ca32eb49c762
child 414992 d48d4c91b804fd4f5556e0731f502e0ab2c570aa
push id33885
push usertoros@mozilla.com
push dateSun, 22 Apr 2018 22:12:17 +0000
treeherdermozilla-central@378a8a64401f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1452624
milestone61.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 1452624 - Part 1 - Replace the "filefield" binding with a regular textbox. r=jaws MozReview-Commit-ID: jTKvyiRNdw
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/main.xul
browser/themes/linux/preferences/in-content/preferences.css
browser/themes/osx/preferences/in-content/preferences.css
browser/themes/shared/incontentprefs/preferences.inc.css
browser/themes/windows/preferences/in-content-new/preferences.css
browser/themes/windows/preferences/in-content/preferences.css
toolkit/content/preferencesBindings.js
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -532,18 +532,21 @@ var gMainPane = {
 
     setEventListener("filter", "command", gMainPane.filter);
     setEventListener("handlersView", "select",
       gMainPane.onSelectionChanged);
     setEventListener("typeColumn", "click", gMainPane.sort);
     setEventListener("actionColumn", "click", gMainPane.sort);
     setEventListener("chooseFolder", "command", gMainPane.chooseFolder);
     setEventListener("saveWhere", "command", gMainPane.handleSaveToCommand);
+    Preferences.get("browser.download.folderList").on("change",
+      gMainPane.displayDownloadDirPref.bind(gMainPane));
     Preferences.get("browser.download.dir").on("change",
       gMainPane.displayDownloadDirPref.bind(gMainPane));
+    gMainPane.displayDownloadDirPref();
 
     // Listen for window unload so we can remove our preference observers.
     window.addEventListener("unload", this);
 
     // Figure out how we should be sorting the list.  We persist sort settings
     // across sessions, so we can't assume the default sort column/direction.
     // XXX should we be using the XUL sort service instead?
     if (document.getElementById("actionColumn").hasAttribute("sortDirection")) {
@@ -2468,37 +2471,28 @@ var gMainPane = {
       // displaying blank downloadFolder label and icon on load of preferences UI
       // Set folderIndex to 1 if currentDirPref is unspecified
       folderIndex = currentDirPref.value ? await this._folderToIndex(currentDirPref.value) : 1;
     }
 
     // Display a 'pretty' label or the path in the UI.
     if (folderIndex == 2) {
       // Custom path selected and is configured
-      downloadFolder.label = this._getDisplayNameOfFile(currentDirPref.value);
+      downloadFolder.value = currentDirPref.value ? currentDirPref.value.path : "";
       iconUrlSpec = fph.getURLSpecFromFile(currentDirPref.value);
     } else if (folderIndex == 1) {
       // 'Downloads'
-      downloadFolder.label = bundlePreferences.getString("downloadsFolderName");
+      downloadFolder.value = bundlePreferences.getString("downloadsFolderName");
       iconUrlSpec = fph.getURLSpecFromFile(await this._indexToFolder(1));
     } else {
       // 'Desktop'
-      downloadFolder.label = bundlePreferences.getString("desktopFolderName");
+      downloadFolder.value = bundlePreferences.getString("desktopFolderName");
       iconUrlSpec = fph.getURLSpecFromFile(await this._getDownloadsFolder("Desktop"));
     }
-    downloadFolder.image = "moz-icon://" + iconUrlSpec + "?size=16";
-  },
-
-  /**
-   * Returns the textual path of a folder in readable form.
-   */
-  _getDisplayNameOfFile(aFolder) {
-    // TODO: would like to add support for 'Downloads on Macintosh HD'
-    //       for OS X users.
-    return aFolder ? aFolder.path : "";
+    downloadFolder.style.backgroundImage = "url(moz-icon://" + iconUrlSpec + "?size=16)";
   },
 
   /**
    * Returns the Downloads folder.  If aFolder is "Desktop", then the Downloads
    * folder returned is the desktop folder; otherwise, it is a folder whose name
    * indicates that it is a download folder and whose path is as determined by
    * the XPCOM directory service via the download manager's attribute
    * defaultDownloadsDirectory.
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -348,38 +348,34 @@
 
 <!--Downloads-->
 <groupbox id="downloadsGroup" data-category="paneGeneral" hidden="true">
   <caption><label data-l10n-id="download-header"/></caption>
 
   <radiogroup id="saveWhere"
               preference="browser.download.useDownloadDir"
               onsyncfrompreference="return gMainPane.readUseDownloadDir();">
-    <hbox id="saveToRow">
+    <hbox>
       <radio id="saveTo"
-            value="true"
-            data-l10n-id="download-save-to"
-            aria-labelledby="saveTo downloadFolder"/>
-      <filefield id="downloadFolder"
-                flex="1"
-                preference="browser.download.folderList"
-                preference-editable="true"
-                aria-labelledby="saveTo"
-                onsyncfrompreference="return gMainPane.displayDownloadDirPref();"/>
+             value="true"
+             data-l10n-id="download-save-to"/>
+      <textbox id="downloadFolder" flex="1"
+               readonly="true"
+               aria-labelledby="saveTo"/>
       <button id="chooseFolder"
-              data-l10n-id="download-choose-folder"
-      />
+              class="accessory-button"
+              data-l10n-id="download-choose-folder"/>
     </hbox>
     <!-- Additional radio button added to support CloudStorage - Bug 1357171 -->
     <radio id="saveToCloud"
-          value="true"
-          hidden="true"/>
+           value="true"
+           hidden="true"/>
     <radio id="alwaysAsk"
-          value="false"
-          data-l10n-id="download-always-ask-where"/>
+           value="false"
+           data-l10n-id="download-always-ask-where"/>
   </radiogroup>
 </groupbox>
 
 <groupbox id="applicationsGroup" data-category="paneGeneral" hidden="true">
   <caption><label data-l10n-id="applications-header"/></caption>
   <description data-l10n-id="applications-description"/>
   <textbox id="filter" flex="1"
            type="search"
--- a/browser/themes/linux/preferences/in-content/preferences.css
+++ b/browser/themes/linux/preferences/in-content/preferences.css
@@ -12,12 +12,8 @@
   /* override the Linux only toolkit rule */
   -moz-appearance: none;
 }
 
 .actionsMenu > .menulist-label-box > .menulist-icon {
   margin-inline-start: 1px;
   margin-inline-end: 8px;
 }
-
-filefield + button {
-  margin-inline-start: -4px;
-}
--- a/browser/themes/osx/preferences/in-content/preferences.css
+++ b/browser/themes/osx/preferences/in-content/preferences.css
@@ -9,25 +9,15 @@
 }
 
 .actionsMenu > .menulist-label-box > .menulist-icon {
   margin-top: 2px;
   margin-inline-start: 2px;
   margin-inline-end: 8px !important;
 }
 
-#downloadFolder > .fileFieldContentBox {
-  padding-inline-start: 3px;
-}
-
-filefield + button {
-  margin-inline-start: -8px;
-  margin-top: 4px;
-  margin-bottom: 4px;
-}
-
 #popupPolicyRow {
   /* Override styles from
      browser/themes/osx/preferences/preferences.css */
   margin-bottom: 0 !important;
   padding-bottom: 0 !important;
   border-bottom: none;
 }
--- a/browser/themes/shared/incontentprefs/preferences.inc.css
+++ b/browser/themes/shared/incontentprefs/preferences.inc.css
@@ -210,16 +210,22 @@ button > hbox > label {
 }
 
 #getStarted {
   font-size: 90%;
 }
 
 #downloadFolder {
   margin-inline-start: 0;
+  padding-inline-start: 30px;
+  background: center left 8px / 16px no-repeat;
+}
+
+#downloadFolder:-moz-locale-dir(rtl) {
+  background-position-x: right 8px;
 }
 
 #updateApp > .groupbox-body > label {
   margin: 0 0 4px;
 }
 
 #updateApp > .groupbox-body > description {
   margin: 0;
--- a/browser/themes/windows/preferences/in-content-new/preferences.css
+++ b/browser/themes/windows/preferences/in-content-new/preferences.css
@@ -3,14 +3,13 @@
    - You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 %include ../../../shared/incontentprefs/preferences.inc.css
 
 .actionsMenu > .menulist-label-box > .menulist-icon {
   margin-inline-end: 9px;
 }
 
-textbox + button,
-filefield + button {
+textbox + button {
   margin-inline-start: -4px;
   margin-top: 4px;
   margin-bottom: 4px;
 }
--- a/browser/themes/windows/preferences/in-content/preferences.css
+++ b/browser/themes/windows/preferences/in-content/preferences.css
@@ -6,14 +6,8 @@
 
 :root > * {
   font-size: 1.25em;
 }
 
 .actionsMenu > .menulist-label-box > .menulist-icon {
   margin-inline-end: 9px;
 }
-
-filefield + button {
-  margin-inline-start: -4px;
-  margin-top: 4px;
-  margin-bottom: 4px;
-}
--- a/toolkit/content/preferencesBindings.js
+++ b/toolkit/content/preferencesBindings.js
@@ -441,17 +441,17 @@ const Preferences = window.Preferences =
       case "colorpicker":
       case "radiogroup":
       case "textbox":
       case "listitem":
       case "listbox":
       case "menulist":
         return true;
       }
-      return aElement.getAttribute("preference-editable") == "true";
+      return false;
     }
 
     updateElements() {
       if (!this.id)
         return;
 
       // This "change" event handler tracks changes made to preferences by
       // sources other than the user in this window.