зеркало из https://github.com/mozilla/gecko-dev.git
Bug 372508 part 2 - remove folderId getter. r=sspitzer.
This commit is contained in:
Родитель
0c07d55db2
Коммит
8d18c1a115
|
@ -1074,7 +1074,7 @@ var BookmarkPropertiesPanel = {
|
|||
if (!selectedNode)
|
||||
return;
|
||||
|
||||
var folderId = asFolder(selectedNode).folderId;
|
||||
var folderId = selectedNode.itemId;
|
||||
// Don't set the selected item if the static item for the folder is
|
||||
// already selected
|
||||
var oldSelectedItem = this._folderMenuList.selectedItem;
|
||||
|
|
|
@ -70,8 +70,8 @@ const NEWLINE = "\r\n";
|
|||
/**
|
||||
* Represents an insertion point within a container where we can insert
|
||||
* items.
|
||||
* @param aFolderId
|
||||
* The folderId of the parent container
|
||||
* @param aItemId
|
||||
* The identifier of the parent container
|
||||
* @param aIndex
|
||||
* The index within the container where we should insert
|
||||
* @param aOrientation
|
||||
|
@ -81,13 +81,13 @@ const NEWLINE = "\r\n";
|
|||
* is provided for informational purposes only!
|
||||
* @constructor
|
||||
*/
|
||||
function InsertionPoint(aFolderId, aIndex, aOrientation) {
|
||||
this.folderId = aFolderId;
|
||||
function InsertionPoint(aItemId, aIndex, aOrientation) {
|
||||
this.itemId = aItemId;
|
||||
this.index = aIndex;
|
||||
this.orientation = aOrientation;
|
||||
}
|
||||
InsertionPoint.prototype.toString = function IP_toString() {
|
||||
return "[object InsertionPoint(folder:" + this.folderId + ",index:" + this.index + ",orientation:" + this.orientation + ")]";
|
||||
return "[object InsertionPoint(folder:" + this.itemId + ",index:" + this.index + ",orientation:" + this.orientation + ")]";
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -142,8 +142,7 @@ PlacesController.prototype = {
|
|||
return false;
|
||||
|
||||
if (this._view.hasSingleSelection && PlacesUtils.nodeIsFolder(node)) {
|
||||
var contents = PlacesUtils.getFolderContents(asFolder(node).folderId,
|
||||
false, false);
|
||||
var contents = PlacesUtils.getFolderContents(node.itemId, false, false);
|
||||
for (var i = 0; i < contents.childCount; ++i) {
|
||||
var child = contents.getChild(i);
|
||||
if (PlacesUtils.nodeIsURI(child))
|
||||
|
@ -214,7 +213,7 @@ PlacesController.prototype = {
|
|||
if (this._view.hasSingleSelection) {
|
||||
var selectedNode = this._view.selectedNode;
|
||||
if (PlacesUtils.nodeIsFolder(selectedNode) &&
|
||||
selectedNode.folderId != PlacesUtils.bookmarks.toolbarFolder) {
|
||||
selectedNode.itemId != PlacesUtils.bookmarks.toolbarFolder) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -338,8 +337,7 @@ PlacesController.prototype = {
|
|||
return false;
|
||||
|
||||
// Disallow removing the toolbar folder
|
||||
if (PlacesUtils.nodeIsFolder(nodes[i]) &&
|
||||
asFolder(nodes[i]).folderId == btFolderId)
|
||||
if (PlacesUtils.nodeIsFolder(nodes[i]) && nodes[i].itemId == btFolderId)
|
||||
return false;
|
||||
|
||||
// We don't call nodeIsReadOnly here, because nodeIsReadOnly means that
|
||||
|
@ -498,7 +496,7 @@ PlacesController.prototype = {
|
|||
break;
|
||||
case Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER:
|
||||
nodeData["folder"] = true;
|
||||
uri = PlacesUtils.bookmarks.getFolderURI(asFolder(node).folderId);
|
||||
uri = PlacesUtils.bookmarks.getFolderURI(node.itemId);
|
||||
|
||||
// See nodeIsRemoteContainer
|
||||
if (asContainer(node).remoteContainerType != "")
|
||||
|
@ -732,7 +730,7 @@ PlacesController.prototype = {
|
|||
return;
|
||||
|
||||
if (PlacesUtils.nodeIsFolder(node))
|
||||
PlacesUtils.showFolderProperties(asFolder(node).folderId);
|
||||
PlacesUtils.showFolderProperties(node.itemId);
|
||||
else if (PlacesUtils.nodeIsBookmark(node))
|
||||
PlacesUtils.showBookmarkProperties(node.itemId);
|
||||
},
|
||||
|
@ -763,16 +761,16 @@ PlacesController.prototype = {
|
|||
#endif
|
||||
var folder = null;
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(selectedNode)) {
|
||||
folder = asFolder(selectedNode);
|
||||
folder = selectedNode;
|
||||
}
|
||||
#ifdef EXTENDED_LIVEBOOKMARKS_UI
|
||||
else if (PlacesUtils.nodeIsURI()) {
|
||||
if (PlacesUtils.nodeIsLivemarkItem(selectedNode))
|
||||
folder = asFolder(selectedNode.parent);
|
||||
folder = selectedNode.parent;
|
||||
}
|
||||
#endif
|
||||
if (folder)
|
||||
PlacesUtils.livemarks.reloadLivemarkFolder(folder.folderId);
|
||||
PlacesUtils.livemarks.reloadLivemarkFolder(folder.itemId);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -863,8 +861,7 @@ PlacesController.prototype = {
|
|||
// Open each uri in the folder in a tab.
|
||||
var index = firstIndex;
|
||||
var urlsToOpen = [];
|
||||
var contents = PlacesUtils.getFolderContents(asFolder(node).folderId,
|
||||
false, false);
|
||||
var contents = PlacesUtils.getFolderContents(node.itemId, false, false);
|
||||
for (var i = 0; i < contents.childCount; ++i) {
|
||||
var child = contents.getChild(i);
|
||||
if (PlacesUtils.nodeIsURI(child))
|
||||
|
@ -972,7 +969,7 @@ PlacesController.prototype = {
|
|||
var ip = this._view.insertionPoint;
|
||||
if (!ip)
|
||||
throw Cr.NS_ERROR_NOT_AVAILABLE;
|
||||
var txn = new PlacesCreateSeparatorTransaction(ip.folderId, ip.index);
|
||||
var txn = new PlacesCreateSeparatorTransaction(ip.itemId, ip.index);
|
||||
PlacesUtils.tm.doTransaction(txn);
|
||||
},
|
||||
|
||||
|
@ -990,7 +987,8 @@ PlacesController.prototype = {
|
|||
*/
|
||||
sortFolderByName: function PC_sortFolderByName() {
|
||||
var selectedNode = this._view.selectedNode;
|
||||
var txn = new PlacesSortFolderByNameTransaction(selectedNode.folderId, selectedNode.bookmarkIndex);
|
||||
var txn = new PlacesSortFolderByNameTransaction(selectedNode.itemId,
|
||||
selectedNode.bookmarkIndex);
|
||||
PlacesUtils.tm.doTransaction(txn);
|
||||
},
|
||||
|
||||
|
@ -1001,7 +999,7 @@ PlacesController.prototype = {
|
|||
if (!this._view.hasSingleSelection)
|
||||
return false;
|
||||
var selectedNode = this._view.selectedNode;
|
||||
var txn = new PlacesSetBookmarksToolbarTransaction(selectedNode.folderId);
|
||||
var txn = new PlacesSetBookmarksToolbarTransaction(selectedNode.itemId);
|
||||
PlacesUtils.tm.doTransaction(txn);
|
||||
},
|
||||
|
||||
|
@ -1061,19 +1059,19 @@ PlacesController.prototype = {
|
|||
|
||||
if (PlacesUtils.nodeIsFolder(node)) {
|
||||
// TODO -- node.parent might be a query and not a folder. See bug 324948
|
||||
var folder = asFolder(node);
|
||||
var folder = node;
|
||||
removedFolders.push(folder);
|
||||
transactions.push(new PlacesRemoveFolderTransaction(folder.folderId));
|
||||
transactions.push(new PlacesRemoveFolderTransaction(folder.itemId));
|
||||
}
|
||||
else if (PlacesUtils.nodeIsSeparator(node)) {
|
||||
// A Bookmark separator.
|
||||
transactions.push(new PlacesRemoveSeparatorTransaction(
|
||||
asFolder(node.parent).folderId, index));
|
||||
node.parent.itemId, index));
|
||||
}
|
||||
else if (PlacesUtils.nodeIsFolder(node.parent)) {
|
||||
// A Bookmark in a Bookmark Folder.
|
||||
transactions.push(new PlacesRemoveItemTransaction(node.itemId,
|
||||
PlacesUtils._uri(node.uri), asFolder(node.parent).folderId, index));
|
||||
PlacesUtils._uri(node.uri), node.parent.itemId, index));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1170,7 +1168,7 @@ PlacesController.prototype = {
|
|||
|
||||
// Allow dropping the feed uri of live-bookmark folders
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(node)) {
|
||||
var uri = PlacesUtils.livemarks.getFeedURI(asFolder(node).folderId);
|
||||
var uri = PlacesUtils.livemarks.getFeedURI(node.itemId);
|
||||
addURIData(uri.spec);
|
||||
}
|
||||
|
||||
|
@ -1218,7 +1216,7 @@ PlacesController.prototype = {
|
|||
|
||||
// Also copy the feed URI for live-bookmark folders
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(node)) {
|
||||
var uri = PlacesUtils.livemarks.getFeedURI(asFolder(node).folderId);
|
||||
var uri = PlacesUtils.livemarks.getFeedURI(node.itemId);
|
||||
generateURIChunks(uri.spec);
|
||||
}
|
||||
}
|
||||
|
@ -1317,7 +1315,8 @@ PlacesController.prototype = {
|
|||
var transactions = [];
|
||||
for (var i = 0; i < items.length; ++i) {
|
||||
transactions.push(PlacesUtils.makeTransaction(items[i], type.value,
|
||||
ip.folderId, ip.index, true));
|
||||
ip.itemId, ip.index,
|
||||
true));
|
||||
}
|
||||
return transactions;
|
||||
}
|
||||
|
@ -1469,7 +1468,7 @@ var PlacesControllerDragHelper = {
|
|||
var unwrapped = PlacesUtils.unwrapNodes(data.value.data,
|
||||
flavor.value)[0];
|
||||
transactions.push(PlacesUtils.makeTransaction(unwrapped,
|
||||
flavor.value, insertionPoint.folderId,
|
||||
flavor.value, insertionPoint.itemId,
|
||||
insertionPoint.index, copy));
|
||||
}
|
||||
|
||||
|
@ -1841,26 +1840,20 @@ function PlacesRemoveFolderTransaction(id) {
|
|||
}
|
||||
PlacesRemoveFolderTransaction.prototype = {
|
||||
__proto__: PlacesBaseTransaction.prototype,
|
||||
getFolderContents:
|
||||
function(aFolderId, aExcludeItems, aExpandQueries) {
|
||||
return PlacesUtils.getFolderContents(aFolderId, aExcludeItems, aExpandQueries);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a flat, ordered list of transactions for a depth-first recreation
|
||||
* of items within this folder.
|
||||
*/
|
||||
_saveFolderContents: function PRFT__saveFolderContents() {
|
||||
this._transactions = [];
|
||||
var contents = this.getFolderContents(this._id, false, false);
|
||||
var contents = this.utils.getFolderContents(this._id, false, false);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
for (var i = 0; i < contents.childCount; ++i) {
|
||||
var child = contents.getChild(i);
|
||||
var txn;
|
||||
if (child.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER) {
|
||||
var folder = asFolder(child);
|
||||
txn = new PlacesRemoveFolderTransaction(folder.folderId);
|
||||
txn = new PlacesRemoveFolderTransaction(child.itemId);
|
||||
}
|
||||
else if (child.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR) {
|
||||
txn = new PlacesRemoveSeparatorTransaction(this._id, i);
|
||||
|
|
|
@ -238,7 +238,7 @@
|
|||
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(child)) {
|
||||
element.setAttribute("livemark", "true");
|
||||
var folder = asFolder(child).folderId;
|
||||
var folder = child.itemId;
|
||||
var siteURI = PlacesUtils.livemarks.getSiteURI(folder);
|
||||
if (siteURI) {
|
||||
element.setAttribute("siteURI", siteURI.spec);
|
||||
|
@ -403,13 +403,13 @@
|
|||
var index = -1;
|
||||
var folderId = 0;
|
||||
if (PlacesUtils.nodeIsFolder(this._resultNode))
|
||||
folderId = this._resultNode.QueryInterface(Ci.nsINavHistoryFolderResultNode).folderId;
|
||||
folderId = this._resultNode.itemId;
|
||||
|
||||
if (this.hasSelection) {
|
||||
if(PlacesUtils.nodeIsFolder(this.selectedNode)) {
|
||||
if (PlacesUtils.nodeIsFolder(this.selectedNode)) {
|
||||
// If there is a folder selected, the insertion point is the
|
||||
// end of the folder.
|
||||
folderId = this.selectedNode.QueryInterface(Ci.nsINavHistoryFolderResultNode).folderId;
|
||||
folderId = this.selectedNode.itemId;
|
||||
} else {
|
||||
// If there is another type of node selected, the insertion point
|
||||
// is after that node.
|
||||
|
@ -545,7 +545,6 @@
|
|||
if (!PlacesUtils.nodeIsFolder(this._self._result.root) ||
|
||||
!PlacesUtils.nodeIsFolder(resultNode))
|
||||
return null;
|
||||
asFolder(resultNode);
|
||||
|
||||
var dropPoint = { ip: null, beforeIndex: null, folderNode: null };
|
||||
// Loop through all the nodes to see which one this should
|
||||
|
@ -565,13 +564,14 @@
|
|||
// 50%, drop into the folder. If it's past that, drop below.
|
||||
if (event.clientY < nodeY + (nodeHeight * 0.25)) {
|
||||
// Drop above this folder.
|
||||
dropPoint.ip = new InsertionPoint(resultNode.folderId, i - start, -1);
|
||||
dropPoint.ip = new InsertionPoint(resultNode.itemId, i - start,
|
||||
-1);
|
||||
dropPoint.beforeIndex = i;
|
||||
return dropPoint;
|
||||
}
|
||||
else if (event.clientY < nodeY + (nodeHeight * 0.75)) {
|
||||
// Drop inside this folder.
|
||||
dropPoint.ip = new InsertionPoint(asFolder(xulNode.node).folderId, -1, 1);
|
||||
dropPoint.ip = new InsertionPoint(xulNode.node.itemId, -1, 1);
|
||||
dropPoint.beforeIndex = i;
|
||||
dropPoint.folderNode = xulNode;
|
||||
return dropPoint;
|
||||
|
@ -581,14 +581,14 @@
|
|||
// drop above the folder. Otherwise, drop below.
|
||||
if (event.clientY < nodeY + (nodeHeight / 2)) {
|
||||
// Drop above this bookmark.
|
||||
dropPoint.ip = new InsertionPoint(resultNode.folderId, i - start, -1);
|
||||
dropPoint.ip = new InsertionPoint(resultNode.itemId, i - start, -1);
|
||||
dropPoint.beforeIndex = i;
|
||||
return dropPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Should drop below the last node.
|
||||
dropPoint.ip = new InsertionPoint(resultNode.folderId, -1, 1);
|
||||
dropPoint.ip = new InsertionPoint(resultNode.itemId, -1, 1);
|
||||
dropPoint.beforeIndex = -1;
|
||||
return dropPoint;
|
||||
},
|
||||
|
|
|
@ -61,11 +61,11 @@ var gMoveBookmarksDialog = {
|
|||
// ever do so
|
||||
return;
|
||||
}
|
||||
var selectedFolderID = asFolder(selectedNode).folderId;
|
||||
var selectedFolderID = selectedNode.itemId;
|
||||
|
||||
var transactions = [];
|
||||
for (var i=0; i < this._nodes.length; i++) {
|
||||
var parentId = asFolder(this._nodes[i].parent).folderId;
|
||||
var parentId = this._nodes[i].parent.itemId;
|
||||
|
||||
// Nothing to do if the node is already under the selected folder
|
||||
if (parentId == selectedFolderID)
|
||||
|
@ -74,9 +74,9 @@ var gMoveBookmarksDialog = {
|
|||
var nodeIndex = PlacesUtils.getIndexOfNode(this._nodes[i]);
|
||||
if (PlacesUtils.nodeIsFolder(this._nodes[i])) {
|
||||
// Disallow moving a folder into itself
|
||||
if (asFolder(this._nodes[i]).folderId != selectedFolderID) {
|
||||
if (this._nodes[i].itemId != selectedFolderID) {
|
||||
transactions.push(new
|
||||
PlacesMoveFolderTransaction(asFolder(this._nodes[i]).folderId,
|
||||
PlacesMoveFolderTransaction(this._nodes[i].itemId,
|
||||
parentId, nodeIndex,
|
||||
selectedFolderID, -1));
|
||||
}
|
||||
|
|
|
@ -319,8 +319,7 @@ var PlacesOrganizer = {
|
|||
if (selectedNode) {
|
||||
if (PlacesUtils.nodeIsFolder(selectedNode)) {
|
||||
var childsCount =
|
||||
PlacesUtils.getFolderContents(asFolder(selectedNode).folderId)
|
||||
.childCount;
|
||||
PlacesUtils.getFolderContents(selectedNode.itemId).childCount;
|
||||
statusText = PlacesUtils.getFormattedString("status_foldercount",
|
||||
[childsCount]);
|
||||
}
|
||||
|
@ -364,7 +363,7 @@ var PlacesSearchBox = {
|
|||
|
||||
switch (PlacesSearchBox.filterCollection) {
|
||||
case "collection":
|
||||
var folderId = asFolder(content.getResult().root).folderId;
|
||||
var folderId = content.getResult().root.itemId;
|
||||
content.applyFilter(filterString, true, folderId, OptionsFilter);
|
||||
PO.setHeaderText(PO.HEADER_TYPE_SEARCH, filterString);
|
||||
break;
|
||||
|
|
|
@ -257,7 +257,7 @@
|
|||
button.setAttribute("container", "true");
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(child)) {
|
||||
button.setAttribute("livemark", "true");
|
||||
var folder = asFolder(child).folderId;
|
||||
var folder = child.itemId;
|
||||
|
||||
// duplicate nsLivemarkService.getSiteURI to avoid instantiating
|
||||
// the service on startup.
|
||||
|
@ -302,7 +302,7 @@
|
|||
<parameter name="child"/>
|
||||
<body><![CDATA[
|
||||
if (PlacesUtils.nodeIsFolder(parent) &&
|
||||
asFolder(parent).folderId == PlacesUtils.bookmarks.toolbarFolder)
|
||||
parent.itemId == PlacesUtils.bookmarks.toolbarFolder)
|
||||
return this.removeChild(child);
|
||||
return null;
|
||||
]]></body>
|
||||
|
@ -459,13 +459,13 @@
|
|||
<getter><![CDATA[
|
||||
// By default, the insertion point is at the top level, at the end.
|
||||
var index = -1;
|
||||
var folderId = this._result.root.QueryInterface(Ci.nsINavHistoryFolderResultNode).folderId;
|
||||
var folderId = this._result.root.itemId;
|
||||
|
||||
if (this.hasSelection) {
|
||||
if(PlacesUtils.nodeIsFolder(this.selectedNode)) {
|
||||
// If there is a folder selected, the insertion point is the
|
||||
// end of the folder.
|
||||
folderId = this.selectedNode.QueryInterface(Ci.nsINavHistoryFolderResultNode).folderId;
|
||||
folderId = this.selectedNode.itemId;
|
||||
} else {
|
||||
// If there is another type of node selected, the insertion point
|
||||
// is after that node.
|
||||
|
@ -619,7 +619,6 @@
|
|||
var result = this._self.getResult();
|
||||
if (!PlacesUtils.nodeIsFolder(result.root))
|
||||
return null;
|
||||
asFolder(result.root);
|
||||
|
||||
var dropPoint = { ip: null, beforeIndex: null, folderNode: null };
|
||||
// Loop through all the nodes to see which one this should
|
||||
|
@ -634,13 +633,13 @@
|
|||
// 50%, drop into the folder. If it's past that, drop to the right.
|
||||
if (event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width * 0.25)) {
|
||||
// Drop to the left of this folder.
|
||||
dropPoint.ip = new InsertionPoint(result.root.folderId, i, -1);
|
||||
dropPoint.ip = new InsertionPoint(result.root.itemId, i, -1);
|
||||
dropPoint.beforeIndex = i;
|
||||
return dropPoint;
|
||||
}
|
||||
else if (event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width * 0.75)) {
|
||||
// Drop inside this folder.
|
||||
dropPoint.ip = new InsertionPoint(asFolder(xulNode.node).folderId, -1, 1);
|
||||
dropPoint.ip = new InsertionPoint(xulNode.node.itemId, -1, 1);
|
||||
dropPoint.beforeIndex = i;
|
||||
dropPoint.folderNode = xulNode;
|
||||
return dropPoint;
|
||||
|
@ -650,14 +649,14 @@
|
|||
// drop to the left of the folder. If it's right, drop to the right.
|
||||
if (event.clientX < xulNode.boxObject.x + (xulNode.boxObject.width / 2)) {
|
||||
// Drop to the left of this bookmark.
|
||||
dropPoint.ip = new InsertionPoint(result.root.folderId, i, -1);
|
||||
dropPoint.ip = new InsertionPoint(result.root.itemId, i, -1);
|
||||
dropPoint.beforeIndex = i;
|
||||
return dropPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Should drop to the right of the last node.
|
||||
dropPoint.ip = new InsertionPoint(result.root.folderId, -1, 1);
|
||||
dropPoint.ip = new InsertionPoint(result.root.itemId, -1, 1);
|
||||
dropPoint.beforeIndex = -1;
|
||||
return dropPoint;
|
||||
},
|
||||
|
|
|
@ -462,7 +462,7 @@
|
|||
if (this.hasSingleSelection && resultView.isContainer(max.value) &&
|
||||
(resultView.isContainerOpen(max.value) ||
|
||||
resultView.nodeForTreeIndex(max.value)
|
||||
.folderId == PlacesUtils.bookmarksRootId))
|
||||
.itemId == PlacesUtils.bookmarksRootId))
|
||||
orientation = NHRVO.DROP_ON;
|
||||
|
||||
return this._getInsertionPoint(max.value, orientation);
|
||||
|
@ -478,7 +478,7 @@
|
|||
var container = result.root;
|
||||
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 folderId).
|
||||
// the view is populated from (i.e. the result's itemId).
|
||||
if (index != -1) {
|
||||
var lastSelected = resultview.nodeForTreeIndex(index);
|
||||
if (resultview.isContainer(index) && orientation == NHRVO.DROP_ON) {
|
||||
|
@ -501,8 +501,8 @@
|
|||
// * Disallow insertion of items under the places root
|
||||
if (PlacesUtils.nodeIsFolder(container) &&
|
||||
!PlacesUtils.nodeIsReadOnly(container) &&
|
||||
container.folderId != PlacesUtils.placesRootId)
|
||||
return new InsertionPoint(asFolder(container).folderId, index, orientation);
|
||||
container.itemId != PlacesUtils.placesRootId)
|
||||
return new InsertionPoint(container.itemId, index, orientation);
|
||||
return null;
|
||||
]]></body>
|
||||
</method>
|
||||
|
@ -584,13 +584,11 @@
|
|||
var childNode = node.getChild(child);
|
||||
if (!PlacesUtils.nodeIsFolder(childNode))
|
||||
continue;
|
||||
|
||||
var childFolder = asFolder(childNode);
|
||||
|
||||
// See if child matches an ID we wanted; add to results.
|
||||
if (childFolder.folderId in indexes) {
|
||||
nodes[childFolder.folderId] = childFolder;
|
||||
delete indexes[childFolder.folderId];
|
||||
if (childNode.itemId in indexes) {
|
||||
nodes[childFolder.itemId] = childFolder;
|
||||
delete indexes[childFolder.itemId];
|
||||
}
|
||||
|
||||
// Search down that child's subtree.
|
||||
|
@ -720,34 +718,33 @@
|
|||
// another result node (that constructed by |getFolderContents| say,
|
||||
// instead of the displayed tree view). So we need to walk the
|
||||
// children of the result to find the right folder.
|
||||
function findFolder(folderId, container) {
|
||||
var wasOpen = container.containerOpen;
|
||||
container.containerOpen = true;
|
||||
var cc = container.childCount;
|
||||
function findFolder(aItemId, aContainer) {
|
||||
var wasOpen = aContainer.containerOpen;
|
||||
aContainer.containerOpen = true;
|
||||
var cc = aContainer.childCount;
|
||||
var foundNode = null;
|
||||
for (var i = 0; i < cc; ++i) {
|
||||
var node = container.getChild(i);
|
||||
var node = aContainer.getChild(i);
|
||||
if (PlacesUtils.nodeIsFolder(node)) {
|
||||
var folder = asFolder(node);
|
||||
if (folder.folderId == folderId) {
|
||||
if (folder.itemId == aItemId) {
|
||||
foundNode = node;
|
||||
break;
|
||||
}
|
||||
foundNode = findFolder(folderId, folder);
|
||||
foundNode = findFolder(aItemId, node);
|
||||
if (foundNode)
|
||||
break;
|
||||
}
|
||||
}
|
||||
container.containerOpen = wasOpen;
|
||||
aContainer.containerOpen = wasOpen;
|
||||
return foundNode;
|
||||
}
|
||||
var folder = null;
|
||||
var root = asContainer(this.getResult().root);
|
||||
if (PlacesUtils.nodeIsFolder(root) &&
|
||||
asFolder(root).folderId == insertionPoint.folderId)
|
||||
root.itemId == insertionPoint.itemId)
|
||||
folder = root;
|
||||
else
|
||||
folder = findFolder(insertionPoint.folderId, root);
|
||||
folder = findFolder(insertionPoint.itemId, root);
|
||||
|
||||
// Since we find the folder manually, using findFolder instead of
|
||||
// PlacesUtils.getFolderContents, the folder is not opened for
|
||||
|
|
|
@ -58,7 +58,6 @@ function QI_node(aNode, aIID) {
|
|||
NS_ASSERT(result, "Node QI Failed");
|
||||
return result;
|
||||
}
|
||||
function asFolder(aNode) { return QI_node(aNode, Ci.nsINavHistoryFolderResultNode); }
|
||||
function asVisit(aNode) { return QI_node(aNode, Ci.nsINavHistoryVisitResultNode); }
|
||||
function asFullVisit(aNode){ return QI_node(aNode, Ci.nsINavHistoryFullVisitResultNode);}
|
||||
function asContainer(aNode){ return QI_node(aNode, Ci.nsINavHistoryContainerResultNode);}
|
||||
|
@ -288,7 +287,7 @@ var PlacesUtils = {
|
|||
NS_ASSERT(aNode, "null node");
|
||||
|
||||
if (this.nodeIsFolder(aNode))
|
||||
return this.bookmarks.getFolderReadonly(asFolder(aNode).folderId);
|
||||
return this.bookmarks.getFolderReadonly(aNode.itemId);
|
||||
if (this.nodeIsQuery(aNode))
|
||||
return asQuery(aNode).childrenReadOnly;
|
||||
return false;
|
||||
|
@ -388,7 +387,7 @@ var PlacesUtils = {
|
|||
NS_ASSERT(aNode, "null node");
|
||||
|
||||
return this.nodeIsFolder(aNode) &&
|
||||
this.bookmarks.getFolderReadonly(asFolder(aNode).folderId);
|
||||
this.bookmarks.getFolderReadonly(aNode.itemId);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -436,9 +435,7 @@ var PlacesUtils = {
|
|||
// bookmark: <itemId>\n<uri>\n<parentId>\n<indexInParent>
|
||||
// separator: 0\n<>\n<parentId>\n<indexInParent>
|
||||
var wrapped = "";
|
||||
if (this.nodeIsFolder(aNode))
|
||||
wrapped += asFolder(aNode).folderId + NEWLINE;
|
||||
else if (this.nodeIsBookmark(aNode))
|
||||
if (aNode.itemId != -1) //
|
||||
wrapped += aNode.itemId + NEWLINE;
|
||||
else
|
||||
wrapped += "0" + NEWLINE;
|
||||
|
@ -449,7 +446,7 @@ var PlacesUtils = {
|
|||
wrapped += NEWLINE;
|
||||
|
||||
if (this.nodeIsFolder(aNode.parent))
|
||||
wrapped += asFolder(aNode.parent).folderId + NEWLINE;
|
||||
wrapped += aNode.parent.itemId + NEWLINE;
|
||||
else
|
||||
wrapped += "0" + NEWLINE;
|
||||
|
||||
|
@ -537,10 +534,9 @@ var PlacesUtils = {
|
|||
var txn = null;
|
||||
var node = children.getChild(i);
|
||||
if (self.nodeIsFolder(node)) {
|
||||
var nodeFolderId = asFolder(node).folderId;
|
||||
var nodeFolderId = node.itemId;
|
||||
var title = self.bookmarks.getItemTitle(nodeFolderId);
|
||||
// XXXmano: use item-annotations once bug 372508 is fixed
|
||||
var annos = self.getAnnotationsForURI(self._uri(node.uri));
|
||||
var annos = self.getAnnotationsForItem(nodeFolderId);
|
||||
var folderItemsTransactions =
|
||||
getChildItemsTransactions(nodeFolderId);
|
||||
txn = new PlacesCreateFolderTransaction(title, -1, aIndex, annos,
|
||||
|
|
|
@ -1822,9 +1822,8 @@ nsPlacesImportExportService::WriteContainerContents(PRInt64 aFolder, const nsACS
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (type == nsINavHistoryResultNode::RESULT_TYPE_FOLDER) {
|
||||
// bookmarks folder
|
||||
nsCOMPtr<nsINavHistoryFolderResultNode> folderNode = do_QueryInterface(child);
|
||||
PRInt64 folderId;
|
||||
rv = folderNode->GetItemId(&folderId);
|
||||
rv = child->GetItemId(&folderId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (aFolder == mPlacesRoot && (folderId == mToolbarFolder ||
|
||||
folderId == mBookmarksRoot)) {
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
interface nsIFile;
|
||||
interface nsINavHistoryContainerResultNode;
|
||||
interface nsINavHistoryQueryResultNode;
|
||||
interface nsINavHistoryFolderResultNode;
|
||||
interface nsINavHistoryQuery;
|
||||
interface nsINavHistoryQueryOptions;
|
||||
interface nsINavHistoryResult;
|
||||
|
@ -81,7 +80,7 @@ interface nsINavHistoryResultNode : nsISupports
|
|||
const PRUint32 RESULT_TYPE_HOST = 3; // nsINavHistoryContainerResultNode
|
||||
const PRUint32 RESULT_TYPE_REMOTE_CONTAINER = 4; // nsINavHistoryContainerResultNode
|
||||
const PRUint32 RESULT_TYPE_QUERY = 5; // nsINavHistoryQueryResultNode
|
||||
const PRUint32 RESULT_TYPE_FOLDER = 6; // nsINavHistoryFolderResultNode
|
||||
const PRUint32 RESULT_TYPE_FOLDER = 6; // nsINavHistoryQueryResultNode
|
||||
const PRUint32 RESULT_TYPE_SEPARATOR = 7; // nsINavHistoryResultNode
|
||||
const PRUint32 RESULT_TYPE_DAY = 8; // nsINavHistoryContainerResultNode
|
||||
readonly attribute PRUint32 type;
|
||||
|
@ -395,24 +394,6 @@ interface nsINavHistoryQueryResultNode : nsINavHistoryContainerResultNode
|
|||
readonly attribute nsINavHistoryQueryOptions queryOptions;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Represents a bookmark folder (type == RESULT_TYPE_FOLDER). It derives from a
|
||||
* query result because it can provide a query that will result in the
|
||||
* contents.
|
||||
*/
|
||||
[scriptable, uuid(f3160bfe-ebb3-453b-b25e-19d0b9c425b1)]
|
||||
interface nsINavHistoryFolderResultNode : nsINavHistoryQueryResultNode
|
||||
{
|
||||
/**
|
||||
* ID of the folder corresponding to this node.
|
||||
* Only valid for RESULT_TYPE_QUERY nodes where exactly one folder
|
||||
* has been specified in the query. 0 in all other cases.
|
||||
*/
|
||||
readonly attribute PRInt64 folderId;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Allows clients of the HistoryResult to define domain specific handling
|
||||
* of specific nsITreeView methods that the HistoryResult does not implement.
|
||||
|
@ -702,11 +683,8 @@ interface nsINavHistoryResult : nsISupports
|
|||
attribute nsINavHistoryResultViewer viewer;
|
||||
|
||||
/**
|
||||
* This is the root of the results. It will either be a
|
||||
* nsINavHistoryFolderResultNode (if the query is for bookmarks matching a
|
||||
* single folder) or just a nsINavHistoryQueryResultNode (for everything
|
||||
* else). Remember that you need to open all containers for their contents
|
||||
* to be valid.
|
||||
* This is the root of the results. Remember that you need to open all
|
||||
* containers for their contents to be valid.
|
||||
*/
|
||||
readonly attribute nsINavHistoryQueryResultNode root;
|
||||
};
|
||||
|
|
|
@ -2574,10 +2574,9 @@ nsNavHistoryQueryResultNode::OnFolderChanged(PRInt64 aFolder,
|
|||
// Therefore, if we are in a treeview AND our parent is visible, we will
|
||||
// keep incremental updating.
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsNavHistoryFolderResultNode,
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsNavHistoryFolderResultNode,
|
||||
nsNavHistoryContainerResultNode,
|
||||
nsINavHistoryQueryResultNode,
|
||||
nsINavHistoryFolderResultNode)
|
||||
nsINavHistoryQueryResultNode)
|
||||
|
||||
nsNavHistoryFolderResultNode::nsNavHistoryFolderResultNode(
|
||||
const nsACString& aTitle, nsNavHistoryQueryOptions* aOptions,
|
||||
|
|
|
@ -692,7 +692,7 @@ public:
|
|||
// of the folder in sync with the bookmark service.
|
||||
|
||||
class nsNavHistoryFolderResultNode : public nsNavHistoryContainerResultNode,
|
||||
public nsINavHistoryFolderResultNode
|
||||
public nsINavHistoryQueryResultNode
|
||||
{
|
||||
public:
|
||||
nsNavHistoryFolderResultNode(const nsACString& aTitle,
|
||||
|
@ -710,9 +710,6 @@ public:
|
|||
NS_IMETHOD GetChildrenReadOnly(PRBool *aChildrenReadOnly);
|
||||
NS_DECL_NSINAVHISTORYQUERYRESULTNODE
|
||||
|
||||
NS_IMETHOD GetFolderId(PRInt64* aFolderId)
|
||||
{ *aFolderId = mItemId; return NS_OK; }
|
||||
|
||||
virtual nsresult OpenContainer();
|
||||
|
||||
// This object implements a bookmark observer interface without deriving from
|
||||
|
|
Загрузка…
Ссылка в новой задаче