Bug 733687 - Persist bookmark dialog height and expanded states. r=InvisibleSmiley a=Callek
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Mon, 26 Mar 2012 00:28:32 +0100
changeset 10717 be6985999277f36be68ebedfa141f0adb091cb56
parent 10716 d40a0933b16d6861fbcc9ead9fb0ace6b7873294
child 10718 4002af09bc21810417175e72460c4b481843aaa4
push idunknown
push userunknown
push dateunknown
reviewersInvisibleSmiley, Callek
bugs733687
Bug 733687 - Persist bookmark dialog height and expanded states. r=InvisibleSmiley a=Callek
suite/browser/browser-prefs.js
suite/common/bookmarks/bm-props.js
suite/common/bookmarks/editBookmarkOverlay.xul
--- a/suite/browser/browser-prefs.js
+++ b/suite/browser/browser-prefs.js
@@ -234,19 +234,21 @@ pref("places.frecency.unvisitedTypedBonu
 pref("browser.bookmarks.autoExportHTML", false);
 
 // The maximum number of daily bookmark backups to
 // keep in {PROFILEDIR}/bookmarkbackups. Special values:
 // -1: unlimited
 //  0: no backups created (and deletes all existing backups)
 pref("browser.bookmarks.max_backups", 10);
 
-// Don't try to alter this pref, it'll be reset the next time you use the
-// bookmarking dialog
+// Don't try to alter these prefs, they'll be reset the next time you use the
+// bookmarking dialog.
 pref("browser.bookmarks.editDialog.firstEditField", "namePicker");
+pref("browser.bookmarks.editDialog.expandTags", false);
+pref("browser.bookmarks.editDialog.expandFolders", false);
 
 // Tabbed browser
 pref("browser.tabs.loadDivertedInBackground", false);
 pref("browser.tabs.loadInBackground", true);
 pref("browser.tabs.opentabfor.doubleclick", false);
 pref("browser.tabs.opentabfor.middleclick", true);
 pref("browser.tabs.opentabfor.urlbar", true);
 pref("browser.tabs.tooltippreview.enable", true);
--- a/suite/common/bookmarks/bm-props.js
+++ b/suite/common/bookmarks/bm-props.js
@@ -346,24 +346,27 @@ var BookmarkPropertiesPanel = {
         if (this._itemType == BOOKMARK_ITEM ||
             this._itemType == LIVEMARK_CONTAINER)
           acceptButton.disabled = !this._inputIsValid();
         break;
     }
 
     // When collapsible elements change their collapsed attribute we must
     // resize the dialog.
-    // sizeToContent is not usable due to bug 90276, so we'll use resizeTo
-    // instead and cache the element size. See WSucks in the legacy
-    // UI code (addBookmark2.js).
+    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                          .getService(Components.interfaces.nsIPrefBranch);
     if (!this._element("tagsRow").collapsed) {
+      if (prefs.getBoolPref("browser.bookmarks.editDialog.expandTags"))
+        gEditItemOverlay.toggleTagsSelector();
       this._element("tagsSelectorRow")
           .addEventListener("DOMAttrModified", this, false);
     }
     if (!this._element("folderRow").collapsed) {
+      if (prefs.getBoolPref("browser.bookmarks.editDialog.expandFolders"))
+        gEditItemOverlay.toggleFolderTreeVisibility();
       this._element("folderTreeRow")
           .addEventListener("DOMAttrModified", this, false);
     }
 
     if (!this._readOnly) {
       // Listen on uri fields to enable accept button if input is valid
       if (this._itemType == BOOKMARK_ITEM) {
         this._element("locationField")
@@ -483,34 +486,43 @@ var BookmarkPropertiesPanel = {
     this._element("folderTreeRow")
         .removeEventListener("DOMAttrModified", this, false);
     this._element("locationField")
         .removeEventListener("input", this, false);
     this._element("feedLocationField")
         .removeEventListener("input", this, false);
     this._element("siteLocationField")
         .removeEventListener("input", this, false);
+
+    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                          .getService(Components.interfaces.nsIPrefBranch);
+    if (!this._element("tagsRow").collapsed)
+      prefs.setBoolPref("browser.bookmarks.editDialog.expandTags",
+                        !this._element("tagsSelectorRow").collapsed);
+    if (!this._element("folderRow").collapsed)
+      prefs.setBoolPref("browser.bookmarks.editDialog.expandFolders",
+                        !this._element("folderTreeRow").collapsed);
   },
 
   onDialogAccept: function BPP_onDialogAccept() {
     // We must blur current focused element to save its changes correctly
     document.commandDispatcher.focusedElement.blur();
     // The order here is important! We have to uninit the panel first, otherwise
     // late changes could force it to commit more transactions.
-    gEditItemOverlay.uninitPanel(true);
+    gEditItemOverlay.uninitPanel(false);
     gEditItemOverlay = null;
     this._endBatch();
     window.arguments[0].performed = true;
   },
 
   onDialogCancel: function BPP_onDialogCancel() {
     // The order here is important! We have to uninit the panel first, otherwise
     // changes done as part of Undo may change the panel contents and by
     // that force it to commit more transactions.
-    gEditItemOverlay.uninitPanel(true);
+    gEditItemOverlay.uninitPanel(false);
     gEditItemOverlay = null;
     this._endBatch();
     PlacesUIUtils.ptm.undoTransaction();
     window.arguments[0].performed = false;
   },
 
   /**
    * This method checks to see if the input fields are in a valid state.
--- a/suite/common/bookmarks/editBookmarkOverlay.xul
+++ b/suite/common/bookmarks/editBookmarkOverlay.xul
@@ -140,17 +140,20 @@
                     tooltiptext="&editBookmarkOverlay.foldersExpanderDown.tooltip;"
                     tooltiptextdown="&editBookmarkOverlay.foldersExpanderDown.tooltip;"
                     tooltiptextup="&editBookmarkOverlay.expanderUp.tooltip;"
                     oncommand="gEditItemOverlay.toggleFolderTreeVisibility();"
                     observes="paneElementsBroadcaster"/>
           </hbox>
         </row>
 
-        <row id="editBMPanel_folderTreeRow" collapsed="true" flex="2">
+        <row id="editBMPanel_folderTreeRow"
+             collapsed="true"
+             persist="height"
+             flex="2">
           <spacer/>
           <vbox flex="1">
             <tree id="editBMPanel_folderTree"
                   class="placesTree"
                   type="places"
                   treelines="true"
                   height="150"
                   flex="1"
@@ -197,17 +200,20 @@
                     tooltiptext="&editBookmarkOverlay.tagsExpanderDown.tooltip;"
                     tooltiptextdown="&editBookmarkOverlay.tagsExpanderDown.tooltip;"
                     tooltiptextup="&editBookmarkOverlay.expanderUp.tooltip;"
                     oncommand="gEditItemOverlay.toggleTagsSelector();"
                     observes="paneElementsBroadcaster"/>
           </hbox>
         </row>
 
-        <row id="editBMPanel_tagsSelectorRow" collapsed="true" flex="2">
+        <row id="editBMPanel_tagsSelectorRow"
+             persist="height"
+             collapsed="true"
+             flex="2">
           <spacer/>
           <listbox id="editBMPanel_tagsSelector"
                    height="150"
                    flex="1"
                    observes="paneElementsBroadcaster"/>
         </row>
 
         <row align="center" id="editBMPanel_keywordRow">
@@ -217,17 +223,17 @@
                  accesskey="&editBookmarkOverlay.keyword.accesskey;"
                  control="editBMPanel_keywordField"
                  observes="paneElementsBroadcaster"/>
           <textbox id="editBMPanel_keywordField"
                    onblur="gEditItemOverlay.onKeywordFieldBlur();"
                    observes="paneElementsBroadcaster"/>
         </row>
 
-        <row id="editBMPanel_descriptionRow" flex="1">
+        <row id="editBMPanel_descriptionRow" persist="height" flex="1">
           <observes element="additionalInfoBroadcaster" attribute="hidden"/>
           <label value="&editBookmarkOverlay.description.label;"
                  class="editBMPanel_rowLabel"
                  accesskey="&editBookmarkOverlay.description.accesskey;"
                  control="editBMPanel_descriptionField"
                  observes="paneElementsBroadcaster"/>
           <textbox id="editBMPanel_descriptionField"
                    multiline="true"