Bug 1160864 - The description field is not shown when editing a read-only container child in the Library. r=mano
authorMarco Bonardo <mbonardo@mozilla.com>
Fri, 08 May 2015 12:43:29 +0200
changeset 242964 1683f5135a1f4ee5e046d8446ffd02b95591411d
parent 242963 045bd99f20246714bf7ffa1e9c7d2109627e6826
child 242965 201c323dcf16f47ae0d35bfd5ca50bb07ac04b46
push id28714
push userkwierso@gmail.com
push dateFri, 08 May 2015 17:29:48 +0000
treeherdermozilla-central@5e8adf0e7f2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmano
bugs1160864
milestone40.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 1160864 - The description field is not shown when editing a read-only container child in the Library. r=mano
browser/components/places/content/editBookmarkOverlay.js
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -77,22 +77,28 @@ let gEditItemOverlay = {
   },
 
   get multiEdit() {
     return this.initialized && this._paneInfo.bulkTagging;
   },
 
   // Check if the pane is initialized to show only read-only fields.
   get readOnly() {
-    // Bug 1120314 - Folder shortcuts are read-only due to some quirky implementation
-    // details (the most important being the "smart" semantics of node.title).
-    return (!this.initialized ||
-            (!this._paneInfo.visibleRows.has("tagsRow") &&
-             (this._paneInfo.isFolderShortcut ||
-              this._paneInfo.isParentReadOnly)));
+    // TODO (Bug 1120314): Folder shortcuts are currently read-only due to some
+    // quirky implementation details (the most important being the "smart"
+    // semantics of node.title that makes hard to edit the right entry).
+    // This pane is read-only if:
+    //  * the panel is not initialized
+    //  * the node is a folder shortcut
+    //  * the node is not bookmarked
+    //  * the node is child of a read-only container and is not a bookmarked URI
+    return !this.initialized ||
+           this._paneInfo.isFolderShortcut ||
+           !this._paneInfo.isItem ||
+           (this._paneInfo.isParentReadOnly && !this._paneInfo.isBookmark);
   },
 
   // the first field which was edited after this panel was initialized for
   // a certain item
   _firstEditedField: "",
 
   _initNamePicker() {
     if (this._paneInfo.bulkTagging)
@@ -184,27 +190,30 @@ let gEditItemOverlay = {
       this._namePicker.readOnly = this.readOnly;
     }
 
     // In some cases we want to hide the location field, since it's not
     // human-readable, but we still want to initialize it.
     showOrCollapse("locationRow", isURI, "location");
     if (isURI) {
       this._initLocationField();
-      this._locationField.readOnly = !this._paneInfo.isItem;
+      this._locationField.readOnly = !this.readOnly;
     }
 
-    if (showOrCollapse("descriptionRow",
-                       this._paneInfo.isItem && !this.readOnly,
+    // hide the description field for
+    if (showOrCollapse("descriptionRow", isItem && !this.readOnly,
                        "description")) {
       this._initDescriptionField();
+      this._descriptionField.readOnly = this.readOnly;
     }
 
-    if (showOrCollapse("keywordRow", isBookmark, "keyword"))
+    if (showOrCollapse("keywordRow", isBookmark, "keyword")) {
       this._initKeywordField();
+      this._keywordField.readOnly = this.readOnly;
+    }
 
     // Collapse the tag selector if the item does not accept tags.
     if (showOrCollapse("tagsRow", isURI || bulkTagging, "tags"))
       this._initTagsField().catch(Components.utils.reportError);
     else if (!this._element("tagsSelectorRow").collapsed)
       this.toggleTagsSelector().catch(Components.utils.reportError);
 
     // Load in sidebar.
@@ -353,17 +362,17 @@ let gEditItemOverlay = {
     this._folderMenuList.selectedItem = defaultItem;
 
     // Set a selectedIndex attribute to show special icons
     this._folderMenuList.setAttribute("selectedIndex",
                                       this._folderMenuList.selectedIndex);
 
     // Hide the folders-separator if no folder is annotated as recently-used
     this._element("foldersSeparator").hidden = (menupopup.childNodes.length <= 6);
-    this._folderMenuList.disabled = this._readOnly;
+    this._folderMenuList.disabled = this.readOnly;
   },
 
   QueryInterface:
   XPCOMUtils.generateQI([Components.interfaces.nsIDOMEventListener,
                          Components.interfaces.nsINavBookmarkObserver]),
 
   _element(aID) document.getElementById("editBMPanel_" + aID),
 
@@ -385,17 +394,17 @@ let gEditItemOverlay = {
       this._observersAdded = false;
     }
 
     this._setPaneInfo(null);
     this._firstEditedField = "";
   },
 
   onTagsFieldChange() {
-    if (!this.readOnly) {
+    if (this._paneInfo.isURI || this._paneInfo.bulkTagging) {
       this._updateTags().then(
         anyChanges => {
           if (anyChanges)
             this._mayUpdateFirstEditField("tagsField");
         }, Components.utils.reportError);
     }
   },