0

我有这个 xml 绑定:

<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl">
    <binding id="tbb" role="xul:toolbarbutton" extends="chrome://global/content/bindings/button.xml#button-base">
        <resources>
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl">
    <binding id="tbb" role="xul:toolbarbutton" extends="chrome://global/content/bindings/button.xml#button-base">
        <resources>
            <stylesheet src="chrome://global/skin/toolbarbutton.css" />
        </resources>
        <content>
            <children includes="observes|template|menupopup|panel|tooltip" />
            <xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label" flex="0" />
            <xul:image class="profilist-badge" xbl:inherits="validate,src=badge,label" width="1" flex="0" />
            <xul:label class="toolbarbutton-text" crop="right" flex="1" xbl:inherits="value=label,accesskey,crop,wrap" />
            <xul:label class="toolbarbutton-multiline-text" flex="1" xbl:inherits="xbl:text=label,accesskey,wrap" />
        </content>
    </binding>
    <binding id="tbb-box">
        <content>
            <children/>
            <xul:box class="profilist-submenu">
                <xul:image class="profilist-closed" />
                <xul:image class="profilist-build" />
                <xul:image class="profilist-safe" />
                <xul:image class="profilist-default" />
                <xul:image class="profilist-rename" />
                <xul:image class="profilist-del" />
            </xul:box>
        </content>
    </binding>
</bindings>

我想要做的是放置一个toolbarbutton使用我在上面定义的绑定的 id'ed profilist-tbb。我想在 XBL 文件中执行此操作。而不是让 css 告诉应用您知道的绑定?

我试过了,工具栏按钮甚至没有被创建:(

<binding id="tbb-box">
    <resources>
        <stylesheet src="chrome://global/skin/toolbarbutton.css" />
    </resources>
    <content>
        <toolbarbutton class="rawr"></toolbarbutton>
        <xul:box class="profilist-submenu">
            <xul:image class="profilist-closed" />
            <xul:image class="profilist-build" />
            <xul:image class="profilist-safe" />
            <xul:image class="profilist-default" />
            <xul:image class="profilist-rename" />
            <xul:image class="profilist-del" />
        </xul:box>
    </content>
</binding>

谢谢

4

1 回答 1

1

我不认为这是最好的解决方案,但这就是我让它工作的方式。我在 id 的 xbl 中给了工具栏按钮一个类,profilist-tbb-box然后从 css 我将绑定应用到toolbarbutton我在其中创建的。

xbl.xml:

<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl">
    <binding id="tbb" role="xul:toolbarbutton" extends="chrome://global/content/bindings/button.xml#button-base">
        <resources>
            <stylesheet src="chrome://global/skin/toolbarbutton.css" />
        </resources>
        <content>
            <children includes="observes|template|menupopup|panel|tooltip" />
            <xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label" flex="0" />
            <xul:image class="profilist-badge" xbl:inherits="validate,src=badge,label" width="1" flex="0" />
            <xul:label class="toolbarbutton-text" crop="right" flex="1" xbl:inherits="value=label,accesskey,crop,wrap" />
            <xul:label class="toolbarbutton-multiline-text" flex="1" xbl:inherits="xbl:text=label,accesskey,wrap" />
        </content>
    </binding>
    <binding id="tbb-box">
        <content>
            <toolbarbutton class="profilist-tbb" xbl:inherits="label,disabled"/>
            <xul:box class="profilist-submenu" xbl:inherits="disabled">
                <xul:image class="profilist-closed" xbl:inherits="disabled"/>
                <xul:image class="profilist-build"  xbl:inherits="disabled"/>
                <xul:image class="profilist-safe"  xbl:inherits="disabled"/>
                <xul:image class="profilist-default"  xbl:inherits="disabled"/>
                <xul:image class="profilist-rename"  xbl:inherits="disabled"/>
                <xul:image class="profilist-del"  xbl:inherits="disabled"/>
            </xul:box>
        </content>
    </binding>
</bindings>

来自CSS:

.profilist-tbb-box {
  -moz-binding: url('chrome://profilist/content/xbl.xml#tbb-box');
}
.profilist-tbb {
  -moz-binding: url('chrome://profilist/content/xbl.xml#tbb');
}
于 2014-08-09T22:18:13.680 回答