Bug 736738 Make it easier for applications and extensions to overlay the customize toolbar window r=gavin.
authorPhilip Chee <philip.chee@gmail.com>
Thu, 29 Mar 2012 23:33:52 +0800
changeset 93944 a9dfce8466063e7e76276cb3767c3fd555cb3ab7
parent 93943 ed56fc645fc31ac805a60a3a556661f6571c274d
child 93945 f059dc47f3d7d219085e9d654a87263d7bdefb24
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs736738
milestone14.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 736738 Make it easier for applications and extensions to overlay the customize toolbar window r=gavin.
toolkit/content/customizeToolbar.js
toolkit/content/customizeToolbar.xul
toolkit/content/widgets/toolbar.xml
--- a/toolkit/content/customizeToolbar.js
+++ b/toolkit/content/customizeToolbar.js
@@ -106,16 +106,20 @@ function finishToolbarCustomization()
     toolbar.removeAttribute("customizing");
   });
 
   notifyParentComplete();
 }
 
 function initDialog()
 {
+  if (!gToolbox.toolbarset) {
+    document.getElementById("newtoolbar").hidden = true;
+  }
+
   var mode = gToolbox.getAttribute("mode");
   document.getElementById("modelist").value = mode;
   var smallIconsCheckbox = document.getElementById("smallicons");
   smallIconsCheckbox.checked = gToolbox.getAttribute("iconsize") == "small";
   if (mode == "text")
     smallIconsCheckbox.disabled = true;
 
   // Build up the palette of other items.
@@ -197,32 +201,32 @@ function persistCurrentSets()
     var currentSet = toolbar.currentSet;
     toolbar.setAttribute("currentset", currentSet);
 
     var customIndex = toolbar.hasAttribute("customindex");
     if (customIndex) {
       if (!toolbar.hasChildNodes()) {
         // Remove custom toolbars whose contents have been removed.
         gToolbox.removeChild(toolbar);
-      } else {
+      } else if (gToolbox.toolbarset) {
         // Persist custom toolbar info on the <toolbarset/>
         gToolbox.toolbarset.setAttribute("toolbar"+(++customCount),
                                          toolbar.toolbarName + ":" + currentSet);
         gToolboxDocument.persist(gToolbox.toolbarset.id, "toolbar"+customCount);
       }
     }
 
     if (!customIndex) {
       // Persist the currentset attribute directly on hardcoded toolbars.
       gToolboxDocument.persist(toolbar.id, "currentset");
     }
   });
 
   // Remove toolbarX attributes for removed toolbars.
-  while (gToolbox.toolbarset.hasAttribute("toolbar"+(++customCount))) {
+  while (gToolbox.toolbarset && gToolbox.toolbarset.hasAttribute("toolbar"+(++customCount))) {
     gToolbox.toolbarset.removeAttribute("toolbar"+customCount);
     gToolboxDocument.persist(gToolbox.toolbarset.id, "toolbar"+customCount);
   }
 }
 
 /**
  * Wraps all items in all customizable toolbars in a toolbox.
  */
--- a/toolkit/content/customizeToolbar.xul
+++ b/toolkit/content/customizeToolbar.xul
@@ -74,27 +74,27 @@
   <vbox flex="1" id="palette-box"
         ondragstart="onToolbarDragStart(event)"
         ondragover="onPaletteDragOver(event)"
         ondrop="onPaletteDrop(event)"/>
 
   <box align="center">
     <label value="&show.label;"/>
     <menulist id="modelist" value="icons" oncommand="updateToolbarMode(this.value);">
-      <menupopup>
-        <menuitem value="full" label="&iconsAndText.label;"/>
-        <menuitem value="icons" label="&icons.label;"/>
-        <menuitem value="text" label="&text.label;"/>
+      <menupopup id="modelistpopup">
+        <menuitem id="modefull" value="full" label="&iconsAndText.label;"/>
+        <menuitem id="modeicons" value="icons" label="&icons.label;"/>
+        <menuitem id="modetext" value="text" label="&text.label;"/>
       </menupopup>
     </menulist>
 
     <checkbox id="smallicons" oncommand="updateIconSize(this.checked ? 'small' : 'large');" label="&useSmallIcons.label;"/>
 
-    <button label="&addNewToolbar.label;" oncommand="addNewToolbar();" icon="add"/>
-    <button label="&restoreDefaultSet.label;" oncommand="restoreDefaultSet();" icon="revert"/>
+    <button id="newtoolbar" label="&addNewToolbar.label;" oncommand="addNewToolbar();" icon="add"/>
+    <button id="restoreDefault" label="&restoreDefaultSet.label;" oncommand="restoreDefaultSet();" icon="revert"/>
   </box>
 
   <separator class="groove"/>
 
   <hbox align="center" pack="end">
     <button id="donebutton" label="&saveChanges.label;" oncommand="onClose();"
             default="true" icon="close"/>
   </hbox>
--- a/toolkit/content/widgets/toolbar.xml
+++ b/toolkit/content/widgets/toolbar.xml
@@ -62,16 +62,18 @@
         ]]>
       </constructor>
       
       <method name="appendCustomToolbar">
         <parameter name="aName"/>
         <parameter name="aCurrentSet"/>
         <body>
           <![CDATA[            
+            if (!this.toolbarset)
+              return null;
             var toolbar = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
                                                   "toolbar");
             toolbar.id = "__customToolbar_" + aName.replace(" ", "_");
             toolbar.setAttribute("customizable", "true");
             toolbar.setAttribute("customindex", ++this.customToolbarCount);
             toolbar.setAttribute("toolbarname", aName);
             toolbar.setAttribute("currentset", aCurrentSet);
             toolbar.setAttribute("mode", this.getAttribute("mode"));