зеркало из https://github.com/mozilla/gecko-dev.git
Bug 480238 - Double-clicking tree column separator opens highlighted link, r=enn
This commit is contained in:
Родитель
8936cb9475
Коммит
2e934ca40b
|
@ -285,25 +285,34 @@ var PlacesOrganizer = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Handle clicks on the tree. If the user middle clicks on a URL, load that
|
||||
* URL according to rules. Single clicks or modified clicks do not result in
|
||||
* any special action, since they're related to selection.
|
||||
* Handle clicks on the tree.
|
||||
* Single Left click, right click or modified click do not result in any
|
||||
* special action, since they're related to selection.
|
||||
* @param aEvent
|
||||
* The mouse event.
|
||||
*/
|
||||
onTreeClick: function PO_onTreeClick(aEvent) {
|
||||
// Only handle clicks on tree children.
|
||||
if (aEvent.target.localName != "treechildren")
|
||||
return;
|
||||
|
||||
var currentView = aEvent.currentTarget;
|
||||
var selectedNode = currentView.selectedNode;
|
||||
if (selectedNode && aEvent.button == 1) {
|
||||
if (PlacesUtils.nodeIsURI(selectedNode))
|
||||
PlacesUIUtils.openNodeWithEvent(selectedNode, aEvent);
|
||||
else if (PlacesUtils.nodeIsContainer(selectedNode)) {
|
||||
// The command execution function will take care of seeing the
|
||||
// selection is a folder/container and loading its contents in
|
||||
// tabs for us.
|
||||
if (selectedNode) {
|
||||
var doubleClickOnFlatList = (aEvent.button == 0 && aEvent.detail == 2 &&
|
||||
aEvent.target.parentNode.flatList);
|
||||
var middleClick = (Event.button == 1 && aEvent.detail == 1);
|
||||
|
||||
if (PlacesUtils.nodeIsURI(selectedNode) &&
|
||||
(doubleClickOnFlatList || middleClick)) {
|
||||
// Open associated uri in the browser.
|
||||
PlacesOrganizer.openSelectedNode(aEvent);
|
||||
}
|
||||
else if (middleClick &&
|
||||
PlacesUtils.nodeIsContainer(selectedNode)) {
|
||||
// The command execution function will take care of seeing if the
|
||||
// selection is a folder or a different container type, and will
|
||||
// load its contents in tabs.
|
||||
PlacesUIUtils.openContainerNodeInTabs(selectedNode, aEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -464,7 +464,6 @@
|
|||
flatList="true"
|
||||
enableColumnDrag="true"
|
||||
onkeypress="if (event.keyCode == KeyEvent.DOM_VK_RETURN) PlacesOrganizer.openSelectedNode(event);"
|
||||
ondblclick="PlacesOrganizer.openSelectedNode(event);"
|
||||
onopenflatcontainer="PlacesOrganizer.openFlatContainer(aContainer);"
|
||||
onselect="PlacesOrganizer.onContentTreeSelect();"
|
||||
onfocus="PlacesOrganizer.onTreeFocus(event);"
|
||||
|
|
|
@ -966,8 +966,9 @@ function testtag_tree_TreeView_rows(tree, testid, rowInfo, startRow)
|
|||
function testtag_tree_TreeView_rows_sort(tree, testid, rowInfo)
|
||||
{
|
||||
// check if cycleHeader sorts the columns
|
||||
var columnIndex = 0;
|
||||
var view = tree.view;
|
||||
var column = tree.columns[0];
|
||||
var column = tree.columns[columnIndex];
|
||||
var columnElement = column.element;
|
||||
var sortkey = columnElement.getAttribute("sort");
|
||||
if (sortkey) {
|
||||
|
@ -984,6 +985,30 @@ function testtag_tree_TreeView_rows_sort(tree, testid, rowInfo)
|
|||
is(columnElement.getAttribute("sortDirection"), "", "cycleHeader column sortDirection natural");
|
||||
// XXXndeakin content view isSorted needs to be tested
|
||||
}
|
||||
|
||||
// Check that clicking on column header sorts the column.
|
||||
var columns = getSortedColumnArray(tree);
|
||||
is(columnElement.getAttribute("sortDirection"), "",
|
||||
"cycleHeader column sortDirection");
|
||||
|
||||
// Click once on column header and check sorting has cycled once.
|
||||
mouseClickOnColumnHeader(columns, columnIndex, 0, 1);
|
||||
is(columnElement.getAttribute("sortDirection"), "ascending",
|
||||
"single click cycleHeader column sortDirection ascending");
|
||||
|
||||
// Now simulate a double click.
|
||||
mouseClickOnColumnHeader(columns, columnIndex, 0, 2);
|
||||
if (navigator.platform == "Win32") {
|
||||
// Windows cycles only once on double click.
|
||||
is(columnElement.getAttribute("sortDirection"), "descending",
|
||||
"double click cycleHeader column sortDirection descending");
|
||||
// 1 single clicks should restore natural sorting.
|
||||
mouseClickOnColumnHeader(columns, columnIndex, 0, 1);
|
||||
}
|
||||
|
||||
// Check we have gone back to natural sorting.
|
||||
is(columnElement.getAttribute("sortDirection"), "",
|
||||
"cycleHeader column sortDirection");
|
||||
}
|
||||
|
||||
// checks if the current and selected rows are correct
|
||||
|
@ -1211,6 +1236,21 @@ function mouseOnCell(tree, row, column, testname)
|
|||
synthesizeMouseExpectEvent(tree.body, x.value, y.value, {}, tree, "select", testname);
|
||||
}
|
||||
|
||||
function mouseClickOnColumnHeader(aColumns, aColumnIndex, aButton, aClickCount)
|
||||
{
|
||||
var columnHeader = aColumns[aColumnIndex].element;
|
||||
var columnHeaderRect = columnHeader.getBoundingClientRect();
|
||||
var columnWidth = columnHeaderRect.right - columnHeaderRect.left;
|
||||
// For multiple click we send separate click events, with increasing
|
||||
// clickCount. This simulates the common behavior of multiple clicks.
|
||||
for (var i = 1; i <= aClickCount; i++) {
|
||||
// Target the middle of the column header.
|
||||
synthesizeMouse(columnHeader, columnWidth / 2, 3,
|
||||
{ button: aButton,
|
||||
clickCount: i }, null);
|
||||
}
|
||||
}
|
||||
|
||||
function mouseDblClickOnCell(tree, row, column, testname)
|
||||
{
|
||||
// select the row we will edit
|
||||
|
|
|
@ -1326,6 +1326,13 @@
|
|||
if (event.target != event.originalTarget)
|
||||
return;
|
||||
|
||||
#ifdef XP_WIN
|
||||
// On Windows multiple clicking on tree columns only cycles one time
|
||||
// every 2 clicks.
|
||||
if (event.detail % 2 == 0)
|
||||
return;
|
||||
#endif
|
||||
|
||||
var tree = this.parentNode.parentNode;
|
||||
var column = tree.columns.getColumnFor(this);
|
||||
tree.view.cycleHeader(column);
|
||||
|
|
Загрузка…
Ссылка в новой задаче