!import
(10 calls, 1364 incl. v-uS, 342 excl. v-uS)
Called: XULElement:QueryInterface (5 calls, 143 v-uS)
XULElement:boxObject (5 calls, 118 v-uS)
nsXPCComponents:interfaces (5 calls, 74 v-uS)
tree.xml:!import (5 calls, 585 v-uS)
BoxObject:view (3 calls, 39 v-uS)
TreeSelection:currentIndex (1 calls, 9 v-uS)
XPCWrappedNative_NoHelper:selection (1 calls, 13 v-uS)
XULElement:getAttribute (1 calls, 38 v-uS)
Called By: tree.xml:!import (5 calls, 585 v-uS)
tree.xml:onfocus (2 calls, 477 v-uS)
msgMail3PaneWindow.js:SetNextMessageAfterDelete (1 calls, 134 v-uS)
tree.xml:get__cellSelType (1 calls, 53 v-uS)
tree.xml:onblur (1 calls, 113 v-uS)
1 <?xml version="1.0"?>
2
3 <!DOCTYPE bindings SYSTEM "chrome://global/locale/tree.dtd">
4
5 <bindings id="treeBindings"
6 xmlns="http://www.mozilla.org/xbl"
7 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
8 xmlns:xbl="http://www.mozilla.org/xbl">
9
10 <binding id="tree-base" extends="chrome://global/content/bindings/general.xml#basecontrol">
11 <resources>
12 <stylesheet src="chrome://global/skin/tree.css"/>
13 </resources>
14 <implementation>
15 <method name="_isAccelPressed">
16 <parameter name="aEvent"/>
_isAccelPressed
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
17 <body><![CDATA[
18 return aEvent.metaKey;
19 ]]></body>
20 </method>
21 </implementation>
22 </binding>
23
24 <binding id="tree" extends="chrome://global/content/bindings/tree.xml#tree-base">
25 <content hidevscroll="true" hidehscroll="true">
26 <children includes="treecols"/>
27 <xul:stack class="tree-stack" flex="1">
28 <xul:treerows class="tree-rows" flex="1" xbl:inherits="hidevscroll">
29 <children/>
30 </xul:treerows>
31 <xul:textbox anonid="input" class="tree-input" left="0" top="0" hidden="true"/>
32 </xul:stack>
33 <xul:hbox xbl:inherits="collapsed=hidehscroll">
34 <xul:scrollbar orient="horizontal" flex="1" increment="16"/>
35 <xul:scrollcorner xbl:inherits="collapsed=hidevscroll"/>
36 </xul:hbox>
37 </content>
38
39 <implementation implements="nsIDOMXULTreeElement, nsIDOMXULMultiSelectControlElement, nsIAccessibleProvider">
40
41 <!-- ///////////////// nsIDOMXULTreeElement ///////////////// -->
42
get_columns
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
43 <property name="columns"
44 onget="return this.treeBoxObject.columns;"/>
45
get_view
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_view
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
46 <property name="view"
47 onget="return this.treeBoxObject.view;"
48 onset="return this.treeBoxObject.view = val;"/>
49
get_body
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
50 <property name="body"
51 onget="return this.treeBoxObject.treeBody;"/>
52
get_editable
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_editable
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
53 <property name="editable"
54 onget="return this.getAttribute('editable') == 'true';"
55 onset="if (val) this.setAttribute('editable', 'true');
56 else this.removeAttribute('editable'); return val;"/>
57
58 <!-- ///////////////// nsIDOMXULSelectControlElement ///////////////// -->
59
60 <!-- ///////////////// nsIDOMXULMultiSelectControlElement ///////////////// -->
61
get_selType
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_selType
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
62 <property name="selType"
63 onget="return this.getAttribute('seltype')"
64 onset="this.setAttribute('seltype', val); return val;"/>
65
get_currentIndex
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_currentIndex
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
66 <property name="currentIndex"
67 onget="return this.view ? this.view.selection.currentIndex: - 1;"
68 onset="if (this.view) return this.view.selection.currentIndex = val; return val;"/>
69
70 <!-- ///////////////// nsIAccessibleProvider ///////////////// -->
71
72 <property name="accessibleType" readonly="true">
get_accessibleType
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
73 <getter>
74 <![CDATA[
75 return Components.interfaces.nsIAccessibleProvider.XULTree;
76 ]]>
77 </getter>
78 </property>
79
get_treeBoxObject
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
80 <property name="treeBoxObject"
81 onget="return this.boxObject.QueryInterface(Components.interfaces.nsITreeBoxObject);"
82 readonly="true"/>
get_contentView
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
83 <property name="contentView"
84 onget="return this.view; /*.QueryInterface(Components.interfaces.nsITreeContentView)*/"
85 readonly="true"/>
get_builderView
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
86 <property name="builderView"
87 onget="return this.view; /*.QueryInterface(Components.interfaces.nsIXULTreeBuilder)*/"
88 readonly="true"/>
field_pageUpOrDownMovesSelection
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
89 <field name="pageUpOrDownMovesSelection">
90 false
91 </field>
get_enableColumnDrag
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_enableColumnDrag
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
92 <property name="enableColumnDrag"
93 onget="return this.hasAttribute('enableColumnDrag');"
94 onset="if (val) this.setAttribute('enableColumnDrag', 'true');
95 else this.removeAttribute('enableColumnDrag'); return val;"/>
96
field__inputField
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
97 <field name="_inputField">null</field>
98
99 <property name="inputField" readonly="true">
get_inputField
(1 calls, 8 incl. v-uS, 8 excl. v-uS)
Called By: tree.xml:onblur (1 calls, 8 v-uS)
100 <getter><![CDATA[
101 if (!this._inputField)
102 this._inputField = document.getAnonymousElementByAttribute(this, "anonid", "input");
103 return this._inputField;
104 ]]></getter>
105 </property>
106
get_disableKeyNavigation
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set_disableKeyNavigation
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
107 <property name="disableKeyNavigation"
108 onget="return this.hasAttribute('disableKeyNavigation');"
109 onset="if (val) this.setAttribute('disableKeyNavigation', 'true');
110 else this.removeAttribute('disableKeyNavigation'); return val;"/>
111
field__editingRow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
112 <field name="_editingRow">-1</field>
field__editingColumn
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
113 <field name="_editingColumn">null</field>
114
get_editingRow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
115 <property name="editingRow" readonly="true"
116 onget="return this._editingRow;"/>
get_editingColumn
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
117 <property name="editingColumn" readonly="true"
118 onget="return this._editingColumn;"/>
119
get__selectDelay
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
set__selectDelay
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
120 <property name="_selectDelay"
121 onset="this.setAttribute('_selectDelay', val);"
122 onget="return this.getAttribute('_selectDelay') || 50;"/>
field__columnsDirty
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
123 <field name="_columnsDirty">true</field>
field__lastKeyTime
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
124 <field name="_lastKeyTime">0</field>
field__incrementalString
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
125 <field name="_incrementalString">""</field>
126
127 <method name="_ensureColumnOrder">
_ensureColumnOrder
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
128 <body><![CDATA[
129 if (!this._columnsDirty)
130 return;
131
132 if (this.columns) {
133 // update the ordinal position of each column to assure that it is
134 // an odd number and 2 positions above its next sibling
135 var cols = [];
136 var i;
137 for (var col = this.columns.getFirstColumn(); col; col = col.getNext())
138 cols.push(col.element);
139 for (i = 0; i < cols.length; ++i)
140 cols[i].setAttribute("ordinal", (i*2)+1);
141
142 // update the ordinal positions of splitters to even numbers, so that
143 // they are in between columns
144 var splitters = this.getElementsByTagName("splitter");
145 for (i = 0; i < splitters.length; ++i)
146 splitters[i].setAttribute("ordinal", (i+1)*2);
147 }
148 this._columnsDirty = false;
149 ]]></body>
150 </method>
151
152 <method name="_reorderColumn">
153 <parameter name="aColMove"/>
154 <parameter name="aColBefore"/>
155 <parameter name="aBefore"/>
_reorderColumn
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
156 <body><![CDATA[
157 this._ensureColumnOrder();
158
159 var i;
160 var cols = [];
161 var col = this.columns.getColumnFor(aColBefore);
162 if (parseInt(aColBefore.ordinal) < parseInt(aColMove.ordinal)) {
163 if (aBefore)
164 cols.push(aColBefore);
165 for (col = col.getNext(); col.element != aColMove;
166 col = col.getNext())
167 cols.push(col.element);
168
169 aColMove.ordinal = cols[0].ordinal;
170 for (i = 0; i < cols.length; ++i)
171 cols[i].ordinal = parseInt(cols[i].ordinal) + 2;
172 } else if (aColBefore.ordinal != aColMove.ordinal) {
173 if (!aBefore)
174 cols.push(aColBefore);
175 for (col = col.getPrevious(); col.element != aColMove;
176 col = col.getPrevious())
177 cols.push(col.element);
178
179 aColMove.ordinal = cols[0].ordinal;
180 for (i = 0; i < cols.length; ++i)
181 cols[i].ordinal = parseInt(cols[i].ordinal) - 2;
182 }
183 ]]></body>
184 </method>
185
186 <method name="_getColumnAtX">
187 <parameter name="aX"/>
188 <parameter name="aThresh"/>
189 <parameter name="aPos"/>
_getColumnAtX
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
190 <body><![CDATA[
191 if (aPos) aPos.value = "before";
192
193 var col = this.columns.getFirstColumn();
194 var lastCol = null;
195 var currentX = this.boxObject.x;
196 while (col) {
197 var cw = col.element.boxObject.width;
198 if (cw > 0) {
199 currentX += cw;
200 if (currentX - (cw * aThresh) > aX)
201 return col.element;
202 }
203 lastCol = col;
204 col = col.getNext();
205 }
206
207 if (aPos) aPos.value = "after";
208 return lastCol.element;
209 ]]></body>
210 </method>
211
212 <method name="changeOpenState">
213 <parameter name="row"/>
214 <!-- Optional parameter openState == true or false to set.
215 No openState param == toggle -->
216 <parameter name="openState"/>
changeOpenState
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
217 <body><![CDATA[
218 if (row < 0 || !this.view.isContainer(row)) {
219 return false;
220 }
221 if (this.view.isContainerOpen(row) != openState) {
222 this.view.toggleOpenState(row);
223 if (row == this.currentIndex) {
224 // Only fire event when current row is expanded or collapsed
225 // because that's all the assistive technology really cares about.
226 var event = document.createEvent('Events');
227 event.initEvent('OpenStateChange', true, true);
228 this.dispatchEvent(event);
229 }
230 return true;
231 }
232 return false;
233 ]]></body>
234 </method>
235
236 <property name="_cellSelType">
get__cellSelType
(1 calls, 84 incl. v-uS, 30 excl. v-uS)
Called: tree.xml:!import (1 calls, 53 v-uS)
Called By: tree.xml:onfocus (1 calls, 84 v-uS)
237 <getter>
238 <![CDATA[
239 var seltype = this.selType;
240 if (seltype == "cell" || seltype == "text")
241 return seltype;
242 return null;
243 ]]>
244 </getter>
245 </property>
246
247 <method name="_getNextColumn">
248 <parameter name="row"/>
249 <parameter name="left"/>
_getNextColumn
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
250 <body><![CDATA[
251 var col = this.view.selection.currentColumn;
252 if (col) {
253 col = left ? col.getPrevious() : col.getNext();
254 }
255 else {
256 col = this.columns.getKeyColumn();
257 }
258 while (col && (col.width == 0 || !col.selectable ||
259 !this.view.isSelectable(row, col)))
260 col = left ? col.getPrevious() : col.getNext();
261 return col;
262 ]]></body>
263 </method>
264
265 <method name="_keyNavigate">
266 <parameter name="event"/>
_keyNavigate
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
267 <body><![CDATA[
268 var key = String.fromCharCode(event.charCode).toLowerCase();
269 if (event.timeStamp - this._lastKeyTime > 1000)
270 this._incrementalString = key;
271 else
272 this._incrementalString += key;
273 this._lastKeyTime = event.timeStamp;
274
275 var length = this._incrementalString.length;
276 var incrementalString = this._incrementalString;
277 var charIndex = 1;
278 while (charIndex < length && incrementalString[charIndex] == incrementalString[charIndex - 1])
279 charIndex++;
280 // If all letters in incremental string are same, just try to match the first one
281 if (charIndex == length) {
282 length = 1;
283 incrementalString = incrementalString.substring(0, length);
284 }
285
286 var keyCol = this.columns.getKeyColumn();
287 var rowCount = this.view.rowCount;
288 var start = 1;
289
290 var c = this.currentIndex;
291 if (length > 1) {
292 start = 0;
293 if (c < 0)
294 c = 0;
295 }
296
297 for (var i = 0; i < rowCount; i++) {
298 var l = (i + start + c) % rowCount;
299 var cellText = this.view.getCellText(l, keyCol);
300 cellText = cellText.substring(0, length).toLowerCase();
301 if (cellText == incrementalString)
302 return l;
303 }
304 return -1;
305 ]]></body>
306 </method>
307
308 <method name="startEditing">
309 <parameter name="row"/>
310 <parameter name="column"/>
startEditing
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
311 <body>
312 <![CDATA[
313 if (row < 0 || row >= this.view.rowCount || !column)
314 return;
315 if (column.type != Components.interfaces.nsITreeColumn.TYPE_TEXT ||
316 column.cycler || !this.view.isEditable(row, column))
317 return;
318
319 if (this._editingColumn)
320 this.stopEditing();
321
322 var input = this.inputField;
323
324 var box = this.treeBoxObject;
325 box.ensureCellIsVisible(row, column);
326
327 var outx = {}, outy = {}, outwidth = {}, outheight = {};
328 var coords = box.getCoordsForCellItem(row, column, "text",
329 outx, outy, outwidth, outheight);
330
331 var style = window.getComputedStyle(input, "");
332 var topadj = parseInt(style.borderTopWidth) + parseInt(style.paddingTop);
333 input.top = outy.value - topadj;
334
335 var left = outx.value;
336 input.left = left;
337 input.height = outheight.value + topadj +
338 parseInt(style.borderBottomWidth) +
339 parseInt(style.paddingBottom);
340
341 coords = box.getCoordsForCellItem(row, column, "cell",
342 outx, outy, outwidth, outheight);
343 input.width = outwidth.value - (left - outx.value);
344 input.hidden = false;
345
346 input.value = this.view.getCellText(row, column);
selectText
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
347 var selectText = function selectText() {
348 input.select();
349 input.inputField.focus();
350 }
351 setTimeout(selectText, 0);
352
353 this._editingRow = row;
354 this._editingColumn = column;
355
356 this.setAttribute("editing", "true");
357 ]]>
358 </body>
359 </method>
360
361 <method name="stopEditing">
362 <parameter name="accept"/>
stopEditing
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
363 <body>
364 <![CDATA[
365 if (!this._editingColumn)
366 return;
367
368 var input = this.inputField;
369 if (accept) {
370 var value = input.value;
371 this.view.setCellText(this._editingRow, this._editingColumn, value);
372 }
373 this._editingRow = -1;
374 this._editingColumn = null;
375
376 input.hidden = true;
377 input.value = "";
378 this.removeAttribute("editing");
379 ]]>
380 </body>
381 </method>
382
383 <method name="_moveByOffset">
384 <parameter name="offset"/>
385 <parameter name="edge"/>
386 <parameter name="event"/>
_moveByOffset
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
387 <body>
388 <![CDATA[
389 if (this._editingColumn || this.view.rowCount == 0)
390 return;
391
392 if (this._isAccelPressed(event) && this.view.selection.single) {
393 this.treeBoxObject.scrollByLines(offset);
394 return;
395 }
396
397 var c = this.currentIndex + offset;
398 if (offset > 0 ? c > edge : c < edge) {
399 if (this.view.selection.isSelected(edge) && this.view.selection.count <= 1)
400 return;
401 c = edge;
402 }
403
404 var cellSelType = this._cellSelType;
405 if (cellSelType) {
406 var column = this.view.selection.currentColumn;
407 if (!column)
408 return;
409
410 while ((offset > 0 ? c <= edge : c >= edge) && !this.view.isSelectable(c, column))
411 c += offset;
412 if (offset > 0 ? c > edge : c < edge)
413 return;
414 }
415
416 if (!this._isAccelPressed(event))
417 this.view.selection.timedSelect(c, this._selectDelay);
418 else // Ctrl+Up/Down moves the anchor without selecting
419 this.currentIndex = c;
420 this.treeBoxObject.ensureRowIsVisible(c);
421 ]]>
422 </body>
423 </method>
424
425 <method name="_moveByOffsetShift">
426 <parameter name="offset"/>
427 <parameter name="edge"/>
428 <parameter name="event"/>
_moveByOffsetShift
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
429 <body>
430 <![CDATA[
431 if (this._editingColumn || this.view.rowCount == 0)
432 return;
433
434 if (this.view.selection.single) {
435 this.treeBoxObject.scrollByLines(offset);
436 return;
437 }
438
439 if (this.view.rowCount == 1 && !this.view.selection.isSelected(0)) {
440 this.view.selection.timedSelect(0, this._selectDelay);
441 return;
442 }
443
444 var c = this.currentIndex;
445 if (c == -1)
446 c = 0;
447
448 if (c == edge) {
449 if (this.view.selection.isSelected(c))
450 return;
451 }
452
453 // Extend the selection from the existing pivot, if any
454 this.view.selection.rangedSelect(-1, c + offset,
455 this._isAccelPressed(event));
456 this.treeBoxObject.ensureRowIsVisible(c + offset);
457
458 ]]>
459 </body>
460 </method>
461
462 <method name="_moveByPage">
463 <parameter name="offset"/>
464 <parameter name="edge"/>
465 <parameter name="event"/>
_moveByPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
466 <body>
467 <![CDATA[
468 if (this._editingColumn || this.view.rowCount == 0)
469 return;
470
471 if (this.pageUpOrDownMovesSelection == this._isAccelPressed(event)) {
472 this.treeBoxObject.scrollByPages(offset);
473 return;
474 }
475
476 if (this.view.rowCount == 1 && !this.view.selection.isSelected(0)) {
477 this.view.selection.timedSelect(0, this._selectDelay);
478 return;
479 }
480
481 var c = this.currentIndex;
482 if (c == -1)
483 return;
484
485 if (c == edge && this.view.selection.isSelected(c)) {
486 this.treeBoxObject.ensureRowIsVisible(c);
487 return;
488 }
489 var i = this.treeBoxObject.getFirstVisibleRow();
490 var p = this.treeBoxObject.getPageLength();
491
492 if (offset > 0) {
493 i += p - 1;
494 if (c >= i) {
495 i = c + p;
496 this.treeBoxObject.ensureRowIsVisible(i > edge ? edge : i);
497 }
498 i = i > edge ? edge : i;
499
500 } else {
501 if (c <= i) {
502 i = c <= p ? 0 : c - p;
503 this.treeBoxObject.ensureRowIsVisible(i);
504 }
505 }
506 this.view.selection.timedSelect(i, this._selectDelay);
507 ]]>
508 </body>
509 </method>
510
511 <method name="_moveByPageShift">
512 <parameter name="offset"/>
513 <parameter name="edge"/>
514 <parameter name="event"/>
_moveByPageShift
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
515 <body>
516 <![CDATA[
517 if (this._editingColumn || this.view.rowCount == 0)
518 return;
519
520 if (this.view.rowCount == 1 && !this.view.selection.isSelected(0) &&
521 !(this.pageUpOrDownMovesSelection == this._isAccelPressed(event))) {
522 this.view.selection.timedSelect(0, this._selectDelay);
523 return;
524 }
525
526 if (this.view.selection.single)
527 return;
528
529 var c = this.currentIndex;
530 if (c == -1)
531 return;
532 if (c == edge && this.view.selection.isSelected(c)) {
533 this.treeBoxObject.ensureRowIsVisible(edge);
534 return;
535 }
536 var i = this.treeBoxObject.getFirstVisibleRow();
537 var p = this.treeBoxObject.getPageLength();
538
539 if (offset > 0) {
540 i += p - 1;
541 if (c >= i) {
542 i = c + p;
543 this.treeBoxObject.ensureRowIsVisible(i > edge ? edge : i);
544 }
545 // Extend the selection from the existing pivot, if any
546 this.view.selection.rangedSelect(-1, i > edge ? edge : i, this._isAccelPressed(event));
547
548 } else {
549
550 if (c <= i) {
551 i = c <= p ? 0 : c - p;
552 this.treeBoxObject.ensureRowIsVisible(i);
553 }
554 // Extend the selection from the existing pivot, if any
555 this.view.selection.rangedSelect(-1, i, this._isAccelPressed(event));
556 }
557
558 ]]>
559 </body>
560 </method>
561
562 <method name="_moveToEdge">
563 <parameter name="edge"/>
564 <parameter name="event"/>
_moveToEdge
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
565 <body>
566 <![CDATA[
567 if (this._editingColumn || this.view.rowCount == 0)
568 return;
569
570 if (this.view.selection.isSelected(edge) && this.view.selection.count == 1) {
571 this.currentIndex = edge;
572 return;
573 }
574
575 // Normal behaviour is to select the first/last row
576 if (!this._isAccelPressed(event))
577 this.view.selection.timedSelect(edge, this._selectDelay);
578
579 // In a multiselect tree Ctrl+Home/End moves the anchor
580 else if (!this.view.selection.single)
581 this.currentIndex = edge;
582
583 this.treeBoxObject.ensureRowIsVisible(edge);
584 ]]>
585 </body>
586 </method>
587
588 <method name="_moveToEdgeShift">
589 <parameter name="edge"/>
590 <parameter name="event"/>
_moveToEdgeShift
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
591 <body>
592 <![CDATA[
593 if (this._editingColumn || this.view.rowCount == 0)
594 return;
595
596 if (this.view.rowCount == 1 && !this.view.selection.isSelected(0)) {
597 this.view.selection.timedSelect(0, this._selectDelay);
598 return;
599 }
600
601 if (this.view.selection.single ||
602 (this.view.selection.isSelected(edge)) && this.view.selection.isSelected(this.currentIndex))
603 return;
604
605 // Extend the selection from the existing pivot, if any.
606 // -1 doesn't work here, so using currentIndex instead
607 this.view.selection.rangedSelect(this.currentIndex, edge, this._isAccelPressed(event));
608
609 this.treeBoxObject.ensureRowIsVisible(edge);
610 ]]>
611 </body>
612 </method>
613 </implementation>
614
615 <handlers>
onDOMMouseScroll
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
616 <handler event="DOMMouseScroll" phase="capturing">
617 <![CDATA[
618 if (this._editingColumn)
619 return;
620
621 var rows = event.detail;
622 if (rows == NSUIEvent.SCROLL_PAGE_UP)
623 this.treeBoxObject.scrollByPages(-1);
624 else if (rows == NSUIEvent.SCROLL_PAGE_DOWN)
625 this.treeBoxObject.scrollByPages(1);
626 else
627 this.treeBoxObject.scrollByLines(rows);
628 ]]>
629 </handler>
onselect
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
630 <handler event="select" phase="target"
631 action="if (event.originalTarget == this) this.stopEditing(true);"/>
onfocus
(1 calls, 738 incl. v-uS, 68 excl. v-uS)
Called: tree.xml:!import (2 calls, 477 v-uS)
BoxObject:focused (1 calls, 108 v-uS)
tree.xml:get__cellSelType (1 calls, 84 v-uS)
632 <handler event="focus">
633 <![CDATA[
634 this.treeBoxObject.focused = true;
635 if (this.currentIndex == -1 && this.view.rowCount > 0) {
636 this.currentIndex = this.treeBoxObject.getFirstVisibleRow();
637 }
638 if (this._cellSelType && !this.view.selection.currentColumn) {
639 var col = this._getNextColumn(this.currentIndex, false);
640 this.view.selection.currentColumn = col;
641 }
642 ]]>
643 </handler>
onblur
(1 calls, 240 incl. v-uS, 33 excl. v-uS)
Called: BoxObject:focused (1 calls, 92 v-uS)
tree.xml:!import (1 calls, 113 v-uS)
644 <handler event="blur" action="this.treeBoxObject.focused = false;"/>
onblur
(1 calls, 75 incl. v-uS, 41 excl. v-uS)
Called: Event:originalTarget (1 calls, 18 v-uS)
textbox.xml:get_inputField (1 calls, 7 v-uS)
tree.xml:get_inputField (1 calls, 8 v-uS)
645 <handler event="blur" phase="capturing"
646 action="if (event.originalTarget == this.inputField.inputField) this.stopEditing(true);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
647 <handler event="keypress" keycode="VK_ENTER">
648 <![CDATA[
649 if (this._editingColumn) {
650 this.stopEditing(true);
651 this.focus();
652 event.stopPropagation();
653 }
654 else {
655 this.changeOpenState(this.currentIndex);
656 }
657 ]]>
658 </handler>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
659 <handler event="keypress" keycode="VK_RETURN">
660 <![CDATA[
661 if (this._editingColumn) {
662 this.stopEditing(true);
663 this.focus();
664 event.stopPropagation();
665 }
666 else {
667 this.changeOpenState(this.currentIndex);
668 }
669 ]]>
670 </handler>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
671 <handler event="keypress" keycode="VK_ESCAPE">
672 <![CDATA[
673 if (this._editingColumn) {
674 this.stopEditing(false);
675 this.focus();
676 event.stopPropagation();
677 }
678 ]]>
679 </handler>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
680 <handler event="keypress" keycode="VK_LEFT">
681 <![CDATA[
682 if (this._editingColumn)
683 return;
684
685 var row = this.currentIndex;
686 if (row < 0)
687 return;
688
689 var cellSelType = this._cellSelType;
690 var checkContainers = true;
691
692 var currentColumn;
693 if (cellSelType) {
694 currentColumn = this.view.selection.currentColumn;
695 if (currentColumn && !currentColumn.primary)
696 checkContainers = false;
697 }
698
699 if (checkContainers) {
700 if (this.changeOpenState(this.currentIndex, false))
701 return;
702 else {
703 var parentIndex = this.view.getParentIndex(this.currentIndex);
704 if (parentIndex >= 0) {
705 if (cellSelType && !this.view.isSelectable(parentIndex, currentColumn)) {
706 return;
707 }
708 this.view.selection.select(parentIndex);
709 this.treeBoxObject.ensureRowIsVisible(parentIndex);
710 return;
711 }
712 }
713 }
714
715 if (cellSelType) {
716 var col = this._getNextColumn(row, true);
717 if (col) {
718 this.view.selection.currentColumn = col;
719 this.treeBoxObject.ensureCellIsVisible(row, col);
720 }
721 }
722 ]]>
723 </handler>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
724 <handler event="keypress" keycode="VK_RIGHT">
725 <![CDATA[
726 if (this._editingColumn)
727 return;
728
729 var row = this.currentIndex;
730 if (row < 0)
731 return;
732
733 var cellSelType = this._cellSelType;
734 var checkContainers = true;
735
736 var currentColumn;
737 if (cellSelType) {
738 currentColumn = this.view.selection.currentColumn;
739 if (currentColumn && !currentColumn.primary)
740 checkContainers = false;
741 }
742
743 if (checkContainers) {
744 if (this.changeOpenState(row, true))
745 return;
746 else {
747 var c = row + 1;
748 var view = this.view;
749 if (c < view.rowCount &&
750 view.getParentIndex(c) == row) {
751 // If already opened, select the first child.
752 // The getParentIndex test above ensures that the children
753 // are already populated and ready.
754 if (cellSelType && !this.view.isSelectable(c , currentColumn)) {
755 var col = this._getNextColumn(c, false);
756 if (col) {
757 this.view.selection.currentColumn = col;
758 }
759 }
760 this.view.selection.timedSelect(c, this._selectDelay);
761 this.treeBoxObject.ensureRowIsVisible(c);
762 return;
763 }
764 }
765 }
766
767 if (cellSelType) {
768 var col = this._getNextColumn(row, false);
769 if (col) {
770 this.view.selection.currentColumn = col;
771 this.treeBoxObject.ensureCellIsVisible(row, col);
772 }
773 }
774 ]]>
775 </handler>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
776 <handler event="keypress" keycode="VK_UP"
777 modifiers="accel any" action="_moveByOffset(-1, 0, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
778 <handler event="keypress" keycode="VK_DOWN"
779 modifiers="accel any" action="_moveByOffset(1, this.view.rowCount - 1, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
780 <handler event="keypress" keycode="VK_UP"
781 modifiers="accel any, shift" action="_moveByOffsetShift(-1, 0, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
782 <handler event="keypress" keycode="VK_DOWN"
783 modifiers="accel any, shift" action="_moveByOffsetShift(1, this.view.rowCount - 1, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
784 <handler event="keypress" keycode="VK_PAGE_UP"
785 modifiers="accel any" action="_moveByPage(-1, 0, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
786 <handler event="keypress" keycode="VK_PAGE_DOWN"
787 modifiers="accel any" action="_moveByPage(1, this.view.rowCount - 1, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
788 <handler event="keypress" keycode="VK_PAGE_UP"
789 modifiers="accel any, shift" action="_moveByPageShift(-1, 0, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
790 <handler event="keypress" keycode="VK_PAGE_DOWN"
791 modifiers="accel any, shift" action="_moveByPageShift(1, this.view.rowCount - 1, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
792 <handler event="keypress" keycode="VK_HOME"
793 modifiers="accel any" action="_moveToEdge(0, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
794 <handler event="keypress" keycode="VK_END"
795 modifiers="accel any" action="_moveToEdge(this.view.rowCount - 1, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
796 <handler event="keypress" keycode="VK_HOME"
797 modifiers="accel any, shift" action="_moveToEdgeShift(0, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
798 <handler event="keypress" keycode="VK_END"
799 modifiers="accel any, shift" action="_moveToEdgeShift(this.view.rowCount - 1, event);"/>
onkeypress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
800 <handler event="keypress">
801 <![CDATA[
802 if (this._editingColumn)
803 return;
804
805 if (event.charCode == ' '.charCodeAt(0)) {
806 var c = this.currentIndex;
807 if (!this.view.selection.isSelected(c) ||
808 (!this.view.selection.single && this._isAccelPressed(event))) {
809 this.view.selection.toggleSelect(c);
810 }
811 }
812 else if (!this.disableKeyNavigation && event.charCode > 0 &&
813 !event.altKey && !this._isAccelPressed(event) &&
814 !event.metaKey && !event.ctrlKey) {
815 var l = this._keyNavigate(event);
816 if (l >= 0) {
817 this.view.selection.timedSelect(l, this._selectDelay);
818 this.treeBoxObject.ensureRowIsVisible(l);
819 }
820 }
821 ]]>
822 </handler>
823 </handlers>
824 </binding>
825
826 <binding id="treecols">
827 <resources>
828 <stylesheet src="chrome://global/skin/tree.css"/>
829 </resources>
830 <content orient="horizontal">
831 <xul:hbox class="tree-scrollable-columns" flex="1">
832 <children includes="treecol|splitter"/>
833 </xul:hbox>
834 <xul:treecolpicker class="treecol-image" fixed="true" xbl:inherits="tooltiptext=pickertooltiptext"/>
835 </content>
836 <implementation implements="nsIAccessibleProvider">
837 <property name="accessibleType" readonly="true">
get_accessibleType
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
838 <getter>
839 <![CDATA[
840 return Components.interfaces.nsIAccessibleProvider.XULTreeColumns;
841 ]]>
842 </getter>
843 </property>
844 </implementation>
845 </binding>
846
847 <binding id="treerows" extends="chrome://global/content/bindings/tree.xml#tree-base">
848 <content>
849 <xul:hbox flex="1" class="tree-bodybox">
850 <children/>
851 </xul:hbox>
852 <xul:scrollbar height="0" minwidth="0" minheight="0" orient="vertical" xbl:inherits="collapsed=hidevscroll"/>
853 </content>
854 <handlers>
onunderflow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
855 <handler event="underflow">
856 <![CDATA[
857 // Scrollport event orientation
858 // 0: vertical
859 // 1: horizontal
860 // 2: both (not used)
861 var tree = document.getBindingParent(this);
862 if (event.detail == 1)
863 tree.setAttribute("hidehscroll", "true");
864 else if (event.detail == 0)
865 tree.setAttribute("hidevscroll", "true");
866 event.stopPropagation();
867 ]]>
868 </handler>
onoverflow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
869 <handler event="overflow">
870 <![CDATA[
871 var tree = document.getBindingParent(this);
872 if (event.detail == 1)
873 tree.removeAttribute("hidehscroll");
874 else if (event.detail == 0)
875 tree.removeAttribute("hidevscroll");
876 event.stopPropagation();
877 ]]>
878 </handler>
879 </handlers>
880 </binding>
881
882 <binding id="treebody" extends="chrome://global/content/bindings/tree.xml#tree-base">
883 <implementation>
constructor
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
884 <constructor>
885 if ("_ensureColumnOrder" in this.parentNode)
886 this.parentNode._ensureColumnOrder();
887 </constructor>
888
field__lastSelectedRow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
889 <field name="_lastSelectedRow">
890 -1
891 </field>
892 </implementation>
893 <handlers>
894 <!-- If there is no modifier key, we select on mousedown, not
895 click, so that drags work correctly. -->
onmousedown
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
896 <handler event="mousedown" clickcount="1">
897 <![CDATA[
898 if (this.parentNode.disabled)
899 return;
900 if (((!this._isAccelPressed(event) ||
901 !this.parentNode.pageUpOrDownMovesSelection) &&
902 !event.shiftKey && !event.metaKey) ||
903 this.parentNode.view.selection.single) {
904 var row = {};
905 var col = {};
906 var obj = {};
907 var b = this.parentNode.treeBoxObject;
908 b.getCellAt(event.clientX, event.clientY, row, col, obj);
909
910 // save off the last selected row
911 this._lastSelectedRow = row.value;
912
913 if (row.value == -1)
914 return;
915
916 if (obj.value == "twisty")
917 return;
918
919 if (col.value) {
920 if (col.value.cycler) {
921 b.view.cycleCell(row.value, col.value);
922 return;
923 } else if (col.value.type == Components.interfaces.nsITreeColumn.TYPE_CHECKBOX) {
924 if (this.parentNode.editable && col.value.editable &&
925 b.view.isEditable(row.value, col.value)) {
926 var value = b.view.getCellValue(row.value, col.value);
927 value = value == "true" ? "false" : "true";
928 b.view.setCellValue(row.value, col.value, value);
929 return;
930 }
931 }
932 }
933
934 var cellSelType = this.parentNode._cellSelType;
935 if (cellSelType == "text" && obj.value != "text" && obj.value != "image")
936 return;
937
938 if (cellSelType) {
939 if (!col.value.selectable ||
940 !b.view.isSelectable(row.value, col.value)) {
941 return;
942 }
943 }
944
945 if (!b.view.selection.isSelected(row.value)) {
946 b.view.selection.select(row.value);
947 b.ensureRowIsVisible(row.value);
948 }
949
950 if (cellSelType) {
951 b.view.selection.currentColumn = col.value;
952 }
953 }
954 ]]>
955 </handler>
956
957 <!-- On a click (up+down on the same item), deselect everything
958 except this item. -->
onclick
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
959 <handler event="click" button="0" clickcount="1">
960 <![CDATA[
961 if (this.parentNode.disabled)
962 return;
963 var row = {};
964 var col = {};
965 var obj = {};
966 var b = this.parentNode.treeBoxObject;
967 b.getCellAt(event.clientX, event.clientY, row, col, obj);
968
969 if (row.value == -1)
970 return;
971
972 if (obj.value == "twisty") {
973 if (b.view.selection.currentIndex >= 0 &&
974 b.view.isContainerOpen(row.value)) {
975 var parentIndex = b.view.getParentIndex(b.view.selection.currentIndex);
976 while (parentIndex >= 0 && parentIndex != row.value)
977 parentIndex = b.view.getParentIndex(parentIndex);
978 if (parentIndex == row.value) {
979 var parentSelectable = true;
980 if (this.parentNode._cellSelType) {
981 var currentColumn = b.view.selection.currentColumn;
982 if (!b.view.isSelectable(parentIndex, currentColumn))
983 parentSelectable = false;
984 }
985 if (parentSelectable)
986 b.view.selection.select(parentIndex);
987 }
988 }
989 this.parentNode.changeOpenState(row.value);
990 return;
991 }
992
993 if (! b.view.selection.single) {
994 var augment = this._isAccelPressed(event);
995 if (event.shiftKey) {
996 b.view.selection.rangedSelect(-1, row.value, augment);
997 b.ensureRowIsVisible(row.value);
998 return;
999 }
1000 if (augment) {
1001 b.view.selection.toggleSelect(row.value);
1002 b.ensureRowIsVisible(row.value);
1003 b.view.selection.currentIndex = row.value;
1004 return;
1005 }
1006 }
1007
1008 /* We want to deselect all the selected items except what was
1009 clicked, UNLESS it was a right-click. We have to do this
1010 in click rather than mousedown so that you can drag a
1011 selected group of items */
1012
1013 if (!col.value) return;
1014
1015 // if the last row has changed in between the time we
1016 // mousedown and the time we click, don't fire the select handler.
1017 // see bug #92366
1018 if (!col.value.cycler && this._lastSelectedRow == row.value &&
1019 col.value.type != Components.interfaces.nsITreeColumn.TYPE_CHECKBOX) {
1020
1021 var cellSelType = this.parentNode._cellSelType;
1022 if (cellSelType == "text" && obj.value != "text" && obj.value != "image")
1023 return;
1024
1025 if (cellSelType) {
1026 if (!col.value.selectable ||
1027 !b.view.isSelectable(row.value, col.value)) {
1028 return;
1029 }
1030 }
1031
1032 b.view.selection.select(row.value);
1033 b.ensureRowIsVisible(row.value);
1034
1035 if (cellSelType) {
1036 b.view.selection.currentColumn = col.value;
1037 }
1038 }
1039 ]]>
1040 </handler>
1041
1042 <!-- double-click -->
onclick
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1043 <handler event="click" clickcount="2">
1044 <![CDATA[
1045 if (this.parentNode.disabled)
1046 return;
1047 var b = this.parentNode.treeBoxObject;
1048 var row = b.view.selection.currentIndex;
1049 if (row == -1)
1050 return;
1051
1052 var col = {};
1053 var obj = {};
1054 b.getCellAt(event.clientX, event.clientY, {}, col, obj);
1055
1056 if (this.parentNode.editable)
1057 this.parentNode.startEditing(row, col.value);
1058
1059 if (!b.view.isContainer(row))
1060 return;
1061
1062
1063 // Cyclers and twisties respond to single clicks, not double clicks
1064 if (col.value && !col.value.cycler && obj.value != "twisty")
1065 this.parentNode.changeOpenState(row);
1066 ]]>
1067 </handler>
1068
1069 </handlers>
1070 </binding>
1071
1072 <binding id="treecol-base" extends="chrome://global/content/bindings/tree.xml#tree-base">
1073 <implementation implements="nsIAccessibleProvider">
constructor
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1074 <constructor>
1075 this.parentNode.parentNode._columnsDirty = true;
1076 </constructor>
1077
1078 <property name="accessibleType" readonly="true">
get_accessibleType
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1079 <getter>
1080 <![CDATA[
1081 return Components.interfaces.nsIAccessibleProvider.XULTreeColumnItem;
1082 ]]>
1083 </getter>
1084 </property>
1085
1086 <property name="ordinal">
get_ordinal
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1087 <getter><![CDATA[
1088 var val = this.getAttribute("ordinal");
1089 return "" + (val == "" ? 1 : (val == "0" ? 0 : parseInt(val)));
1090 ]]></getter>
set_ordinal
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1091 <setter><![CDATA[
1092 this.setAttribute("ordinal", val);
1093 return val;
1094 ]]></setter>
1095 </property>
1096
1097 <property name="_previousVisibleColumn">
get__previousVisibleColumn
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1098 <getter><![CDATA[
1099 var sib = this.boxObject.previousSibling;
1100 while (sib) {
1101 if (sib.localName == "treecol" && sib.boxObject.width > 0 && sib.parentNode == this.parentNode)
1102 return sib;
1103 sib = sib.boxObject.previousSibling;
1104 }
1105 return null;
1106 ]]></getter>
1107 </property>
1108
1109 <method name="_onDragMouseMove">
1110 <parameter name="aEvent"/>
_onDragMouseMove
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1111 <body><![CDATA[
1112 var col = document.treecolDragging;
1113 if (!col) return;
1114
1115 // determine if we have moved the mouse far enough
1116 // to initiate a drag
1117 if (col.mDragGesturing) {
1118 if (Math.abs(aEvent.clientX - col.mStartDragX) < 5 &&
1119 Math.abs(aEvent.clientY - col.mStartDragY) < 5) {
1120 return;
1121 } else {
1122 col.mDragGesturing = false;
1123 col.setAttribute("dragging", "true");
1124 window.addEventListener("click", col._onDragMouseClick, true);
1125 }
1126 }
1127
1128 var pos = {};
1129 var targetCol = col.parentNode.parentNode._getColumnAtX(aEvent.clientX, 0.5, pos);
1130
1131 // bail if we haven't mousemoved to a different column
1132 if (col.mTargetCol == targetCol && col.mTargetDir == pos.value)
1133 return;
1134
1135 var tree = col.parentNode.parentNode;
1136 var sib;
1137 var column;
1138 if (col.mTargetCol) {
1139 // remove previous insertbefore/after attributes
1140 col.mTargetCol.removeAttribute("insertbefore");
1141 col.mTargetCol.removeAttribute("insertafter");
1142 column = tree.columns.getColumnFor(col.mTargetCol);
1143 tree.treeBoxObject.invalidateColumn(column);
1144 sib = col.mTargetCol._previousVisibleColumn;
1145 if (sib) {
1146 sib.removeAttribute("insertafter");
1147 column = tree.columns.getColumnFor(sib);
1148 tree.treeBoxObject.invalidateColumn(column);
1149 }
1150 col.mTargetCol = null;
1151 col.mTargetDir = null;
1152 }
1153
1154 if (targetCol) {
1155 // set insertbefore/after attributes
1156 if (pos.value == "after") {
1157 targetCol.setAttribute("insertafter", "true");
1158 } else {
1159 targetCol.setAttribute("insertbefore", "true");
1160 sib = targetCol._previousVisibleColumn;
1161 if (sib) {
1162 sib.setAttribute("insertafter", "true");
1163 column = tree.columns.getColumnFor(sib);
1164 tree.treeBoxObject.invalidateColumn(column);
1165 }
1166 }
1167 column = tree.columns.getColumnFor(targetCol);
1168 tree.treeBoxObject.invalidateColumn(column);
1169 col.mTargetCol = targetCol;
1170 col.mTargetDir = pos.value;
1171 }
1172 ]]></body>
1173 </method>
1174
1175 <method name="_onDragMouseUp">
1176 <parameter name="aEvent"/>
_onDragMouseUp
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1177 <body><![CDATA[
1178 var col = document.treecolDragging;
1179 if (!col) return;
1180
1181 if (!col.mDragGesturing) {
1182 if (col.mTargetCol) {
1183 // remove insertbefore/after attributes
1184 var before = col.mTargetCol.hasAttribute("insertbefore");
1185 col.mTargetCol.removeAttribute(before ? "insertbefore" : "insertafter");
1186
1187 var sib = col.mTargetCol._previousVisibleColumn;
1188 if (before && sib) {
1189 sib.removeAttribute("insertafter");
1190 }
1191
1192 // Move the column only if it will result in a different column
1193 // ordering
1194 var move = true;
1195
1196 // If this is a before move and the previous visible column is
1197 // the same as the column we're moving, don't move
1198 if (before && col == sib) {
1199 move = false;
1200 }
1201 else if (!before && col == col.mTargetCol) {
1202 // If this is an after move and the column we're moving is
1203 // the same as the target column, don't move.
1204 move = false;
1205 }
1206
1207 if (move) {
1208 col.parentNode.parentNode._reorderColumn(col, col.mTargetCol, before);
1209 }
1210
1211 // repaint to remove lines
1212 col.parentNode.parentNode.treeBoxObject.invalidate();
1213
1214 col.mTargetCol = null;
1215 }
1216 } else
1217 col.mDragGesturing = false;
1218
1219 document.treecolDragging = null;
1220 col.removeAttribute("dragging");
1221
1222 window.removeEventListener("mousemove", col._onDragMouseMove, true);
1223 window.removeEventListener("mouseup", col._onDragMouseUp, true);
1224 // we have to wait for the click event to fire before removing
1225 // cancelling handler
anon:1226:29
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1226 var clickHandler = function(handler) {
1227 window.removeEventListener("click", handler, true);
1228 };
1229 window.setTimeout(clickHandler, 0, col._onDragMouseClick);
1230 ]]></body>
1231 </method>
1232
1233 <method name="_onDragMouseClick">
1234 <parameter name="aEvent"/>
_onDragMouseClick
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1235 <body><![CDATA[
1236 // prevent click event from firing after column drag and drop
1237 aEvent.stopPropagation();
1238 aEvent.preventDefault();
1239 ]]></body>
1240 </method>
1241 </implementation>
1242
1243 <handlers>
onmousedown
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1244 <handler event="mousedown" button="0"><![CDATA[
1245 if (this.parentNode.parentNode.enableColumnDrag) {
1246 var xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
1247 var cols = this.parentNode.getElementsByTagNameNS(xulns, "treecol");
1248
1249 // only start column drag operation if there are at least 2 visible columns
1250 var visible = 0;
1251 for (var i = 0; i < cols.length; ++i)
1252 if (cols[i].boxObject.width > 0) ++visible;
1253
1254 if (visible > 1) {
1255 window.addEventListener("mousemove", this._onDragMouseMove, true);
1256 window.addEventListener("mouseup", this._onDragMouseUp, true);
1257 document.treecolDragging = this;
1258 this.mDragGesturing = true;
1259 this.mStartDragX = event.clientX;
1260 this.mStartDragY = event.clientY;
1261 }
1262 }
1263 ]]></handler>
onclick
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1264 <handler event="click" button="0" phase="target">
1265 <![CDATA[
1266 if (event.target != event.originalTarget)
1267 return;
1268
1269 var tree = this.parentNode.parentNode;
1270 var column = tree.columns.getColumnFor(this);
1271 tree.view.cycleHeader(column);
1272 ]]>
1273 </handler>
1274 </handlers>
1275 </binding>
1276
1277 <binding id="treecol" extends="chrome://global/content/bindings/tree.xml#treecol-base">
1278 <content>
1279 <xul:label class="treecol-text" xbl:inherits="crop,value=label" flex="1" crop="right"/>
1280 <xul:image class="treecol-sortdirection" xbl:inherits="sortDirection,hidden=hideheader"/>
1281 </content>
1282 </binding>
1283
1284 <binding id="treecol-image" extends="chrome://global/content/bindings/tree.xml#treecol-base">
1285 <content>
1286 <xul:image class="treecol-icon" xbl:inherits="src"/>
1287 </content>
1288 </binding>
1289
1290 <binding id="columnpicker" display="xul:button"
1291 extends="chrome://global/content/bindings/tree.xml#tree-base">
1292 <content>
1293 <xul:image class="tree-columnpicker-icon"/>
1294 <xul:menupopup anonid="popup">
1295 <xul:menuseparator anonid="menuseparator"/>
1296 <xul:menuitem anonid="menuitem" label="&restoreNaturalOrder.label;"/>
1297 </xul:menupopup>
1298 </content>
1299
1300 <implementation implements="nsIAccessibleProvider">
1301 <property name="accessibleType" readonly="true">
get_accessibleType
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1302 <getter>
1303 return Components.interfaces.nsIAccessibleProvider.XULButton;
1304 </getter>
1305 </property>
1306
1307 <method name="buildPopup">
1308 <parameter name="aPopup"/>
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1309 <body>
1310 <![CDATA[
1311 // We no longer cache the picker content, remove the old content.
1312 while (aPopup.childNodes.length > 2)
1313 aPopup.removeChild(aPopup.firstChild);
1314
1315 var refChild = aPopup.firstChild;
1316
1317 var tree = this.parentNode.parentNode;
1318 for (var currCol = tree.columns.getFirstColumn(); currCol;
1319 currCol = currCol.getNext()) {
1320 // Construct an entry for each column in the row, unless
1321 // it is not being shown.
1322 var currElement = currCol.element;
1323 if (!currElement.hasAttribute("ignoreincolumnpicker")) {
1324 var popupChild = document.createElement("menuitem");
1325 popupChild.setAttribute("type", "checkbox");
1326 var columnName = currElement.getAttribute("display") ||
1327 currElement.getAttribute("label");
1328 popupChild.setAttribute("label", columnName);
1329 popupChild.setAttribute("colindex", currCol.index);
1330 if (currElement.getAttribute("hidden") != "true")
1331 popupChild.setAttribute("checked", "true");
1332 if (currCol.primary)
1333 popupChild.setAttribute("disabled", "true");
1334 aPopup.insertBefore(popupChild, refChild);
1335 }
1336 }
1337
1338 var hidden = !tree.enableColumnDrag;
1339 const anonids = ["menuseparator", "menuitem"];
1340 for (var i = 0; i < anonids.length; i++) {
1341 var element = document.getAnonymousElementByAttribute(this, "anonid", anonids[i]);
1342 element.hidden = hidden;
1343 }
1344 ]]>
1345 </body>
1346 </method>
1347 </implementation>
1348
1349 <handlers>
oncommand
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1350 <handler event="command">
1351 <![CDATA[
1352 if (event.originalTarget == this) {
1353 var popup = document.getAnonymousElementByAttribute(this, "anonid", "popup");
1354 this.buildPopup(popup);
1355 popup.showPopup(this, -1, -1, "popup", "bottomright", "topright");
1356 }
1357 else {
1358 var tree = this.parentNode.parentNode;
1359 tree.stopEditing(true);
1360 var menuitem = document.getAnonymousElementByAttribute(this, "anonid", "menuitem");
1361 if (event.originalTarget == menuitem) {
1362 tree.columns.restoreNaturalOrder();
1363 tree._ensureColumnOrder();
1364 }
1365 else {
1366 var colindex = event.originalTarget.getAttribute("colindex");
1367 var column = tree.columns[colindex];
1368 if (column) {
1369 var element = column.element;
1370 if (element.getAttribute("hidden") == "true")
1371 element.setAttribute("hidden", "false");
1372 else
1373 element.setAttribute("hidden", "true");
1374 }
1375 }
1376 }
1377 ]]>
1378 </handler>
1379 </handlers>
1380 </binding>
1381 </bindings>