gecko/browser/metro/base/content/bindings/selectionoverlay.xml

155 lines
5.1 KiB
XML

<?xml version="1.0"?>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<binding id="selection-binding">
<content>
<html:div flex="1" class="selection-overlay-inner window-width window-height" anonid="selection-overlay-inner">
<xul:stack>
<html:div anonid="selection-overlay-debug" class="window-width window-height"/>
<xul:toolbarbutton id="selectionhandle-mark1" label="^" left="10" top="10" hidden="true"/>
<xul:toolbarbutton id="selectionhandle-mark2" label="^" left="10" top="10" hidden="true"/>
<xul:toolbarbutton id="selectionhandle-mark3" label="^" left="10" top="10" hidden="true"/>
</xul:stack>
</html:div>
</content>
<implementation implements="nsIDOMEventListener">
<constructor>
<![CDATA[
this._selectionOverlay.addEventListener('contextmenu', this);
]]>
</constructor>
<destructor>
<![CDATA[
this._selectionOverlay.removeEventListener('contextmenu', this);
]]>
</destructor>
<field name="_selectionOverlay" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "selection-overlay-inner").parentNode;</field>
<field name="_selectionDebugOverlay" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "selection-overlay-debug");</field>
<property name="enabled">
<setter>
<![CDATA[
if (val) {
this._selectionOverlay.setAttribute("class", "selection-overlay window-width window-height");
} else {
this._selectionOverlay.setAttribute("class", "selection-overlay-hidden");
while(this._selectionDebugOverlay.hasChildNodes()) this._selectionDebugOverlay.removeChild(this._selectionDebugOverlay.firstChild);
}
return val;
]]>
</setter>
<getter>
<![CDATA[
return (this._selectionOverlay.getAttribute("class") == "selection-overlay");
]]>
</getter>
</property>
<property name="displayDebugLayer">
<setter>
<![CDATA[
if (val) {
this._selectionDebugOverlay.style.display = "block";
this._debugLayerVisible = true;
} else {
this._selectionDebugOverlay.style.display = "none";
this._debugLayerVisible = false;
}
return this._debugLayerVisible;
]]>
</setter>
<getter>
<![CDATA[
if (this._debugLayerVisible == "undefined")
this._debugLayerVisible = false;
return this._debugLayerVisible;
]]>
</getter>
</property>
<method name="init">
<body>
<![CDATA[
this.enabled = true;
]]>
</body>
</method>
<method name="shutdown">
<body>
<![CDATA[
this.enabled = false;
]]>
</body>
</method>
<method name="_onContextMenu">
<parameter name="aEvent"/>
<body>
<![CDATA[
// forward this over. frame script will treat this like
// a bubbling contextmenu event.
Browser.selectedTab.browser.messageManager.sendAsyncMessage("Browser:InvokeContextAtPoint", {
xPos: aEvent.clientX, yPos: aEvent.clientY });
]]>
</body>
</method>
<method name="handleEvent">
<parameter name="aEvent"/>
<body>
<![CDATA[
switch (aEvent.type) {
case 'contextmenu':
this._onContextMenu(aEvent);
break;
}
]]>
</body>
</method>
<method name="addDebugRect">
<parameter name="aLeft"/>
<parameter name="aTop"/>
<parameter name="aRight"/>
<parameter name="aBottom"/>
<parameter name="aColor"/>
<parameter name="aFill"/>
<parameter name="aId"/>
<body>
<![CDATA[
let e = document.createElement("div");
this._selectionDebugOverlay.appendChild(e);
e.style.position = "fixed";
e.style.left = aLeft +"px";
e.style.top = aTop +"px";
e.style.right = aRight +"px";
e.style.bottom = aBottom +"px";
e.style.maxWidth = (aRight - aLeft) +"px";
e.style.width = (aRight - aLeft) +"px";
e.style.maxHeight = (aBottom - aTop) +"px";
e.style.height = (aBottom - aTop) +"px";
if (aFill == undefined) {
e.style.backgroundColor = aColor;
} else {
if (aFill) {
e.style.backgroundColor = aColor;
} else {
e.style.border = "2px solid " + aColor;
}
}
e.style.opacity = "0.5";
]]>
</body>
</method>
</implementation>
</binding>
</bindings>