/
tabutils.xml
243 lines (212 loc) · 9.7 KB
/
tabutils.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
%browserDTD;
]>
<bindings id="tabutils-bindings"
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="arrowscrollbox" extends="chrome://browser/content/tabbrowser.xml#tabbrowser-arrowscrollbox">
<content>
<xul:hbox id="PinnedTabsBar" anonid="pinnedbox" flex="0"
type="places"
place="place:folder=-1"
context="placesContext"
onclick="if (event.button != 0) return;var node = event.target._placesNode;if (node) if (PlacesUtils.nodeIsURI(node)) gBrowser.selectedTab = event.target.tab || gBrowser.addTab(node.uri);"
onpopupshowing="BookmarksEventHandler.onPopupShowing(event);"
tooltip="bhTooltip" popupsinherittooltip="true">
<xul:hbox>
<xul:hbox align="center">
<xul:image id="PinnedTabsBarDropIndicator"
mousethrough="always"
collapsed="true"/>
</xul:hbox>
<xul:scrollbox id="PinnedTabsBarItems" orient="horizontal"/>
<xul:toolbarbutton id="PinnedTabsBarChevron"
type="menu"
class="chevron"
mousethrough="never"
collapsed="true"
tooltiptext="&bookmarksToolbarChevron.tooltip;"
onpopupshowing="this.parentNode.parentNode._placesView._onChevronPopupShowing(event);event.stopPropagation();">
<xul:menupopup id="PinnedTabsBarChevronPopup"
placespopup="true"
tooltip="bhTooltip" popupsinherittooltip="true"
context="placesContext"/>
</xul:toolbarbutton>
</xul:hbox>
</xul:hbox>
<xul:toolbarbutton class="scrollbutton-up"
xbl:inherits="orient,collapsed=notoverflowing,disabled=scrolledtostart"
anonid="scrollbutton-up"
onclick="_distanceScroll(event);"
onmousedown="if (event.button == 0) _startScroll(-1);"
onmouseup="if (event.button == 0) _stopScroll();"
onmouseover="_continueScroll(-1);"
onmouseout="_pauseScroll();"
chromedir="&locale.dir;"/>
<xul:spacer class="arrowscrollbox-overflow-start-indicator"
xbl:inherits="collapsed=scrolledtostart"/>
<xul:scrollbox class="arrowscrollbox-scrollbox"
anonid="scrollbox"
flex="1"
xbl:inherits="orient,align,pack,dir">
<children/>
</xul:scrollbox>
<xul:spacer class="arrowscrollbox-overflow-end-indicator"
xbl:inherits="collapsed=scrolledtoend"/>
<xul:toolbarbutton class="scrollbutton-down"
xbl:inherits="orient,collapsed=notoverflowing,disabled=scrolledtoend"
anonid="scrollbutton-down"
onclick="_distanceScroll(event);"
onmousedown="if (event.button == 0) _startScroll(1);"
onmouseup="if (event.button == 0) _stopScroll();"
onmouseover="_continueScroll(1);"
onmouseout="_pauseScroll();"
chromedir="&locale.dir;"/>
</content>
<implementation>
<constructor>
<![CDATA[
this.setAttribute("notoverflowing", "true");
this._updateScrollButtonsDisabledState();
PinnedTabsBar = TU_hookFunc(PlacesToolbar,
["PlacesToolbar", "PinnedTabsBar", "g"],
["PlacesChevron", "PinnedTabsBarChevron", "g"]
);
PinnedTabsBar.prototype.__proto__ = PlacesToolbar.prototype;
TU_hookCode("PinnedTabsBar.prototype._insertNewItem", /.*button.className.*/, function() {
button.className = "tabbrowser-tab";
button.setAttribute("faviconized", true);
button.setAttribute("pinned", true);
button.setAttribute("style", "position: static !important; height: auto !important;");
button.setAttribute("context", "placesContext");
});
TU_hookCode("PinnedTabsBar.prototype._rebuild", "}", "gBrowser.mTabContainer.positionPinnedTabs(true);");
["nodeInserted", "nodeRemoved", "nodeMoved"].forEach(function(aMethod) {
TU_hookCode.call(PinnedTabsBar.prototype, aMethod,
[/.*_removeChild\((.*)\).*/, "var tab = $1.tab;$&"],
["this.updateChevron();", "$&;var tab;if (tab) gBrowser.mTabContainer.positionPinnedTab(tab);gBrowser.mTabContainer.positionPinnedTabs();"]
);
});
TU_hookSetter("PlacesViewBase.prototype.place", /.*executeQueries[\s\S]*addObserver.*/, "try {$&} catch (e) {}"); //Fx 4.0
let pinnedbox = this._pinnedbox;
pinnedbox._selectNewTab = function() {};
pinnedbox.advanceSelectedTab = function() {};
pinnedbox.__defineGetter__("place", function() {
let view = this.parentNode.parentNode._placesView;
if (view)
return view.place;
});
pinnedbox.__defineSetter__("place", function(val) {
let view = this.parentNode.parentNode._placesView;
if (view)
view.uninit();
new PinnedTabsBar(val);
return val;
});
setTimeout(function() {
gBrowser.updatePinnedTabsBar();
}, 0);
]]>
</constructor>
<field name="_pinnedbox">
document.getElementById("PinnedTabsBarItems")
</field>
<method name="_canScrollToElement">
<parameter name="tab"/>
<body><![CDATA[
return !tab.pinned && !tab.hidden && !tab.collapsed;
]]></body>
</method>
</implementation>
<handlers>
<handler event="underflow"><![CDATA[
if (event.detail ^ this.orient == "vertical")
document.getBindingParent(this).removeAttribute("overflow");
]]></handler>
<handler event="overflow"><![CDATA[
if (event.detail ^ this.orient == "vertical")
document.getBindingParent(this).setAttribute("overflow", "true");
]]></handler>
</handlers>
</binding>
<binding id="tabbrowser-tab" display="xul:button" extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tab">
<handlers>
<handler event="mousedown" button="0" phase="capturing">
<![CDATA[
if (!this.parentNode._selectNewTab) {
this.parentNode._selectNewTab = function() {};
}
]]>
</handler>
</handlers>
</binding>
<binding id="tab-content">
<content>
<xul:image class="tab-twisty" style="pointer-events: auto;"
role="presentation"/>
<children includes="image"/>
<children includes="label"/>
<xul:label xbl:inherits="value=group-counter"
class="tab-text tab-counter"
role="presentation"/>
<children/>
</content>
</binding>
<binding id="tab-twisty">
<handlers>
<handler event="click" button="0"><![CDATA[
let bindingParent = document.getBindingParent(this);
let tab = document.getBindingParent(bindingParent);
gBrowser.collapseStack(tab);
event.stopPropagation();
]]></handler>
<handler event="dblclick" button="0"><![CDATA[
event.stopPropagation();
]]></handler>
<handler event="mousedown" button="0"><![CDATA[
event.stopPropagation();
]]></handler>
<handler event="mouseover"><![CDATA[
let bindingParent = document.getBindingParent(this);
let tab = document.getBindingParent(bindingParent);
tab.mOverTwisty = gBrowser.isStackedTab(tab);
]]></handler>
<handler event="mouseout"><![CDATA[
let bindingParent = document.getBindingParent(this);
let tab = document.getBindingParent(bindingParent);
tab.mOverTwisty = false;
]]></handler>
</handlers>
</binding>
<binding id="browser" extends="chrome://global/content/bindings/browser.xml#browser">
<implementation>
<field name="droppedLinkHandler">handleDroppedLink</field>
</implementation>
<handlers>
<handler event="dragover" group="system">
<![CDATA[
if (!this.droppedLinkHandler || event.defaultPrevented)
return;
// For drags that appear to be internal text (for example, tab drags),
// set the dropEffect to 'none'. This prevents the drop even if some
// other listener cancelled the event.
var types = event.dataTransfer.types;
if (types.contains("text/x-moz-text-internal") && !types.contains("text/plain")) {
event.dataTransfer.dropEffect = "none";
event.stopPropagation();
event.preventDefault();
}
let linkHandler = Components.classes["@mozilla.org/content/dropped-link-handler;1"].
getService(Components.interfaces.nsIDroppedLinkHandler);
if (linkHandler.canDropLink(event, TU_getPref("extensions.tabutils.dragAndGo", true)))
event.preventDefault();
]]>
</handler>
</handlers>
</binding>
</bindings>