зеркало из https://github.com/mozilla/gecko-dev.git
227 строки
8.6 KiB
XML
227 строки
8.6 KiB
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/. -->
|
|
<!-- globals XULMenuElement -->
|
|
|
|
<bindings id="menuitemBindings"
|
|
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="menuitem-base"
|
|
extends="chrome://global/content/bindings/general.xml#basetext">
|
|
<implementation implements="nsIDOMXULSelectControlItemElement, nsIDOMXULContainerItemElement">
|
|
<property name="value" onset="this.setAttribute('value', val); return val;"
|
|
onget="return this.getAttribute('value');"/>
|
|
<!-- nsIDOMXULSelectControlItemElement -->
|
|
<property name="selected" readonly="true"
|
|
onget="return this.getAttribute('selected') == 'true';"/>
|
|
<property name="control" readonly="true">
|
|
<getter>
|
|
<![CDATA[
|
|
var parent = this.parentNode;
|
|
// Return the parent if it is a menu or menulist.
|
|
if (parent && parent.parentNode instanceof XULMenuElement) {
|
|
return parent.parentNode;
|
|
}
|
|
return null;
|
|
]]>
|
|
</getter>
|
|
</property>
|
|
|
|
<!-- nsIDOMXULContainerItemElement -->
|
|
<property name="parentContainer" readonly="true">
|
|
<getter>
|
|
for (var parent = this.parentNode; parent; parent = parent.parentNode) {
|
|
if (parent instanceof XULMenuElement) {
|
|
return parent;
|
|
}
|
|
}
|
|
return null;
|
|
</getter>
|
|
</property>
|
|
</implementation>
|
|
</binding>
|
|
|
|
<binding id="menu-base"
|
|
extends="chrome://global/content/bindings/menu.xml#menuitem-base">
|
|
|
|
<implementation implements="nsIDOMXULContainerElement">
|
|
<property name="open" onget="return this.hasAttribute('open');">
|
|
<setter><![CDATA[
|
|
this.openMenu(val);
|
|
return val;
|
|
]]></setter>
|
|
</property>
|
|
|
|
<!-- nsIDOMXULContainerElement interface -->
|
|
<method name="appendItem">
|
|
<parameter name="aLabel"/>
|
|
<parameter name="aValue"/>
|
|
<body>
|
|
var menupopup = this.menupopup;
|
|
if (!menupopup) {
|
|
menupopup = this.ownerDocument.createXULElement("menupopup");
|
|
this.appendChild(menupopup);
|
|
}
|
|
|
|
var menuitem = this.ownerDocument.createXULElement("menuitem");
|
|
menuitem.setAttribute("label", aLabel);
|
|
menuitem.setAttribute("value", aValue);
|
|
|
|
return menupopup.appendChild(menuitem);
|
|
</body>
|
|
</method>
|
|
|
|
<property name="itemCount" readonly="true">
|
|
<getter>
|
|
var menupopup = this.menupopup;
|
|
return menupopup ? menupopup.children.length : 0;
|
|
</getter>
|
|
</property>
|
|
|
|
<method name="getIndexOfItem">
|
|
<parameter name="aItem"/>
|
|
<body>
|
|
<![CDATA[
|
|
var menupopup = this.menupopup;
|
|
if (menupopup) {
|
|
var items = menupopup.children;
|
|
var length = items.length;
|
|
for (var index = 0; index < length; ++index) {
|
|
if (items[index] == aItem)
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
]]>
|
|
</body>
|
|
</method>
|
|
|
|
<method name="getItemAtIndex">
|
|
<parameter name="aIndex"/>
|
|
<body>
|
|
<![CDATA[
|
|
var menupopup = this.menupopup;
|
|
if (!menupopup || aIndex < 0 || aIndex >= menupopup.children.length)
|
|
return null;
|
|
|
|
return menupopup.children[aIndex];
|
|
]]>
|
|
</body>
|
|
</method>
|
|
|
|
<property name="menupopup" readonly="true">
|
|
<getter>
|
|
<![CDATA[
|
|
const XUL_NS =
|
|
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
for (var child = this.firstElementChild; child; child = child.nextElementSibling) {
|
|
if (child.namespaceURI == XUL_NS && child.localName == "menupopup")
|
|
return child;
|
|
}
|
|
return null;
|
|
]]>
|
|
</getter>
|
|
</property>
|
|
</implementation>
|
|
</binding>
|
|
|
|
<binding id="menu"
|
|
extends="chrome://global/content/bindings/menu.xml#menu-base">
|
|
<content>
|
|
<xul:label class="menu-text" xbl:inherits="value=label,accesskey,crop" crop="right"/>
|
|
<xul:hbox class="menu-accel-container" anonid="accel">
|
|
<xul:label class="menu-accel" xbl:inherits="value=acceltext"/>
|
|
</xul:hbox>
|
|
<xul:hbox align="center" class="menu-right" xbl:inherits="_moz-menuactive,disabled">
|
|
<xul:image/>
|
|
</xul:hbox>
|
|
<children includes="menupopup"/>
|
|
</content>
|
|
</binding>
|
|
|
|
<binding id="menuitem" extends="chrome://global/content/bindings/menu.xml#menuitem-base">
|
|
<content>
|
|
<xul:label class="menu-text" xbl:inherits="value=label,accesskey,crop,highlightable" crop="right"/>
|
|
<xul:hbox class="menu-accel-container" anonid="accel">
|
|
<xul:label class="menu-accel" xbl:inherits="value=acceltext"/>
|
|
</xul:hbox>
|
|
</content>
|
|
</binding>
|
|
|
|
<binding id="menu-menubar"
|
|
extends="chrome://global/content/bindings/menu.xml#menu-base">
|
|
<content>
|
|
<xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/>
|
|
<children includes="menupopup"/>
|
|
</content>
|
|
</binding>
|
|
|
|
<binding id="menu-menubar-iconic"
|
|
extends="chrome://global/content/bindings/menu.xml#menu-base">
|
|
<content>
|
|
<xul:image class="menubar-left" xbl:inherits="src=image"/>
|
|
<xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/>
|
|
<children includes="menupopup"/>
|
|
</content>
|
|
</binding>
|
|
|
|
<binding id="menuitem-iconic" extends="chrome://global/content/bindings/menu.xml#menuitem">
|
|
<content>
|
|
<xul:hbox class="menu-iconic-left" align="center" pack="center"
|
|
xbl:inherits="selected,_moz-menuactive,disabled,checked">
|
|
<xul:image class="menu-iconic-icon" xbl:inherits="src=image,triggeringprincipal=iconloadingprincipal,validate,src"/>
|
|
</xul:hbox>
|
|
<xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop,highlightable" crop="right"/>
|
|
<xul:label class="menu-iconic-highlightable-text" xbl:inherits="xbl:text=label,crop,accesskey,highlightable" crop="right"/>
|
|
<children/>
|
|
<xul:hbox class="menu-accel-container" anonid="accel">
|
|
<xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/>
|
|
</xul:hbox>
|
|
</content>
|
|
</binding>
|
|
|
|
<binding id="menuitem-iconic-noaccel" extends="chrome://global/content/bindings/menu.xml#menuitem">
|
|
<content>
|
|
<xul:hbox class="menu-iconic-left" align="center" pack="center"
|
|
xbl:inherits="selected,disabled,checked">
|
|
<xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
|
|
</xul:hbox>
|
|
<xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop,highlightable" crop="right"/>
|
|
<xul:label class="menu-iconic-highlightable-text" xbl:inherits="xbl:text=label,crop,accesskey,highlightable" crop="right"/>
|
|
</content>
|
|
</binding>
|
|
|
|
<binding id="menucaption" extends="chrome://global/content/bindings/menu.xml#menu-base">
|
|
<content>
|
|
<xul:hbox class="menu-iconic-left" align="center" pack="center"
|
|
xbl:inherits="selected,disabled,checked">
|
|
<xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
|
|
</xul:hbox>
|
|
<xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,crop,highlightable" crop="right"/>
|
|
<xul:label class="menu-iconic-highlightable-text" xbl:inherits="xbl:text=label,crop,highlightable" crop="right"/>
|
|
</content>
|
|
</binding>
|
|
|
|
<binding id="menu-iconic"
|
|
extends="chrome://global/content/bindings/menu.xml#menu-base">
|
|
<content>
|
|
<xul:hbox class="menu-iconic-left" align="center" pack="center">
|
|
<xul:image class="menu-iconic-icon" xbl:inherits="src=image"/>
|
|
</xul:hbox>
|
|
<xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop,highlightable" crop="right"/>
|
|
<xul:label class="menu-iconic-highlightable-text" xbl:inherits="xbl:text=label,crop,accesskey,highlightable" crop="right"/>
|
|
<xul:hbox class="menu-accel-container" anonid="accel">
|
|
<xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/>
|
|
</xul:hbox>
|
|
<xul:hbox align="center" class="menu-right" xbl:inherits="_moz-menuactive,disabled">
|
|
<xul:image/>
|
|
</xul:hbox>
|
|
<children includes="menupopup|template"/>
|
|
</content>
|
|
</binding>
|
|
</bindings>
|