|
1 <?xml version="1.0"?> |
|
2 <!-- This Source Code Form is subject to the terms of the Mozilla Public |
|
3 - License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
|
5 |
|
6 <!DOCTYPE bindings [ |
|
7 <!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd"> |
|
8 %browserDTD; |
|
9 ]> |
|
10 |
|
11 <bindings |
|
12 xmlns="http://www.mozilla.org/xbl" |
|
13 xmlns:xbl="http://www.mozilla.org/xbl" |
|
14 xmlns:html="http://www.w3.org/1999/xhtml" |
|
15 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
16 |
|
17 <binding id="documenttab"> |
|
18 <content> |
|
19 <xul:stack class="documenttab-container"> |
|
20 <html:canvas anonid="thumbnail-canvas" class="documenttab-thumbnail" /> |
|
21 <xul:image anonid="favicon" class="documenttab-favicon" width="26" height="26"/> |
|
22 |
|
23 <xul:label anonid="title" class="documenttab-title" bottom="0" start="0" end="0" crop="end"/> |
|
24 <xul:box anonid="selection" class="documenttab-crop"/> |
|
25 <xul:box anonid="selection" class="documenttab-selection"/> |
|
26 <xul:button anonid="close" class="documenttab-close" end="0" top="0" |
|
27 onclick="event.stopPropagation(); document.getBindingParent(this)._onClose()" |
|
28 label="&closetab.label;"/> |
|
29 </xul:stack> |
|
30 </content> |
|
31 |
|
32 <handlers> |
|
33 <handler event="click" button="0" clickcount="1" action="this._onClick()"/> |
|
34 <handler event="click" button="1" clickcount="1" action="event.stopPropagation(); this._onClose()"/> |
|
35 <handler event="dblclick" action="this._onDoubleClick(); event.stopPropagation();"/> |
|
36 </handlers> |
|
37 |
|
38 <implementation> |
|
39 <field name="thumbnailCanvas" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "thumbnail-canvas");</field> |
|
40 <field name="_close" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "close");</field> |
|
41 <field name="_title" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "title");</field> |
|
42 <field name="_favicon" readonly="true">document.getAnonymousElementByAttribute(this, "anonid", "favicon");</field> |
|
43 <field name="_container" readonly="true">this.parentNode;</field> |
|
44 |
|
45 <constructor> |
|
46 <![CDATA[ |
|
47 this.thumbnailCanvas.mozOpaque = true; |
|
48 this.thumbnailCanvas.mozImageSmoothingEnabled = true; |
|
49 ]]> |
|
50 </constructor> |
|
51 |
|
52 <method name="_onClick"> |
|
53 <body> |
|
54 <![CDATA[ |
|
55 this._container.selectedTab = this; |
|
56 let selectFn = new Function("event", this._container.parentNode.getAttribute("onselect")); |
|
57 selectFn.call(this); |
|
58 ]]> |
|
59 </body> |
|
60 </method> |
|
61 |
|
62 <method name="_onDoubleClick"> |
|
63 <body> |
|
64 <![CDATA[ |
|
65 this._container.selectedTab = this; |
|
66 let selectFn = new Function("event", this._container.parentNode.getAttribute("ondbltap")); |
|
67 selectFn.call(this); |
|
68 ]]> |
|
69 </body> |
|
70 </method> |
|
71 |
|
72 <method name="_onClose"> |
|
73 <body> |
|
74 <![CDATA[ |
|
75 let callbackFunc = this._container.parentNode.getAttribute("onclosetab"); |
|
76 let closeFn = new Function("event", callbackFunc); |
|
77 closeFn.call(this); |
|
78 ]]> |
|
79 </body> |
|
80 </method> |
|
81 |
|
82 <method name="updateTitle"> |
|
83 <parameter name="title"/> |
|
84 <body> |
|
85 <![CDATA[ |
|
86 this._title.value = title; |
|
87 ]]> |
|
88 </body> |
|
89 </method> |
|
90 |
|
91 <method name="updateFavicon"> |
|
92 <parameter name="src"/> |
|
93 <body> |
|
94 <![CDATA[ |
|
95 this._favicon.src = src; |
|
96 ]]> |
|
97 </body> |
|
98 </method> |
|
99 |
|
100 </implementation> |
|
101 </binding> |
|
102 |
|
103 <binding id="tablist"> |
|
104 <content> |
|
105 <xul:arrowscrollbox anonid="tabs-scrollbox" class="tabs-scrollbox" flex="1" orient="horizontal" |
|
106 clicktoscroll="true" /> |
|
107 </content> |
|
108 |
|
109 <handlers> |
|
110 <handler event="dblclick" action="this._onDoubleClick();"/> |
|
111 </handlers> |
|
112 |
|
113 <implementation implements="nsIDOMEventListener"> |
|
114 <constructor> |
|
115 <![CDATA[ |
|
116 window.addEventListener("MozContextUITabsShow", this, true); |
|
117 ]]> |
|
118 </constructor> |
|
119 |
|
120 <destructor> |
|
121 <![CDATA[ |
|
122 window.removeEventListener("MozContextUITabsShow", this, true); |
|
123 ]]> |
|
124 </destructor> |
|
125 |
|
126 <method name="handleEvent"> |
|
127 <parameter name="event"/> |
|
128 <body> |
|
129 <![CDATA[ |
|
130 switch (event.type) { |
|
131 case "MozContextUITabsShow": |
|
132 this.strip.ensureElementIsVisible(this.selectedTab, false); |
|
133 break; |
|
134 } |
|
135 ]]> |
|
136 </body> |
|
137 </method> |
|
138 |
|
139 <field name="strip">document.getAnonymousElementByAttribute(this, "anonid", "tabs-scrollbox");</field> |
|
140 <field name="_selectedTab">null</field> |
|
141 |
|
142 <!-- Used by the chrome input handler --> |
|
143 <property name="anonScrollBox" |
|
144 readonly="true" |
|
145 onget="return this.strip;"/> |
|
146 |
|
147 <property name="selectedTab" onget="return this._selectedTab;"> |
|
148 <setter> |
|
149 <![CDATA[ |
|
150 if (this._selectedTab) |
|
151 this._selectedTab.removeAttribute("selected"); |
|
152 |
|
153 if (val) |
|
154 val.setAttribute("selected", "true"); |
|
155 |
|
156 this._selectedTab = val; |
|
157 this.strip.ensureElementIsVisible(val); |
|
158 ]]> |
|
159 </setter> |
|
160 </property> |
|
161 |
|
162 <method name="addTab"> |
|
163 <parameter name="aIndex"/> |
|
164 <body> |
|
165 <![CDATA[ |
|
166 let tab = document.createElement("documenttab"); |
|
167 if (aIndex >= 0) { |
|
168 let child = this.strip.children[aIndex]; |
|
169 this.strip.insertBefore(tab, child); |
|
170 } else { |
|
171 this.strip.appendChild(tab); |
|
172 } |
|
173 return tab; |
|
174 ]]> |
|
175 </body> |
|
176 </method> |
|
177 |
|
178 <method name="removeTab"> |
|
179 <parameter name="aTab"/> |
|
180 <body> |
|
181 <![CDATA[ |
|
182 this.strip.removeChild(aTab); |
|
183 ]]> |
|
184 </body> |
|
185 </method> |
|
186 |
|
187 <method name="_onDoubleTap"> |
|
188 <body> |
|
189 <![CDATA[ |
|
190 new Function("event", this.getAttribute("ondoubletap")).call(); |
|
191 ]]> |
|
192 </body> |
|
193 </method> |
|
194 |
|
195 <method name="_onDoubleClick"> |
|
196 <body> |
|
197 <![CDATA[ |
|
198 // ignore mouse events if we're interacting with touch input |
|
199 if (!InputSourceHelper.isPrecise) |
|
200 return; |
|
201 new Function("event", this.getAttribute("ondoubletap")).call(); |
|
202 ]]> |
|
203 </body> |
|
204 </method> |
|
205 |
|
206 </implementation> |
|
207 </binding> |
|
208 </bindings> |