gecko-dev/toolkit/content/widgets/toolbar.xml
Paolo Amadini d6977c62c9 Bug 1428930 - Move some XBL accessibility roles into XULMap.h. r=bgrins,surkov
MozReview-Commit-ID: Iye8XoQ7neq

--HG--
extra : rebase_source : e9101e02cdf30489eda8867cbf6784eeb923e47d
2018-02-07 13:23:53 +00:00

214 lines
7.1 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/. -->
<bindings id="toolbarBindings"
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="toolbar-base">
<resources>
<stylesheet src="chrome://global/skin/toolbar.css"/>
</resources>
</binding>
<binding id="toolbar"
extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" />
<binding id="toolbar-menubar-autohide"
extends="chrome://global/content/bindings/toolbar.xml#toolbar">
<implementation>
<constructor>
this._setInactive();
</constructor>
<destructor>
this._setActive();
</destructor>
<field name="_inactiveTimeout">null</field>
<field name="_contextMenuListener"><![CDATA[({
toolbar: this,
contextMenu: null,
get active() {
return !!this.contextMenu;
},
init(event) {
var node = event.target;
while (node != this.toolbar) {
if (node.localName == "menupopup")
return;
node = node.parentNode;
}
var contextMenuId = this.toolbar.getAttribute("context");
if (!contextMenuId)
return;
this.contextMenu = document.getElementById(contextMenuId);
if (!this.contextMenu)
return;
this.contextMenu.addEventListener("popupshown", this);
this.contextMenu.addEventListener("popuphiding", this);
this.toolbar.addEventListener("mousemove", this);
},
handleEvent(event) {
switch (event.type) {
case "popupshown":
this.toolbar.removeEventListener("mousemove", this);
break;
case "popuphiding":
case "mousemove":
this.toolbar._setInactiveAsync();
this.toolbar.removeEventListener("mousemove", this);
this.contextMenu.removeEventListener("popuphiding", this);
this.contextMenu.removeEventListener("popupshown", this);
this.contextMenu = null;
break;
}
}
})]]></field>
<method name="_setInactive">
<body><![CDATA[
this.setAttribute("inactive", "true");
]]></body>
</method>
<method name="_setInactiveAsync">
<body><![CDATA[
this._inactiveTimeout = setTimeout(function(self) {
if (self.getAttribute("autohide") == "true") {
self._inactiveTimeout = null;
self._setInactive();
}
}, 0, this);
]]></body>
</method>
<method name="_setActive">
<body><![CDATA[
if (this._inactiveTimeout) {
clearTimeout(this._inactiveTimeout);
this._inactiveTimeout = null;
}
this.removeAttribute("inactive");
]]></body>
</method>
</implementation>
<handlers>
<handler event="DOMMenuBarActive" action="this._setActive();"/>
<handler event="popupshowing" action="this._setActive();"/>
<handler event="mousedown" button="2" action="this._contextMenuListener.init(event);"/>
<handler event="DOMMenuBarInactive"><![CDATA[
if (!this._contextMenuListener.active)
this._setInactiveAsync();
]]></handler>
</handlers>
</binding>
<binding id="toolbar-drag"
extends="chrome://global/content/bindings/toolbar.xml#toolbar">
<implementation>
<field name="_dragBindingAlive">true</field>
<constructor><![CDATA[
if (!this._draggableStarted) {
this._draggableStarted = true;
try {
let tmp = {};
ChromeUtils.import("resource://gre/modules/WindowDraggingUtils.jsm", tmp);
let draggableThis = new tmp.WindowDraggingElement(this);
draggableThis.mouseDownCheck = function(e) {
// Don't move while customizing.
return this._dragBindingAlive &&
this.getAttribute("customizing") != "true";
};
} catch (e) {}
}
]]></constructor>
</implementation>
</binding>
<binding id="menubar"
extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:menubar">
<implementation>
<field name="_active">false</field>
<field name="_statusbar">null</field>
<field name="_originalStatusText">null</field>
<property name="statusbar" onget="return this.getAttribute('statusbar');"
onset="this.setAttribute('statusbar', val); return val;"/>
<method name="_updateStatusText">
<parameter name="itemText"/>
<body>
<![CDATA[
if (!this._active)
return;
var newText = itemText ? itemText : this._originalStatusText;
if (newText != this._statusbar.label)
this._statusbar.label = newText;
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="DOMMenuBarActive">
<![CDATA[
if (!this.statusbar) return;
this._statusbar = document.getElementById(this.statusbar);
if (!this._statusbar)
return;
this._active = true;
this._originalStatusText = this._statusbar.label;
]]>
</handler>
<handler event="DOMMenuBarInactive">
<![CDATA[
if (!this._active)
return;
this._active = false;
this._statusbar.label = this._originalStatusText;
]]>
</handler>
<handler event="DOMMenuItemActive">this._updateStatusText(event.target.statusText);</handler>
<handler event="DOMMenuItemInactive">this._updateStatusText("");</handler>
</handlers>
</binding>
<binding id="toolbardecoration" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
</binding>
<binding id="toolbarpaletteitem" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:button">
<content>
<xul:hbox class="toolbarpaletteitem-box" flex="1" xbl:inherits="type,place">
<children/>
</xul:hbox>
</content>
</binding>
<binding id="toolbarpaletteitem-palette" extends="chrome://global/content/bindings/toolbar.xml#toolbarpaletteitem">
<content>
<xul:hbox class="toolbarpaletteitem-box" xbl:inherits="type,place">
<children/>
</xul:hbox>
<xul:label xbl:inherits="value=title"/>
</content>
</binding>
<binding id="toolbarpaletteitem-palette-wrapping-label" extends="chrome://global/content/bindings/toolbar.xml#toolbarpaletteitem">
<content>
<xul:hbox class="toolbarpaletteitem-box" xbl:inherits="type,place">
<children/>
</xul:hbox>
<xul:label xbl:inherits="xbl:text=title"/>
</content>
</binding>
</bindings>