Bug 813218 - Fix padding in the Folder picker in the Toolbar widget. ui-r=bwinton, r=mkmelin
authoraceman <acelists@atlas.sk>
Sun, 13 Jan 2013 09:41:45 -0500
changeset 11809 764a9ff6e1ac20a6c1b75b26075c26667216532a
parent 11808 d5ac1b0f26d8f548b675f0831375a5edeb05652d
child 11810 86b275c695fd86e9778ffa55bd3d960e6f8d57b4
push id8797
push userryanvm@gmail.com
push dateSun, 13 Jan 2013 14:41:58 +0000
treeherdercomm-central@764a9ff6e1ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwinton, mkmelin
bugs813218
Bug 813218 - Fix padding in the Folder picker in the Toolbar widget. ui-r=bwinton, r=mkmelin
mail/base/content/extraCustomizeItems.xul
mail/test/mozmill/folder-display/test-folder-toolbar.js
mail/themes/gnomestripe/mail/folderMenus.css
mail/themes/pinstripe/mail/folderMenus.css
mail/themes/qute/mail/folderMenus.css
mailnews/base/content/folderWidgets.xml
mailnews/extensions/newsblog/content/feed-subscriptions.xul
--- a/mail/base/content/extraCustomizeItems.xul
+++ b/mail/base/content/extraCustomizeItems.xul
@@ -67,22 +67,22 @@
                    oncommand="goDoCommand('button_compact');"
                    observes="button_compact"/>
     <toolbaritem id="folder-location-container" insert-after="button-stop"
                  title="&folderLocationToolbarItem.title;"
                  align="center"
                  class="chromeclass-toolbar-additional">
       <menulist id="locationFolders"
                 class="folderMenuItem"
-                label=" "
+                label="&folderLocationToolbarItem.title;"
                 context="folderPaneContext"
-                width="170"
+                maxwidth="300"
                 crop="center">
         <menupopup id="folderLocationPopup"
-                   class="folderLocationPopup"
+                   class="menulist-menupopup"
                    type="folder"
                    flex="1"
                    fileHereLabel="&filemessageschoosethis.label;"
                    showFileHereLabel="true"
                    oncommand="gFolderTreeView.selectFolder(event.target._folder);"/>
       </menulist>
     </toolbaritem>
     <toolbaritem id="mailviews-container"
--- a/mail/test/mozmill/folder-display/test-folder-toolbar.js
+++ b/mail/test/mozmill/folder-display/test-folder-toolbar.js
@@ -21,30 +21,69 @@ function setupModule(module)
   wh.installInto(module);
 
   folderA = create_folder("FolderToolbarA");
   // we need one message to select and open
   folderB = create_folder("FolderToolbarB");
   make_new_sets_in_folder(folderB, [{count: 1}]);
 }
 
+/**
+ * Returns the value of an individual entity in a DTD file.
+ * Code borrowed from https://hg.mozilla.org/qa/mozmill-tests/file/lib/utils.js.
+ * This function could be put into some shared module if more tests need it.
+ *
+ * @param [string] urls
+ *        Array of DTD urls.
+ * @param {string} entityId
+ *        The ID of the entity to get the value of.
+ *
+ * @return The value of the requested entity
+ * @type string
+ */
+function getEntity(urls, entityId) {
+  // Add xhtml11.dtd to prevent missing entity errors with XHTML files
+  urls.push("resource:///res/dtd/xhtml11.dtd");
+
+  // Build a string of external entities
+  var extEntities = "";
+  for (i = 0; i < urls.length; i++) {
+    extEntities += '<!ENTITY % dtd' + i + ' SYSTEM "' +
+    urls[i] + '">%dtd' + i + ';';
+  }
+
+  var parser = Cc["@mozilla.org/xmlextras/domparser;1"]
+                 .createInstance(Ci.nsIDOMParser);
+  var header = '<?xml version="1.0"?><!DOCTYPE elem [' + extEntities + ']>';
+  var elem = '<elem id="elementID">&' + entityId + ';</elem>';
+  var doc = parser.parseFromString(header + elem, 'text/xml');
+  var elemNode = doc.querySelector('elem[id="elementID"]');
+
+  if (elemNode == null)
+    throw new Error(arguments.callee.name + ": Unknown entity - " + entityId);
+
+  return elemNode.textContent;
+}
+
 function test_add_folder_toolbar()
 {
   // It should not be present by default
   let folderLoc = mc.eid("locationFolders");
   mc.assertNodeNotExist(folderLoc);
 
   // But it should show up when we call
   add_to_toolbar(mc.e("mail-bar3"), "folder-location-container");
   folderLoc = mc.eid("locationFolders");
   mc.assertNode(folderLoc);
 
+  let defaultLabel = getEntity(["chrome://messenger/locale/messenger.dtd"],
+                               "folderLocationToolbarItem.title");
   // XXX I'm not sure we actually want this behavior...
-  assert_equals(folderLoc.node.label, " ",
-                "Uninitialized Folder doesn't have a blank label.");
+  assert_equals(folderLoc.node.label, defaultLabel,
+                "Uninitialized Folder doesn't have the default label.");
 }
 
 function test_folder_toolbar_shows_correct_item()
 {
   add_to_toolbar(mc.e("mail-bar3"), "folder-location-container");
   let folderLoc = mc.eid("locationFolders");
 
   // Start in folder a.
--- a/mail/themes/gnomestripe/mail/folderMenus.css
+++ b/mail/themes/gnomestripe/mail/folderMenus.css
@@ -96,18 +96,8 @@
   -moz-image-region: rect(0px 80px 16px 64px);
 }
 
 /* Feed account node */
 .folderMenuItem[IsServer="true"][ServerType="rss"] {
   list-style-image: url("chrome://messenger/skin/icons/folder-pane.png");
   -moz-image-region: rect(32px 16px 48px 0px);
 }
-
-/* Make any sub-menu item of the folderLocationPopup act like a menuitem. */
-.folderLocationPopup menuitem,
-.folderLocationPopup menu {
-  -moz-padding-end: 30px;
-  padding-top: 0px;
-  padding-bottom: 0px;
-  max-width: none;
-  font: message-box;
-}
--- a/mail/themes/pinstripe/mail/folderMenus.css
+++ b/mail/themes/pinstripe/mail/folderMenus.css
@@ -95,18 +95,8 @@
   -moz-image-region: rect(0 32px 16px 16px);
 }
 
 /* Feed servers */
 .folderMenuItem[IsServer="true"][ServerType="rss"] {
   list-style-image: url("chrome://messenger/skin/icons/server.png");
   -moz-image-region: rect(0 16px 16px 0);
 }
-
-/* Make any sub-menu item of the folderLocationPopup act like a menuitem. */
-.folderLocationPopup menuitem,
-.folderLocationPopup menu {
-  -moz-padding-end: 30px;
-  padding-top: 0px;
-  padding-bottom: 0px;
-  max-width: none;
-  font: message-box;
-}
--- a/mail/themes/qute/mail/folderMenus.css
+++ b/mail/themes/qute/mail/folderMenus.css
@@ -95,18 +95,8 @@
 .folderMenuItem[IsServer="true"][ServerType="nntp"][IsSecure="true"] {
   -moz-image-region: rect(0 80px 16px 64px) !important;
 }
 
 /* Feed server */
 .folderMenuItem[IsServer="true"][ServerType="rss"] {
   list-style-image: url("chrome://messenger-newsblog/skin/icons/server-rss.png");
 }
-
-/* Make any sub-menu item of the folderLocationPopup act like a menuitem. */
-.folderLocationPopup menuitem,
-.folderLocationPopup menu {
-  -moz-padding-end: 30px;
-  padding-top: 0px;
-  padding-bottom: 0px;
-  max-width: none;
-  font: message-box;
-}
--- a/mailnews/base/content/folderWidgets.xml
+++ b/mailnews/base/content/folderWidgets.xml
@@ -26,23 +26,40 @@
         while (node instanceof XULElement) {
           if (/wrapper-.*/.test(node.id)) {
             inWrapper = true;
             break;
           }
           node = node.parentNode;
         }
         if (this.parentNode && this.parentNode.localName == "menulist" &&
-            !inWrapper)
+            !inWrapper) {
+          // If we were in a wrapper before and have a width stored, restore it now.
+          if (this.hasAttribute("original-width")) {
+            if (this.getAttribute("original-width") == "none")
+              this.removeAttribute("width");
+            else
+              this.setAttribute("width", this.getAttribute("original-width"));
+
+            this.removeAttribute("original-width");
+          }
           this._ensureInitialized();
-
+        }
         // But if we're in a wrapper, remove our children, because we're
         // getting re-created when the toolbar customization closes.
-        if (inWrapper)
+        if (inWrapper) {
           this._teardown();
+          // Store our current width and set a safe small width when we show
+          // in a wrapper.
+          if (!this.hasAttribute("original-width")) {
+            this.setAttribute("original-width", this.hasAttribute("width") ?
+                                                this.getAttribute("width") : "none");
+            this.setAttribute("width", "100");
+          }
+        }
       ]]></constructor>
       <destructor><![CDATA[
         // Clean up when being destroyed.
         this._removeListener();
       ]]></destructor>
       <!--
          - Make sure we remove our listener when the window is being destroyed
          - or the widget teared down.
--- a/mailnews/extensions/newsblog/content/feed-subscriptions.xul
+++ b/mailnews/extensions/newsblog/content/feed-subscriptions.xul
@@ -121,17 +121,17 @@
                        control="selectFolder"/>
               </hbox>
               <hbox>
                 <menulist id="selectFolder"
                           flex="1"
                           class="folderMenuItem"
                           hidden="true">
                   <menupopup id="selectFolderPopup"
-                             class="folderLocationPopup"
+                             class="menulist-menupopup"
                              type="folder"
                              mode="feeds"
                              showFileHereLabel="true"
                              showAccountsFileHere="true"
                              oncommand="FeedSubscriptions.setFolderPicker(event.target._folder)"/>
                 </menulist>
                 <textbox id="selectFolderValue"
                          flex="1"