1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/metro/base/content/bindings/tabs.xml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,208 @@ 1.4 +<?xml version="1.0"?> 1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.6 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.8 + 1.9 +<!DOCTYPE bindings [ 1.10 +<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd"> 1.11 +%browserDTD; 1.12 +]> 1.13 + 1.14 +<bindings 1.15 + xmlns="http://www.mozilla.org/xbl" 1.16 + xmlns:xbl="http://www.mozilla.org/xbl" 1.17 + xmlns:html="http://www.w3.org/1999/xhtml" 1.18 + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.19 + 1.20 + <binding id="documenttab"> 1.21 + <content> 1.22 + <xul:stack class="documenttab-container"> 1.23 + <html:canvas anonid="thumbnail-canvas" class="documenttab-thumbnail" /> 1.24 + <xul:image anonid="favicon" class="documenttab-favicon" width="26" height="26"/> 1.25 + 1.26 + <xul:label anonid="title" class="documenttab-title" bottom="0" start="0" end="0" crop="end"/> 1.27 + <xul:box anonid="selection" class="documenttab-crop"/> 1.28 + <xul:box anonid="selection" class="documenttab-selection"/> 1.29 + <xul:button anonid="close" class="documenttab-close" end="0" top="0" 1.30 + onclick="event.stopPropagation(); document.getBindingParent(this)._onClose()" 1.31 + label="&closetab.label;"/> 1.32 + </xul:stack> 1.33 + </content> 1.34 + 1.35 + <handlers> 1.36 + <handler event="click" button="0" clickcount="1" action="this._onClick()"/> 1.37 + <handler event="click" button="1" clickcount="1" action="event.stopPropagation(); this._onClose()"/> 1.38 + <handler event="dblclick" action="this._onDoubleClick(); event.stopPropagation();"/> 1.39 + </handlers> 1.40 + 1.41 + <implementation> 1.42 + <field name="thumbnailCanvas" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "thumbnail-canvas");</field> 1.43 + <field name="_close" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "close");</field> 1.44 + <field name="_title" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "title");</field> 1.45 + <field name="_favicon" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "favicon");</field> 1.46 + <field name="_container" readonly="true">this.parentNode;</field> 1.47 + 1.48 + <constructor> 1.49 + <![CDATA[ 1.50 + this.thumbnailCanvas.mozOpaque = true; 1.51 + this.thumbnailCanvas.mozImageSmoothingEnabled = true; 1.52 + ]]> 1.53 + </constructor> 1.54 + 1.55 + <method name="_onClick"> 1.56 + <body> 1.57 + <![CDATA[ 1.58 + this._container.selectedTab = this; 1.59 + let selectFn = new Function("event", this._container.parentNode.getAttribute("onselect")); 1.60 + selectFn.call(this); 1.61 + ]]> 1.62 + </body> 1.63 + </method> 1.64 + 1.65 + <method name="_onDoubleClick"> 1.66 + <body> 1.67 + <![CDATA[ 1.68 + this._container.selectedTab = this; 1.69 + let selectFn = new Function("event", this._container.parentNode.getAttribute("ondbltap")); 1.70 + selectFn.call(this); 1.71 + ]]> 1.72 + </body> 1.73 + </method> 1.74 + 1.75 + <method name="_onClose"> 1.76 + <body> 1.77 + <![CDATA[ 1.78 + let callbackFunc = this._container.parentNode.getAttribute("onclosetab"); 1.79 + let closeFn = new Function("event", callbackFunc); 1.80 + closeFn.call(this); 1.81 + ]]> 1.82 + </body> 1.83 + </method> 1.84 + 1.85 + <method name="updateTitle"> 1.86 + <parameter name="title"/> 1.87 + <body> 1.88 + <![CDATA[ 1.89 + this._title.value = title; 1.90 + ]]> 1.91 + </body> 1.92 + </method> 1.93 + 1.94 + <method name="updateFavicon"> 1.95 + <parameter name="src"/> 1.96 + <body> 1.97 + <![CDATA[ 1.98 + this._favicon.src = src; 1.99 + ]]> 1.100 + </body> 1.101 + </method> 1.102 + 1.103 + </implementation> 1.104 + </binding> 1.105 + 1.106 + <binding id="tablist"> 1.107 + <content> 1.108 + <xul:arrowscrollbox anonid="tabs-scrollbox" class="tabs-scrollbox" flex="1" orient="horizontal" 1.109 + clicktoscroll="true" /> 1.110 + </content> 1.111 + 1.112 + <handlers> 1.113 + <handler event="dblclick" action="this._onDoubleClick();"/> 1.114 + </handlers> 1.115 + 1.116 + <implementation implements="nsIDOMEventListener"> 1.117 + <constructor> 1.118 + <![CDATA[ 1.119 + window.addEventListener("MozContextUITabsShow", this, true); 1.120 + ]]> 1.121 + </constructor> 1.122 + 1.123 + <destructor> 1.124 + <![CDATA[ 1.125 + window.removeEventListener("MozContextUITabsShow", this, true); 1.126 + ]]> 1.127 + </destructor> 1.128 + 1.129 + <method name="handleEvent"> 1.130 + <parameter name="event"/> 1.131 + <body> 1.132 + <![CDATA[ 1.133 + switch (event.type) { 1.134 + case "MozContextUITabsShow": 1.135 + this.strip.ensureElementIsVisible(this.selectedTab, false); 1.136 + break; 1.137 + } 1.138 + ]]> 1.139 + </body> 1.140 + </method> 1.141 + 1.142 + <field name="strip">document.getAnonymousElementByAttribute(this, "anonid", "tabs-scrollbox");</field> 1.143 + <field name="_selectedTab">null</field> 1.144 + 1.145 + <!-- Used by the chrome input handler --> 1.146 + <property name="anonScrollBox" 1.147 + readonly="true" 1.148 + onget="return this.strip;"/> 1.149 + 1.150 + <property name="selectedTab" onget="return this._selectedTab;"> 1.151 + <setter> 1.152 + <![CDATA[ 1.153 + if (this._selectedTab) 1.154 + this._selectedTab.removeAttribute("selected"); 1.155 + 1.156 + if (val) 1.157 + val.setAttribute("selected", "true"); 1.158 + 1.159 + this._selectedTab = val; 1.160 + this.strip.ensureElementIsVisible(val); 1.161 + ]]> 1.162 + </setter> 1.163 + </property> 1.164 + 1.165 + <method name="addTab"> 1.166 + <parameter name="aIndex"/> 1.167 + <body> 1.168 + <![CDATA[ 1.169 + let tab = document.createElement("documenttab"); 1.170 + if (aIndex >= 0) { 1.171 + let child = this.strip.children[aIndex]; 1.172 + this.strip.insertBefore(tab, child); 1.173 + } else { 1.174 + this.strip.appendChild(tab); 1.175 + } 1.176 + return tab; 1.177 + ]]> 1.178 + </body> 1.179 + </method> 1.180 + 1.181 + <method name="removeTab"> 1.182 + <parameter name="aTab"/> 1.183 + <body> 1.184 + <![CDATA[ 1.185 + this.strip.removeChild(aTab); 1.186 + ]]> 1.187 + </body> 1.188 + </method> 1.189 + 1.190 + <method name="_onDoubleTap"> 1.191 + <body> 1.192 + <![CDATA[ 1.193 + new Function("event", this.getAttribute("ondoubletap")).call(); 1.194 + ]]> 1.195 + </body> 1.196 + </method> 1.197 + 1.198 + <method name="_onDoubleClick"> 1.199 + <body> 1.200 + <![CDATA[ 1.201 + // ignore mouse events if we're interacting with touch input 1.202 + if (!InputSourceHelper.isPrecise) 1.203 + return; 1.204 + new Function("event", this.getAttribute("ondoubletap")).call(); 1.205 + ]]> 1.206 + </body> 1.207 + </method> 1.208 + 1.209 + </implementation> 1.210 + </binding> 1.211 +</bindings>