PageRenderTime 31ms CodeModel.GetById 16ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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