gecko/mobile/chrome/content/tabs.xml
Michael Wu 04e6585203 Bug 549431, remove DOCTYPE line from tabs.xml, r=mfinkle
--HG--
extra : rebase_source : 4f0c0fd2540fe4ec5c34d53ebf9b822822377c0a
2010-03-01 14:31:41 -08:00

148 lines
4.4 KiB
XML

<?xml version="1.0"?>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="documenttab">
<content>
<xul:stack anonid="page" class="documenttab-container" flex="1">
<html:canvas anonid="canvas" class="documenttab-canvas" left="8" width="106" height="64" moz-opaque="true"
onclick="document.getBindingParent(this)._onClick()"/>
<xul:hbox left="0" top="10" height="64" width="55" align="center" onclick="document.getBindingParent(this)._close()">
<xul:image anonid="close" class="documenttab-close" mousethrough="always"/>
</xul:hbox>
</xul:stack>
</content>
<implementation>
<method name="_onClick">
<body>
<![CDATA[
this.parentNode.selectedTab = this;
let selectFn = new Function("event", this.parentNode.getAttribute('onselect'));
selectFn.call(this);
]]>
</body>
</method>
<method name="_close">
<body>
<![CDATA[
let closeFn = new Function("event", this.parentNode.getAttribute('onclosetab'));
closeFn.call(this);
]]>
</body>
</method>
<method name="updateThumbnail">
<parameter name="browser"/>
<parameter name="browserView"/>
<body>
<![CDATA[
const tabWidth = 106;
const tabHeight = 64;
let destCanvas = document.getAnonymousElementByAttribute(this, "anonid", "canvas");
if (browserView) {
browserView.renderToCanvas(destCanvas, tabWidth, tabHeight);
} else {
let domWin = browser.contentWindow;
let ctx = destCanvas.getContext("2d");
let width = domWin.innerWidth;
let height = domWin.innerHeight;
ctx.clearRect(0, 0, tabWidth, tabHeight);
ctx.save();
ctx.scale(tabWidth / width, tabHeight / height);
ctx.drawWindow(domWin, 0, 0, width, height, "white");
ctx.restore();
}
]]>
</body>
</method>
</implementation>
</binding>
<binding id="tablist">
<implementation>
<field name="_selectedTab">null</field>
<property name="selectedTab">
<getter>
<![CDATA[
return this._selectedTab;
]]>
</getter>
<setter>
<![CDATA[
if (this._selectedTab)
this._selectedTab.removeAttribute('selected');
if (val)
val.setAttribute('selected', 'true');
this._selectedTab = val;
]]>
</setter>
</property>
<method name="addTab">
<body>
<![CDATA[
let tab = document.createElement("box");
tab.setAttribute("type", "documenttab");
this.appendChild(tab);
this._updateWidth();
return tab;
]]>
</body>
</method>
<method name="removeTab">
<parameter name="aTab"/>
<body>
<![CDATA[
this.removeChild(aTab);
this._updateWidth();
]]>
</body>
</method>
<method name="resize">
<body>
<![CDATA[
let container = this.parentNode.getBoundingClientRect();
let element = this.getBoundingClientRect();
let height = (element.top - container.top) +
((container.top + container.height) - (element.top + element.height));
this.style.height = height + "px";
this._updateWidth();
]]>
</body>
</method>
<field name="_columnsCount">1</field>
<method name="_updateWidth">
<body>
<![CDATA[
let boundingBox = this.firstChild.getBoundingClientRect();
let columnsCount = Math.ceil(this.childNodes.length / Math.floor(this.style.height / boundingBox.height));
if (this._columnsCount != columnsCount) {
this.style.width = (this.lastChild.boxObject.x + boundingBox.width) + "px";
this._columnsCount = columnsCount;
}
]]>
</body>
</method>
</implementation>
</binding>
</bindings>