/toolkit/content/widgets/menu.xml

http://github.com/zpao/v8monkey · XML · 286 lines · 251 code · 30 blank · 5 comment · 0 complexity · 477253af79276a4c7dfcc52222189122 MD5 · raw file

  1. <?xml version="1.0"?>
  2. <bindings id="menuitemBindings"
  3. xmlns="http://www.mozilla.org/xbl"
  4. xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  5. xmlns:xbl="http://www.mozilla.org/xbl">
  6. <binding id="menuitem-base"
  7. extends="chrome://global/content/bindings/general.xml#control-item">
  8. <resources>
  9. <stylesheet src="chrome://global/skin/menu.css"/>
  10. </resources>
  11. <implementation implements="nsIDOMXULSelectControlItemElement, nsIDOMXULContainerItemElement, nsIAccessibleProvider">
  12. <!-- nsIAccessibleProvider -->
  13. <property name="accessibleType" readonly="true">
  14. <getter>
  15. <![CDATA[
  16. return Components.interfaces.nsIAccessibleProvider.XULMenuitem;
  17. ]]>
  18. </getter>
  19. </property>
  20. <!-- nsIDOMXULSelectControlItemElement -->
  21. <property name="selected" readonly="true"
  22. onget="return this.getAttribute('selected') == 'true';"/>
  23. <property name="control" readonly="true">
  24. <getter>
  25. <![CDATA[
  26. var parent = this.parentNode;
  27. if (parent &&
  28. parent.parentNode instanceof Components.interfaces.nsIDOMXULSelectControlElement)
  29. return parent.parentNode;
  30. return null;
  31. ]]>
  32. </getter>
  33. </property>
  34. <!-- nsIDOMXULContainerItemElement -->
  35. <property name="parentContainer" readonly="true">
  36. <getter>
  37. for (var parent = this.parentNode; parent; parent = parent.parentNode) {
  38. if (parent instanceof Components.interfaces.nsIDOMXULContainerElement)
  39. return parent;
  40. }
  41. return null;
  42. </getter>
  43. </property>
  44. </implementation>
  45. </binding>
  46. <binding id="menu-base"
  47. extends="chrome://global/content/bindings/menu.xml#menuitem-base">
  48. <implementation implements="nsIDOMXULContainerElement">
  49. <property name="open" onget="return this.hasAttribute('open');">
  50. <setter><![CDATA[
  51. this.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject)
  52. .openMenu(val);
  53. return val;
  54. ]]></setter>
  55. </property>
  56. <property name="openedWithKey" readonly="true">
  57. <getter><![CDATA[
  58. return this.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject)
  59. .openedWithKey;
  60. ]]></getter>
  61. </property>
  62. <!-- nsIDOMXULContainerElement interface -->
  63. <method name="appendItem">
  64. <parameter name="aLabel"/>
  65. <parameter name="aValue"/>
  66. <body>
  67. return this.insertItemAt(-1, aLabel, aValue);
  68. </body>
  69. </method>
  70. <method name="insertItemAt">
  71. <parameter name="aIndex"/>
  72. <parameter name="aLabel"/>
  73. <parameter name="aValue"/>
  74. <body>
  75. const XUL_NS =
  76. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  77. var menupopup = this.menupopup;
  78. if (!menupopup) {
  79. menupopup = this.ownerDocument.createElementNS(XUL_NS, "menupopup");
  80. this.appendChild(menupopup);
  81. }
  82. var menuitem = this.ownerDocument.createElementNS(XUL_NS, "menuitem");
  83. menuitem.setAttribute("label", aLabel);
  84. menuitem.setAttribute("value", aValue);
  85. var before = this.getItemAtIndex(aIndex);
  86. if (before)
  87. return menupopup.insertBefore(menuitem, before);
  88. return menupopup.appendChild(menuitem);
  89. </body>
  90. </method>
  91. <method name="removeItemAt">
  92. <parameter name="aIndex"/>
  93. <body>
  94. <![CDATA[
  95. var menupopup = this.menupopup;
  96. if (menupopup) {
  97. var item = this.getItemAtIndex(aIndex);
  98. if (item)
  99. return menupopup.removeChild(item);
  100. }
  101. return null;
  102. ]]>
  103. </body>
  104. </method>
  105. <property name="itemCount" readonly="true">
  106. <getter>
  107. var menupopup = this.menupopup;
  108. return menupopup ? menupopup.childNodes.length : 0;
  109. </getter>
  110. </property>
  111. <method name="getIndexOfItem">
  112. <parameter name="aItem"/>
  113. <body>
  114. <![CDATA[
  115. var menupopup = this.menupopup;
  116. if (menupopup) {
  117. var items = menupopup.childNodes;
  118. var length = items.length;
  119. for (var index = 0; index < length; ++index) {
  120. if (items[index] == aItem)
  121. return index;
  122. }
  123. }
  124. return -1;
  125. ]]>
  126. </body>
  127. </method>
  128. <method name="getItemAtIndex">
  129. <parameter name="aIndex"/>
  130. <body>
  131. <![CDATA[
  132. var menupopup = this.menupopup;
  133. if (!menupopup || aIndex < 0 || aIndex >= menupopup.childNodes.length)
  134. return null;
  135. return menupopup.childNodes[aIndex];
  136. ]]>
  137. </body>
  138. </method>
  139. <property name="menupopup" readonly="true">
  140. <getter>
  141. <![CDATA[
  142. const XUL_NS =
  143. "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  144. for (var child = this.firstChild; child; child = child.nextSibling) {
  145. if (child.namespaceURI == XUL_NS && child.localName == "menupopup")
  146. return child;
  147. }
  148. return null;
  149. ]]>
  150. </getter>
  151. </property>
  152. </implementation>
  153. </binding>
  154. <binding id="menu"
  155. extends="chrome://global/content/bindings/menu.xml#menu-base">
  156. <content>
  157. <xul:label class="menu-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  158. <xul:hbox class="menu-accel-container" anonid="accel">
  159. <xul:label class="menu-accel" xbl:inherits="value=acceltext"/>
  160. </xul:hbox>
  161. <xul:hbox align="center" class="menu-right" xbl:inherits="_moz-menuactive,disabled">
  162. <xul:image/>
  163. </xul:hbox>
  164. <children includes="menupopup"/>
  165. </content>
  166. </binding>
  167. <binding id="menuitem" extends="chrome://global/content/bindings/menu.xml#menuitem-base">
  168. <content>
  169. <xul:label class="menu-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  170. <xul:hbox class="menu-accel-container" anonid="accel">
  171. <xul:label class="menu-accel" xbl:inherits="value=acceltext"/>
  172. </xul:hbox>
  173. </content>
  174. </binding>
  175. <binding id="menu-menubar"
  176. extends="chrome://global/content/bindings/menu.xml#menu-base">
  177. <content>
  178. <xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  179. <children includes="menupopup"/>
  180. </content>
  181. </binding>
  182. <binding id="menu-menubar-iconic"
  183. extends="chrome://global/content/bindings/menu.xml#menu-base">
  184. <content>
  185. <xul:image class="menubar-left" xbl:inherits="src=image"/>
  186. <xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  187. <children includes="menupopup"/>
  188. </content>
  189. </binding>
  190. <binding id="menuitem-iconic" extends="chrome://global/content/bindings/menu.xml#menuitem">
  191. <content>
  192. <xul:hbox class="menu-iconic-left" align="center" pack="center"
  193. xbl:inherits="selected,_moz-menuactive,disabled,checked">
  194. <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
  195. </xul:hbox>
  196. <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  197. <xul:hbox class="menu-accel-container" anonid="accel">
  198. <xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/>
  199. </xul:hbox>
  200. </content>
  201. </binding>
  202. <binding id="menuitem-iconic-noaccel" extends="chrome://global/content/bindings/menu.xml#menuitem">
  203. <content>
  204. <xul:hbox class="menu-iconic-left" align="center" pack="center"
  205. xbl:inherits="selected,disabled,checked">
  206. <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
  207. </xul:hbox>
  208. <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  209. </content>
  210. </binding>
  211. <binding id="menuitem-iconic-desc-noaccel" extends="chrome://global/content/bindings/menu.xml#menuitem">
  212. <content>
  213. <xul:hbox class="menu-iconic-left" align="center" pack="center"
  214. xbl:inherits="selected,disabled,checked">
  215. <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
  216. </xul:hbox>
  217. <xul:label class="menu-iconic-text" xbl:inherits="value=label,accesskey,crop" crop="right" flex="1"/>
  218. <xul:label class="menu-iconic-text menu-description" xbl:inherits="value=description" crop="right" flex="10000"/>
  219. </content>
  220. </binding>
  221. <binding id="menu-iconic"
  222. extends="chrome://global/content/bindings/menu.xml#menu-base">
  223. <content>
  224. <xul:hbox class="menu-iconic-left" align="center" pack="center">
  225. <xul:image class="menu-iconic-icon" xbl:inherits="src=image"/>
  226. </xul:hbox>
  227. <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  228. <xul:hbox class="menu-accel-container" anonid="accel">
  229. <xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/>
  230. </xul:hbox>
  231. <xul:hbox align="center" class="menu-right" xbl:inherits="_moz-menuactive,disabled">
  232. <xul:image/>
  233. </xul:hbox>
  234. <children includes="menupopup|template"/>
  235. </content>
  236. </binding>
  237. <binding id="menubutton-item" extends="chrome://global/content/bindings/menu.xml#menuitem-base">
  238. <content>
  239. <xul:label class="menubutton-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/>
  240. <children includes="menupopup"/>
  241. </content>
  242. </binding>
  243. <binding id="menuseparator"
  244. extends="chrome://global/content/bindings/menu.xml#menuitem-base">
  245. <implementation>
  246. <!-- nsIAccessibleProvider -->
  247. <property name="accessibleType" readonly="true">
  248. <getter>
  249. <![CDATA[
  250. return Components.interfaces.nsIAccessibleProvider.XULMenuSeparator;
  251. ]]>
  252. </getter>
  253. </property>
  254. </implementation>
  255. </binding>
  256. </bindings>