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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
|
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings id="placesTreeBindings"
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="places-tree" extends="chrome://global/content/bindings/tree.xml#tree">
<implementation>
<constructor><![CDATA[
// Force an initial build.
if (this.place)
this.place = this.place;
]]></constructor>
<destructor><![CDATA[
// Break the treeviewer->result->treeviewer cycle.
// Note: unsetting the result's viewer also unsets
// the viewer's reference to our treeBoxObject.
var result = this.result;
if (result) {
result.root.containerOpen = false;
}
// Unregister the controllber before unlinking the view, otherwise it
// may still try to update commands on a view with a null result.
if (this._controller) {
this._controller.terminate();
this.controllers.removeController(this._controller);
}
this.view = null;
]]></destructor>
<property name="controller"
readonly="true"
onget="return this._controller"/>
<!-- overriding -->
<property name="view">
<getter><![CDATA[
try {
return this.treeBoxObject.view.wrappedJSObject;
}
catch(e) {
return null;
}
]]></getter>
<setter><![CDATA[
return this.treeBoxObject.view = val;
]]></setter>
</property>
<property name="associatedElement"
readonly="true"
onget="return this"/>
<method name="applyFilter">
<parameter name="filterString"/>
<parameter name="folderRestrict"/>
<parameter name="includeHidden"/>
<body><![CDATA[
// preserve grouping
var queryNode = PlacesUtils.asQuery(this.result.root);
var options = queryNode.queryOptions.clone();
// Make sure we're getting uri results.
// We do not yet support searching into grouped queries or into
// tag containers, so we must fall to the default case.
if (PlacesUtils.nodeIsHistoryContainer(queryNode) ||
options.resultType == options.RESULTS_AS_TAG_QUERY ||
options.resultType == options.RESULTS_AS_TAG_CONTENTS)
options.resultType = options.RESULTS_AS_URI;
var query = PlacesUtils.history.getNewQuery();
query.searchTerms = filterString;
if (folderRestrict) {
query.setFolders(folderRestrict, folderRestrict.length);
options.queryType = options.QUERY_TYPE_BOOKMARKS;
}
options.includeHidden = !!includeHidden;
this.load([query], options);
]]></body>
</method>
<method name="load">
<parameter name="queries"/>
<parameter name="options"/>
<body><![CDATA[
let result = PlacesUtils.history
.executeQueries(queries, queries.length,
options);
let callback;
if (this.flatList) {
let onOpenFlatContainer = this.onOpenFlatContainer;
if (onOpenFlatContainer)
callback = new Function("aContainer", onOpenFlatContainer);
}
if (!this._controller) {
this._controller = new PlacesController(this);
this.controllers.appendController(this._controller);
}
let treeView = new PlacesTreeView(this.flatList, callback, this._controller);
// Observer removal is done within the view itself. When the tree
// goes away, treeboxobject calls view.setTree(null), which then
// calls removeObserver.
result.addObserver(treeView, false);
this.view = treeView;
if (this.getAttribute("selectfirstnode") == "true" && treeView.rowCount > 0) {
treeView.selection.select(0);
}
this._cachedInsertionPoint = undefined;
]]></body>
</method>
<property name="flatList">
<getter><![CDATA[
return this.getAttribute("flatList") == "true";
]]></getter>
<setter><![CDATA[
if (this.flatList != val) {
this.setAttribute("flatList", val);
// reload with the last place set
if (this.place)
this.place = this.place;
}
return val;
]]></setter>
</property>
<property name="onOpenFlatContainer">
<getter><![CDATA[
return this.getAttribute("onopenflatcontainer");
]]></getter>
<setter><![CDATA[
if (this.onOpenFlatContainer != val) {
this.setAttribute("onopenflatcontainer", val);
// reload with the last place set
if (this.place)
this.place = this.place;
}
return val;
]]></setter>
</property>
<!--
Causes a particular node represented by the specified placeURI to be
selected in the tree. All containers above the node in the hierarchy
will be opened, so that the node is visible.
-->
<method name="selectPlaceURI">
<parameter name="placeURI"/>
<body><![CDATA[
// Do nothing if a node matching the given uri is already selected
if (this.hasSelection && this.selectedNode.uri == placeURI)
return;
function findNode(container, placeURI, nodesURIChecked) {
var containerURI = container.uri;
if (containerURI == placeURI)
return container;
if (nodesURIChecked.indexOf(containerURI) != -1)
return null;
// never check the contents of the same query
nodesURIChecked.push(containerURI);
var wasOpen = container.containerOpen;
if (!wasOpen)
container.containerOpen = true;
for (var i = 0; i < container.childCount; ++i) {
var child = container.getChild(i);
var childURI = child.uri;
if (childURI == placeURI)
return child;
else if (PlacesUtils.nodeIsContainer(child)) {
var nested = findNode(PlacesUtils.asContainer(child), placeURI, nodesURIChecked);
if (nested)
return nested;
}
}
if (!wasOpen)
container.containerOpen = false;
return null;
}
var container = this.result.root;
NS_ASSERT(container, "No result, cannot select place URI!");
if (!container)
return;
var child = findNode(container, placeURI, []);
if (child)
this.selectNode(child);
else {
// If the specified child could not be located, clear the selection
var selection = this.view.selection;
selection.clearSelection();
}
]]></body>
</method>
<!--
Causes a particular node to be selected in the tree, resulting in all
containers above the node in the hierarchy to be opened, so that the
node is visible.
-->
<method name="selectNode">
<parameter name="node"/>
<body><![CDATA[
var view = this.view;
var parent = node.parent;
if (parent && !parent.containerOpen) {
// Build a list of all of the nodes that are the parent of this one
// in the result.
var parents = [];
var root = this.result.root;
while (parent && parent != root) {
parents.push(parent);
parent = parent.parent;
}
// Walk the list backwards (opening from the root of the hierarchy)
// opening each folder as we go.
for (var i = parents.length - 1; i >= 0; --i) {
var index = view.treeIndexForNode(parents[i]);
if (index != Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE &&
view.isContainer(index) && !view.isContainerOpen(index))
view.toggleOpenState(index);
}
// Select the specified node...
}
var index = view.treeIndexForNode(node);
if (index == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE)
return;
view.selection.select(index);
// ... and ensure it's visible, not scrolled off somewhere.
this.treeBoxObject.ensureRowIsVisible(index);
]]></body>
</method>
<!-- nsIPlacesView -->
<property name="result">
<getter><![CDATA[
try {
return this.view.QueryInterface(Ci.nsINavHistoryResultObserver).result;
}
catch (e) {
return null;
}
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="place">
<getter><![CDATA[
return this.getAttribute("place");
]]></getter>
<setter><![CDATA[
this.setAttribute("place", val);
var queriesRef = { };
var queryCountRef = { };
var optionsRef = { };
PlacesUtils.history.queryStringToQueries(val, queriesRef, queryCountRef, optionsRef);
if (queryCountRef.value == 0)
queriesRef.value = [PlacesUtils.history.getNewQuery()];
if (!optionsRef.value)
optionsRef.value = PlacesUtils.history.getNewQueryOptions();
this.load(queriesRef.value, optionsRef.value);
return val;
]]></setter>
</property>
<!-- nsIPlacesView -->
<property name="hasSelection">
<getter><![CDATA[
return this.view && this.view.selection.count >= 1;
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="selectedNodes">
<getter><![CDATA[
let nodes = [];
if (!this.hasSelection)
return nodes;
let selection = this.view.selection;
let rc = selection.getRangeCount();
let resultview = this.view;
for (let i = 0; i < rc; ++i) {
let min = { }, max = { };
selection.getRangeAt(i, min, max);
for (let j = min.value; j <= max.value; ++j)
nodes.push(resultview.nodeForTreeIndex(j));
}
return nodes;
]]></getter>
</property>
<method name="toggleCutNode">
<parameter name="aNode"/>
<parameter name="aValue"/>
<body><![CDATA[
this.view.toggleCutNode(aNode, aValue);
]]></body>
</method>
<!-- nsIPlacesView -->
<property name="removableSelectionRanges">
<getter><![CDATA[
// This property exists in addition to selectedNodes because it
// encodes selection ranges (which only occur in list views) into
// the return value. For each removed range, the index at which items
// will be re-inserted upon the remove transaction being performed is
// the first index of the range, so that the view updates correctly.
//
// For example, if we remove rows 2,3,4 and 7,8 from a list, when we
// undo that operation, if we insert what was at row 3 at row 3 again,
// it will show up _after_ the item that was at row 5. So we need to
// insert all items at row 2, and the tree view will update correctly.
//
// Also, this function collapses the selection to remove redundant
// data, e.g. when deleting this selection:
//
// http://www.foo.com/
// (-) Some Folder
// http://www.bar.com/
//
// ... returning http://www.bar.com/ as part of the selection is
// redundant because it is implied by removing "Some Folder". We
// filter out all such redundancies since some partial amount of
// the folder's children may be selected.
//
let nodes = [];
if (!this.hasSelection)
return nodes;
var selection = this.view.selection;
var rc = selection.getRangeCount();
var resultview = this.view;
// This list is kept independently of the range selected (i.e. OUTSIDE
// the for loop) since the row index of a container is unique for the
// entire view, and we could have some really wacky selection and we
// don't want to blow up.
var containers = { };
for (var i = 0; i < rc; ++i) {
var range = [];
var min = { }, max = { };
selection.getRangeAt(i, min, max);
for (var j = min.value; j <= max.value; ++j) {
if (this.view.isContainer(j))
containers[j] = true;
if (!(this.view.getParentIndex(j) in containers))
range.push(resultview.nodeForTreeIndex(j));
}
nodes.push(range);
}
return nodes;
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="draggableSelection"
onget="return this.selectedNodes"/>
<!-- nsIPlacesView -->
<property name="selectedNode">
<getter><![CDATA[
var view = this.view;
if (!view || view.selection.count != 1)
return null;
var selection = view.selection;
var min = { }, max = { };
selection.getRangeAt(0, min, max);
return this.view.nodeForTreeIndex(min.value);
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="insertionPoint">
<getter><![CDATA[
// invalidated on selection and focus changes
if (this._cachedInsertionPoint !== undefined)
return this._cachedInsertionPoint;
// there is no insertion point for history queries
// so bail out now and save a lot of work when updating commands
var resultNode = this.result.root;
if (PlacesUtils.nodeIsQuery(resultNode) &&
PlacesUtils.asQuery(resultNode).queryOptions.queryType ==
Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY)
return this._cachedInsertionPoint = null;
var orientation = Ci.nsITreeView.DROP_BEFORE;
// If there is no selection, insert at the end of the container.
if (!this.hasSelection) {
var index = this.view.rowCount - 1;
this._cachedInsertionPoint =
this._getInsertionPoint(index, orientation);
return this._cachedInsertionPoint;
}
// This is a two-part process. The first part is determining the drop
// orientation.
// * The default orientation is to drop _before_ the selected item.
// * If the selected item is a container, the default orientation
// is to drop _into_ that container.
//
// Warning: It may be tempting to use tree indexes in this code, but
// you must not, since the tree is nested and as your tree
// index may change when folders before you are opened and
// closed. You must convert your tree index to a node, and
// then use getChildIndex to find your absolute index in
// the parent container instead.
//
var resultView = this.view;
var selection = resultView.selection;
var rc = selection.getRangeCount();
var min = { }, max = { };
selection.getRangeAt(rc - 1, min, max);
// If the sole selection is a container, and we are not in
// a flatlist, insert into it.
// Note that this only applies to _single_ selections,
// if the last element within a multi-selection is a
// container, insert _adjacent_ to the selection.
//
// If the sole selection is the bookmarks toolbar folder, we insert
// into it even if it is not opened
var itemId =
PlacesUtils.getConcreteItemId(resultView.nodeForTreeIndex(max.value));
if (selection.count == 1 && resultView.isContainer(max.value) &&
!this.flatList)
orientation = Ci.nsITreeView.DROP_ON;
this._cachedInsertionPoint =
this._getInsertionPoint(max.value, orientation);
return this._cachedInsertionPoint;
]]></getter>
</property>
<method name="_getInsertionPoint">
<parameter name="index"/>
<parameter name="orientation"/>
<body><![CDATA[
var result = this.result;
var resultview = this.view;
var container = result.root;
var dropNearItemId = -1;
NS_ASSERT(container, "null container");
// When there's no selection, assume the container is the container
// the view is populated from (i.e. the result's itemId).
if (index != -1) {
var lastSelected = resultview.nodeForTreeIndex(index);
if (resultview.isContainer(index) && orientation == Ci.nsITreeView.DROP_ON) {
// If the last selected item is an open container, append _into_
// it, rather than insert adjacent to it.
container = lastSelected;
index = -1;
}
else if (lastSelected.containerOpen &&
orientation == Ci.nsITreeView.DROP_AFTER &&
lastSelected.hasChildren) {
// If the last selected item is an open container and the user is
// trying to drag into it as a first item, really insert into it.
container = lastSelected;
orientation = Ci.nsITreeView.DROP_ON;
index = 0;
}
else {
// Use the last-selected node's container.
container = lastSelected.parent;
// See comment in the treeView.js's copy of this method
if (!container || !container.containerOpen)
return null;
// Avoid the potentially expensive call to getChildIndex
// if we know this container doesn't allow insertion
if (PlacesControllerDragHelper.disallowInsertion(container))
return null;
var queryOptions = PlacesUtils.asQuery(result.root).queryOptions;
if (queryOptions.sortingMode !=
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) {
// If we are within a sorted view, insert at the end
index = -1;
}
else if (queryOptions.excludeItems ||
queryOptions.excludeQueries ||
queryOptions.excludeReadOnlyFolders) {
// Some item may be invisible, insert near last selected one.
// We don't replace index here to avoid requests to the db,
// instead it will be calculated later by the controller.
index = -1;
dropNearItemId = lastSelected.itemId;
}
else {
var lsi = container.getChildIndex(lastSelected);
index = orientation == Ci.nsITreeView.DROP_BEFORE ? lsi : lsi + 1;
}
}
}
if (PlacesControllerDragHelper.disallowInsertion(container))
return null;
return new InsertionPoint(PlacesUtils.getConcreteItemId(container),
index, orientation,
PlacesUtils.nodeIsTagQuery(container),
dropNearItemId);
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="selectAll">
<body><![CDATA[
this.view.selection.selectAll();
]]></body>
</method>
<!-- This method will select the first node in the tree that matches
each given item id. It will open any parent nodes that it needs
to in order to show the selected items.
-->
<method name="selectItems">
<parameter name="aIDs"/>
<parameter name="aOpenContainers"/>
<body><![CDATA[
// By default, we do search and select within containers which were
// closed (note that containers in which nodes were not found are
// closed).
if (aOpenContainers === undefined)
aOpenContainers = true;
var ids = aIDs; // don't manipulate the caller's array
// Array of nodes found by findNodes which are to be selected
var nodes = [];
// Array of nodes found by findNodes which should be opened
var nodesToOpen = [];
// A set of URIs of container-nodes that were previously searched,
// and thus shouldn't be searched again. This is empty at the initial
// start of the recursion and gets filled in as the recursion
// progresses.
var nodesURIChecked = [];
/**
* Recursively search through a node's children for items
* with the given IDs. When a matching item is found, remove its ID
* from the IDs array, and add the found node to the nodes dictionary.
*
* NOTE: This method will leave open any node that had matching items
* in its subtree.
*/
function findNodes(node) {
var foundOne = false;
// See if node matches an ID we wanted; add to results.
// For simple folder queries, check both itemId and the concrete
// item id.
var index = ids.indexOf(node.itemId);
if (index == -1 &&
node.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT)
index = ids.indexOf(PlacesUtils.asQuery(node).folderItemId);
if (index != -1) {
nodes.push(node);
foundOne = true;
ids.splice(index, 1);
}
if (ids.length == 0 || !PlacesUtils.nodeIsContainer(node) ||
nodesURIChecked.indexOf(node.uri) != -1)
return foundOne;
PlacesUtils.asContainer(node);
if (!aOpenContainers && !node.containerOpen)
return foundOne;
nodesURIChecked.push(node.uri);
// Remember the beginning state so that we can re-close
// this node if we don't find any additional results here.
var previousOpenness = node.containerOpen;
node.containerOpen = true;
for (var child = 0; child < node.childCount && ids.length > 0;
child++) {
var childNode = node.getChild(child);
var found = findNodes(childNode);
if (!foundOne)
foundOne = found;
}
// If we didn't find any additional matches in this node's
// subtree, revert the node to its previous openness.
if (foundOne)
nodesToOpen.unshift(node);
node.containerOpen = previousOpenness;
return foundOne;
}
// Disable notifications while looking for nodes.
let result = this.result;
let didSuppressNotifications = result.suppressNotifications;
if (!didSuppressNotifications)
result.suppressNotifications = true
try {
findNodes(this.result.root);
}
finally {
if (!didSuppressNotifications)
result.suppressNotifications = false;
}
// For all the nodes we've found, highlight the corresponding
// index in the tree.
var resultview = this.view;
var selection = this.view.selection;
selection.selectEventsSuppressed = true;
selection.clearSelection();
// Open nodes containing found items
for (var i = 0; i < nodesToOpen.length; i++) {
nodesToOpen[i].containerOpen = true;
}
for (var i = 0; i < nodes.length; i++) {
var index = resultview.treeIndexForNode(nodes[i]);
if (index == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE)
continue;
selection.rangedSelect(index, index, true);
}
selection.selectEventsSuppressed = false;
]]></body>
</method>
<field name="_contextMenuShown">false</field>
<method name="buildContextMenu">
<parameter name="aPopup"/>
<body><![CDATA[
this._contextMenuShown = true;
return this.controller.buildContextMenu(aPopup);
]]></body>
</method>
<method name="destroyContextMenu">
<parameter name="aPopup"/>
this._contextMenuShown = false;
<body/>
</method>
<property name="ownerWindow"
readonly="true"
onget="return window;"/>
<field name="_active">true</field>
<property name="active"
onget="return this._active"
onset="return this._active = val"/>
</implementation>
<handlers>
<handler event="focus"><![CDATA[
this._cachedInsertionPoint = undefined;
// See select handler. We need the sidebar's places commandset to be
// updated as well
document.commandDispatcher.updateCommands("focus");
]]></handler>
<handler event="select"><![CDATA[
this._cachedInsertionPoint = undefined;
// This additional complexity is here for the sidebars
var win = window;
while (true) {
win.document.commandDispatcher.updateCommands("focus");
if (win == window.top)
break;
win = win.parent;
}
]]></handler>
<handler event="dragstart"><![CDATA[
if (event.target.localName != "treechildren")
return;
let nodes = this.selectedNodes;
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i];
// Disallow dragging the root node of a tree.
if (!node.parent) {
event.preventDefault();
event.stopPropagation();
return;
}
// If this node is child of a readonly container (e.g. a livemark)
// or cannot be moved, we must force a copy.
if (!PlacesControllerDragHelper.canMoveNode(node)) {
event.dataTransfer.effectAllowed = "copyLink";
break;
}
}
this._controller.setDataTransfer(event);
event.stopPropagation();
]]></handler>
<handler event="dragover"><![CDATA[
if (event.target.localName != "treechildren")
return;
let cell = this.treeBoxObject.getCellAt(event.clientX, event.clientY);
let node = cell.row != -1 ?
this.view.nodeForTreeIndex(cell.row) :
this.result.root;
// cache the dropTarget for the view
PlacesControllerDragHelper.currentDropTarget = node;
// We have to calculate the orientation since view.canDrop will use
// it and we want to be consistent with the dropfeedback.
let tbo = this.treeBoxObject;
let rowHeight = tbo.rowHeight;
let eventY = event.clientY - tbo.treeBody.boxObject.y -
rowHeight * (cell.row - tbo.getFirstVisibleRow());
let orientation = Ci.nsITreeView.DROP_BEFORE;
if (cell.row == -1) {
// If the row is not valid we try to insert inside the resultNode.
orientation = Ci.nsITreeView.DROP_ON;
}
else if (PlacesUtils.nodeIsContainer(node) &&
eventY > rowHeight * 0.75) {
// If we are below the 75% of a container the treeview we try
// to drop after the node.
orientation = Ci.nsITreeView.DROP_AFTER;
}
else if (PlacesUtils.nodeIsContainer(node) &&
eventY > rowHeight * 0.25) {
// If we are below the 25% of a container the treeview we try
// to drop inside the node.
orientation = Ci.nsITreeView.DROP_ON;
}
if (!this.view.canDrop(cell.row, orientation, event.dataTransfer))
return;
event.preventDefault();
event.stopPropagation();
]]></handler>
<handler event="dragend"><![CDATA[
PlacesControllerDragHelper.currentDropTarget = null;
]]></handler>
</handlers>
</binding>
</bindings>
|