From 2a31e2e4197f24c8dd84fc889a0545841f865721 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Wed, 11 Aug 2010 18:05:10 +0200 Subject: [PATCH] bug 570788 - Incorporate improvements from SeaMonkey places review into Firefox code, round 4 (tree), r=mak a=gavin --- browser/components/places/content/tree.xml | 1 - browser/components/places/content/treeView.js | 48 ++++++++----------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/browser/components/places/content/tree.xml b/browser/components/places/content/tree.xml index ad46c1e753c..eed2cb61f66 100644 --- a/browser/components/places/content/tree.xml +++ b/browser/components/places/content/tree.xml @@ -780,4 +780,3 @@ - diff --git a/browser/components/places/content/treeView.js b/browser/components/places/content/treeView.js index a4d97fbeffe..970824a8976 100644 --- a/browser/components/places/content/treeView.js +++ b/browser/components/places/content/treeView.js @@ -37,11 +37,21 @@ * * ***** END LICENSE BLOCK ***** */ +function PlacesTreeView(aFlatList, aOnOpenFlatContainer) { + this._tree = null; + this._result = null; + this._selection = null; + this._rootNode = null; + this._rows = []; + this._flatList = aFlatList; + this._openContainerCallback = aOnOpenFlatContainer; +} + PlacesTreeView.prototype = { _makeAtom: function PTV__makeAtom(aString) { - return Cc["@mozilla.org/atom-service;1"]. - getService(Ci.nsIAtomService). - getAtom(aString); + return Cc["@mozilla.org/atom-service;1"]. + getService(Ci.nsIAtomService). + getAtom(aString); }, _atoms: [], @@ -122,8 +132,7 @@ PlacesTreeView.prototype = { if (!(aContainer instanceof Ci.nsINavHistoryQueryResultNode)) return aContainer._plainContainer = false; - let resultType = aContainer.queryOptions.resultType; - switch (resultType) { + switch (aContainer.queryOptions.resultType) { case Ci.nsINavHistoryQueryOptions.RESULTS_AS_DATE_QUERY: case Ci.nsINavHistoryQueryOptions.RESULTS_AS_SITE_QUERY: case Ci.nsINavHistoryQueryOptions.RESULTS_AS_DATE_SITE_QUERY: @@ -602,8 +611,7 @@ PlacesTreeView.prototype = { return; // Bail out for hidden separators. - if (PlacesUtils.nodeIsSeparator(aNode) && - this._result.sortingMode != Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) + if (PlacesUtils.nodeIsSeparator(aNode) && this.isSorted()) return; let parentRow; @@ -632,7 +640,7 @@ PlacesTreeView.prototype = { // children themselves that would be in the way. let cc = aParentNode.childCount; let separatorsAreHidden = PlacesUtils.nodeIsSeparator(aNode) && - this._result.sortingMode != Ci.nsINavHistoryQueryOptions.SORT_BY_NONE; + this.isSorted(); for (let i = aNewIndex + 1; i < cc; i++) { let node = aParentNode.getChild(i); if (!separatorsAreHidden || PlacesUtils.nodeIsSeparator(node)) { @@ -679,8 +687,7 @@ PlacesTreeView.prototype = { throw Cr.NS_ERROR_NOT_IMPLEMENTED; // Bail out for hidden separators. - if (PlacesUtils.nodeIsSeparator(aNode) && - this._result.sortingMode != Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) + if (PlacesUtils.nodeIsSeparator(aNode) && this.isSorted()) return; let parentRow = aParentNode == this._rootNode ? @@ -728,8 +735,7 @@ PlacesTreeView.prototype = { return; // Bail out for hidden separators. - if (PlacesUtils.nodeIsSeparator(aNode) && - this._result.sortingMode != Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) + if (PlacesUtils.nodeIsSeparator(aNode) && this.isSorted()) return; let oldRow = this._getRowForNode(aNode, true); @@ -1204,7 +1210,7 @@ PlacesTreeView.prototype = { else { // Use the last-selected node's container. container = lastSelected.parent; - + // During its Drag & Drop operation, the tree code closes-and-opens // containers very often (part of the XUL "spring-loaded folders" // implementation). And in certain cases, we may reach a closed @@ -1309,8 +1315,7 @@ PlacesTreeView.prototype = { getCellText: function PTV_getCellText(aRow, aColumn) { let node = this._getNodeForRow(aRow); - let columnType = this._getColumnType(aColumn); - switch (columnType) { + switch (this._getColumnType(aColumn)) { case this.COLUMN_TYPE_TITLE: // normally, this is just the title, but we don't want empty items in // the tree view so return a special string if the title is empty. @@ -1428,8 +1433,7 @@ PlacesTreeView.prototype = { let newSort; let newSortingAnnotation = ""; const NHQO = Ci.nsINavHistoryQueryOptions; - let columnType = this._getColumnType(aColumn); - switch (columnType) { + switch (this._getColumnType(aColumn)) { case this.COLUMN_TYPE_TITLE: if (oldSort == NHQO.SORT_BY_TITLE_ASCENDING) newSort = NHQO.SORT_BY_TITLE_DESCENDING; @@ -1576,13 +1580,3 @@ PlacesTreeView.prototype = { performActionOnRow: function(aAction, aRow) { }, performActionOnCell: function(aAction, aRow, aColumn) { } }; - -function PlacesTreeView(aFlatList, aOnOpenFlatContainer) { - this._tree = null; - this._result = null; - this._selection = null; - this._rootNode = null; - this._rows = []; - this._flatList = aFlatList; - this._openContainerCallback = aOnOpenFlatContainer; -}