diff options
Diffstat (limited to 'toolkit/content/widgets/toolbar.xml')
-rw-r--r-- | toolkit/content/widgets/toolbar.xml | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/toolkit/content/widgets/toolbar.xml b/toolkit/content/widgets/toolbar.xml index 548504e24..55cef8244 100644 --- a/toolkit/content/widgets/toolbar.xml +++ b/toolkit/content/widgets/toolbar.xml @@ -30,7 +30,7 @@ </field> <field name="externalToolbars"> - [] + [] </field> <!-- Set by customizeToolbar.js --> @@ -49,18 +49,54 @@ <constructor> <![CDATA[ + this.toolbarInfoSeparators = ["|", "-"]; + this.toolbarInfoLegacySeparator = ":"; // Look to see if there is a toolbarset. this.toolbarset = this.firstChild; - while (this.toolbarset && this.toolbarset.localName != "toolbarset") - this.toolbarset = toolbarset.nextSibling; + while (this.toolbarset && this.toolbarset.localName != "toolbarset") { + this.toolbarset = this.toolbarset.nextSibling; + } if (this.toolbarset) { // Create each toolbar described by the toolbarset. var index = 0; - while (toolbarset.hasAttribute("toolbar"+(++index))) { - var toolbarInfo = toolbarset.getAttribute("toolbar"+index); - var infoSplit = toolbarInfo.split(":"); - this.appendCustomToolbar(infoSplit[0], infoSplit[1]); + while (this.toolbarset.hasAttribute("toolbar" + (++index))) { + let hiddingAttribute = + this.toolbarset.getAttribute("type") == "menubar" + ? "autohide" : "collapsed"; + let toolbarInfo = this.toolbarset.getAttribute("toolbar" + index); + let infoSplit = toolbarInfo.split(this.toolbarInfoSeparators[0]); + if (infoSplit.length == 1) { + infoSplit = toolbarInfo.split(this.toolbarInfoLegacySeparator); + } + let infoName = infoSplit[0]; + let infoHidingAttribute = [null, null]; + let infoCurrentSet = ""; + let infoSplitLen = infoSplit.length; + switch (infoSplitLen) { + case 3: + // Pale Moon 27.2+ + // Basilisk (UXP) + infoHidingAttribute = infoSplit[1] + .split(this.toolbarInfoSeparators[1]); + infoCurrentSet = infoSplit[2]; + break; + case 2: + // Legacy: + // - toolbars from Pale Moon 27.0 - 27.1.x + // - Basilisk (moebius) + // The previous value (hiddingAttribute) isn't stored. + infoHidingAttribute = [hiddingAttribute, "false"]; + infoCurrentSet = infoSplit[1]; + break; + default: + Components.utils.reportError( + "Customizable toolbars - an invalid value:" + "\n" + + '"toolbar' + index + '" = "' + toolbarInfo + '"'); + break; + } + this.appendCustomToolbar( + infoName, infoCurrentSet, infoHidingAttribute); } } ]]> @@ -69,6 +105,7 @@ <method name="appendCustomToolbar"> <parameter name="aName"/> <parameter name="aCurrentSet"/> + <parameter name="aHidingAttribute"/> <body> <![CDATA[ if (!this.toolbarset) @@ -84,6 +121,10 @@ toolbar.setAttribute("iconsize", this.getAttribute("iconsize")); toolbar.setAttribute("context", this.toolbarset.getAttribute("context")); toolbar.setAttribute("class", "chromeclass-toolbar"); + // Restore persist the hiding attribute. + if (aHidingAttribute[0]) { + toolbar.setAttribute(aHidingAttribute[0], aHidingAttribute[1]); + } this.insertBefore(toolbar, this.toolbarset); return toolbar; |