Bug 387746 - New Left Pane for Places Organizer, along with other places back-end and front-end changes; also fixes bugs 393547, 395994, 401075, 403141. r=dietrich.

This commit is contained in:
mozilla.mano@sent.com 2007-11-19 18:01:53 -08:00
Родитель ca0977105f
Коммит 414bd17bf8
58 изменённых файлов: 731 добавлений и 1376 удалений

Просмотреть файл

@ -190,7 +190,8 @@ var PlacesCommandHook = {
}
catch (e) { }
var parent = aParent != undefined ? aParent : PlacesUtils.unfiledRootId;
var parent = aParent != undefined ?
aParent : PlacesUtils.unfiledBookmarksFolderId;
var descAnno = { name: DESCRIPTION_ANNO, value: description };
var txn = PlacesUtils.ptm.createItem(uri, parent, -1,
title, null, [descAnno]);

Просмотреть файл

@ -89,7 +89,7 @@
observes="isImage"/>
<!-- work-around bug 392512 -->
<command id="Browser:AddBookmarkAs"
oncommand="PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksRootId);"/>
oncommand="PlacesCommandHook.bookmarkCurrentPage(true, PlacesUtils.bookmarksMenuFolderId);"/>
<!-- The command is disabled for the hidden window. Otherwise its enabled
state is handled by the BookmarkAllTabsHandler object. -->
<command id="Browser:BookmarkAllTabs"

Просмотреть файл

@ -264,44 +264,9 @@ function BookmarkThisTab()
tab = getBrowser().mCurrentTab;
PlacesCommandHook.bookmarkPage(tab.linkedBrowser,
PlacesUtils.bookmarksRootId, true);
PlacesUtils.bookmarksMenuFolderId, true);
}
/**
* Global bookmarks observer for browser-window specific stuff
*/
var gBookmarksObserver = {
QueryInterface: function G_BO_QueryInterface(aIID) {
if (aIID.equals(Ci.nsINavBookmarkObserver) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_NOINTERFACE;
},
_toolbar: null,
get toolbar() {
if (!this._toolbar)
this._toolbar = document.getElementById("bookmarksBarContent");
return this._toolbar;
},
onBeginUpdateBatch: function() { },
onEndUpdateBatch: function() { },
onItemAdded: function() { },
onItemRemoved: function() { },
onItemChanged:
function G_BO_onItemChanged(aID, aProperty, aIsAnnotationProperty, aValue) {
if (aProperty == "became_toolbar_folder" && this.toolbar)
this.toolbar.place = PlacesUtils.getQueryStringForFolder(aID);
},
onItemVisited: function() { },
onItemMoved: function() { }
};
/**
* Initialize the bookmarks toolbar
*/
@ -344,13 +309,13 @@ function initPlacesDefaultQueries() {
var mostVisitedSitesTitle =
PlacesUtils.getString("mostVisitedSitesTitle");
var bookmarksRoot = PlacesUtils.bookmarksRootId;
var unfiledRoot = PlacesUtils.unfiledRootId;
var tagRoot = PlacesUtils.tagRootId;
var bookmarksMenuFolder = PlacesUtils.bookmarksMenuFolderId;
var unfiledBookmarksFolder = PlacesUtils.unfiledBookmarksFolderId;
var tagsFolder = PlacesUtils.tagsFolderId;
var defaultIndex = bmsvc.DEFAULT_INDEX;
// index = 0, make it the first folder
var placesFolder = bmsvc.createFolder(bmsvc.toolbarFolder,
var placesFolder = bmsvc.createFolder(PlacesUtils.toolbarFolderId,
placesFolderTitle,
0);
@ -360,7 +325,7 @@ function initPlacesDefaultQueries() {
// exclude queries so that user created "saved searches"
// and these queries (added automatically) are excluded
var recentlyCreatedBookmarksItem = bmsvc.insertBookmark(placesFolder,
IO.newURI("place:folder=" + bookmarksRoot + "&folder=" + unfiledRoot +
IO.newURI("place:folder=" + bookmarksMenuFolder + "&folder=" + unfiledBookmarksFolder +
"&queryType=" + Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS +
"&sort=" +
Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_DESCENDING +
@ -370,7 +335,7 @@ function initPlacesDefaultQueries() {
defaultIndex, recentlyCreatedBookmarksTitle);
var recentlyVisitedBookmarksItem = bmsvc.insertBookmark(placesFolder,
IO.newURI("place:folder=" + bookmarksRoot + "&folder=" + unfiledRoot +
IO.newURI("place:folder=" + bookmarksMenuFolder + "&folder=" + unfiledBookmarksFolder +
"&queryType=" + Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS +
"&sort=" + Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING +
"&excludeItemIfParentHasAnnotation=livemark%2FfeedURI" +
@ -378,7 +343,7 @@ function initPlacesDefaultQueries() {
defaultIndex, recentlyVisitedBookmarksTitle);
var mostVisitedBookmarksItem = bmsvc.insertBookmark(placesFolder,
IO.newURI("place:folder=" + bookmarksRoot + "&folder=" + unfiledRoot +
IO.newURI("place:folder=" + bookmarksMenuFolder + "&folder=" + unfiledBookmarksFolder +
"&queryType=" + Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS +
"&sort=" +
Ci.nsINavHistoryQueryOptions.SORT_BY_VISITCOUNT_DESCENDING +
@ -387,23 +352,21 @@ function initPlacesDefaultQueries() {
defaultIndex, mostVisitedBookmarksTitle);
var recentlyUsedTagsItem = bmsvc.insertBookmark(placesFolder,
IO.newURI("place:folder=" + tagRoot +
IO.newURI("place:folder=" + tagsFolder +
"&group=" + Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER +
"&queryType=" + Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS +
"&applyOptionsToContainers=1" +
"&sort=" +
Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_DESCENDING +
"&resolveNullBookmarkTitles=1" +
"&maxResults=" + maxResults),
defaultIndex, recentlyUsedTagsTitle);
var mostUsedTagsItem = bmsvc.insertBookmark(placesFolder,
IO.newURI("place:folder=" + tagRoot +
IO.newURI("place:folder=" + tagsFolder +
"&group=" + Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER +
"&queryType=" + Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS +
"&applyOptionsToContainers=1" +
"&sort=" + Ci.nsINavHistoryQueryOptions.SORT_BY_COUNT_DESCENDING +
"&resolveNullBookmarkTitles=1" +
"&maxResults=" + maxResults),
defaultIndex, mostUsedTagsTitle);
@ -419,7 +382,11 @@ function initPlacesDefaultQueries() {
try {
bmsvc.runInBatchMode(callback, null);
} finally {
}
catch(ex) {
Components.utils.reportError(ex);
}
finally {
// We need to persist this preference change, since we want to
// check it at next app start even if the browser exits abruptly
gPrefService.setBoolPref("browser.places.createdDefaultQueries", true);
@ -1076,7 +1043,6 @@ function delayedStartup()
initPlacesDefaultQueries();
initBookmarksToolbar();
PlacesUtils.bookmarks.addObserver(gBookmarksObserver, false);
PlacesStarButton.init();
// called when we go into full screen, even if it is
@ -1234,7 +1200,6 @@ function BrowserShutdown()
} catch (ex) {
}
PlacesUtils.bookmarks.removeObserver(gBookmarksObserver);
PlacesStarButton.uninit();
try {

Просмотреть файл

@ -1140,11 +1140,11 @@ nsContextMenu.prototype = {
},
bookmarkThisPage: function CM_bookmarkThisPage() {
window.top.PlacesCommandHook.bookmarkPage(this.browser, PlacesUtils.bookmarksRootId, true);
window.top.PlacesCommandHook.bookmarkPage(this.browser, PlacesUtils.bookmarksMenuFolderId, true);
},
bookmarkLink: function CM_bookmarkLink() {
window.top.PlacesCommandHook.bookmarkLink(PlacesUtils.bookmarksRootId, this.linkURL,
window.top.PlacesCommandHook.bookmarkLink(PlacesUtils.bookmarksMenuFolderId, this.linkURL,
this.linkText());
},

Просмотреть файл

@ -262,7 +262,7 @@ ImportBookmarksHTML(nsIFile* aBookmarksFile,
// Create an imported bookmarks folder under the bookmarks menu.
PRInt64 root;
rv = bms->GetBookmarksRoot(&root);
rv = bms->GetBookmarksMenuFolder(&root);
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 folder;

Просмотреть файл

@ -1174,7 +1174,7 @@ nsIEProfileMigrator::CopyFavorites(PRBool aReplace) {
nsCOMPtr<nsINavBookmarksService> bms(do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 root;
rv = bms->GetBookmarksRoot(&root);
rv = bms->GetBookmarksMenuFolder(&root);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString personalToolbarFolderName;

Просмотреть файл

@ -1050,7 +1050,7 @@ nsOperaProfileMigrator::CopyBookmarks(PRBool aReplace)
nsCOMPtr<nsINavBookmarksService> bms(do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 root;
rv = bms->GetBookmarksRoot(&root);
rv = bms->GetBookmarksMenuFolder(&root);
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 parentFolder = root;

Просмотреть файл

@ -905,7 +905,7 @@ nsSafariProfileMigrator::CopyBookmarks(PRBool aReplace)
nsCOMPtr<nsINavBookmarksService> bms(do_GetService(NS_NAVBOOKMARKSSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 root;
rv = bms->GetBookmarksRoot(&root);
rv = bms->GetBookmarksMenuFolder(&root);
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 folder;

Просмотреть файл

@ -201,7 +201,7 @@ var BookmarkPropertiesPanel = {
else {
// default to the bookmarks root
this._defaultInsertionPoint =
new InsertionPoint(PlacesUtils.bookmarks.bookmarksRoot, -1);
new InsertionPoint(PlacesUtils.bookmarksMenuFolderId, -1);
}
switch(dialogInfo.type) {
@ -1041,12 +1041,19 @@ var BookmarkPropertiesPanel = {
expander.getAttribute("tooltiptextup"));
document.documentElement.buttons = "accept,cancel,extra2";
if (!this._folderTree.treeBoxObject.view.isContainerOpen(0))
this._folderTree.treeBoxObject.view.toggleOpenState(0);
this._folderTree.selectFolders([this._getFolderIdFromMenuList()]);
this._folderTree.collapsed = false;
if (!this._folderTree.place) {
const FOLDER_TREE_PLACE_URI =
"place:excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1&folder=" +
PlacesUtils.allBookmarksFolderId;
this._folderTree.place = FOLDER_TREE_PLACE_URI;
}
var currentFolder = this._getFolderIdFromMenuList();
this._folderTree.selectItems([currentFolder]);
this._folderTree.focus();
this._folderTree.collapsed = false;
resizeTo(window.outerWidth, window.outerHeight + this._folderTreeHeight);
}
},
@ -1056,7 +1063,7 @@ var BookmarkPropertiesPanel = {
var selectedItem = this._folderMenuList.selectedItem
switch (selectedItem.id) {
case "bookmarksRootItem":
return PlacesUtils.bookmarksRootId;
return PlacesUtils.bookmarksMenuFolderId;
case "toolbarFolderItem":
return PlacesUtils.toolbarFolderId;
}
@ -1089,7 +1096,7 @@ var BookmarkPropertiesPanel = {
}
if (aCheckStaticFolderItems) {
if (aFolderId == PlacesUtils.bookmarksRootId)
if (aFolderId == PlacesUtils.bookmarksMenuFolderId)
return this._element("bookmarksRootItem")
if (aFolderId == PlacesUtils.toolbarFolderId)
return this._element("toolbarFolderItem")
@ -1106,7 +1113,7 @@ var BookmarkPropertiesPanel = {
if (this._folderTree.hidden)
return;
this._folderTree.selectFolders([this._getFolderIdFromMenuList()]);
this._folderTree.selectItems([this._getFolderIdFromMenuList()]);
},
onFolderTreeSelect: function BPP_onFolderTreeSelect() {
@ -1119,9 +1126,9 @@ var BookmarkPropertiesPanel = {
// already selected
var oldSelectedItem = this._folderMenuList.selectedItem;
if ((oldSelectedItem.id == "toolbarFolderItem" &&
folderId == PlacesUtils.bookmarks.toolbarFolder) ||
folderId == PlacesUtils.toolbarFolderId) ||
(oldSelectedItem.id == "bookmarksRootItem" &&
folderId == PlacesUtils.bookmarks.bookmarksRoot))
folderId == PlacesUtils.bookmarksMenuFolderId))
return;
var folderItem = this._getFolderMenuItem(folderId, false);

Просмотреть файл

@ -163,8 +163,6 @@
height="150"
persist="height"
onselect="BookmarkPropertiesPanel.onFolderTreeSelect();"
showRoot="true"
place="place:folder=2&amp;excludeItems=1&amp;excludeQueries=1&amp;excludeReadOnlyFolders=1"
hidecolumnpicker="true">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>

Просмотреть файл

@ -36,7 +36,9 @@
# ***** END LICENSE BLOCK *****
function init() {
document.getElementById('search-box').focus();
document.getElementById("bookmarks-view").place =
"place:queryType=1&folder=" + window.top.PlacesUtils.allBookmarksFolderId;
document.getElementById("search-box").focus();
}
function searchBookmarks(aSearchString) {
@ -45,5 +47,7 @@ function searchBookmarks(aSearchString) {
tree.place = tree.place;
else
tree.applyFilter(aSearchString, true,
[PlacesUtils.bookmarksRootId, PlacesUtils.unfiledRootId]);
[PlacesUtils.bookmarksMenuFolderId,
PlacesUtils.unfiledBookmarksFolderId,
PlacesUtils.toolbarFolderId]);
}

Просмотреть файл

@ -70,7 +70,6 @@
<tree id="bookmarks-view" class="sidebar-placesTree" type="places"
flex="1"
hidecolumnpicker="true"
place="place:folder=2&amp;queryType=1"
context="placesContext"
onkeypress="if (event.keyCode == 13) this.controller.openSelectedNodeWithEvent(event);"
onclick="SidebarUtils.handleClick(this, event);">

Просмотреть файл

@ -160,18 +160,6 @@ PlacesController.prototype = {
// Livemark containers
if (PlacesUtils.nodeIsLivemarkContainer(selectedNode))
return true;
#ifdef EXTENDED_LIVEBOOKMARKS_UI
// Subscriptions View - not yet exposed anywhere
if (selectedNode.uri.indexOf("livemark%2F") != -1)
return true;
// children of a live bookmark (legacy bookmarks UI doesn't support
// this)
if (PlacesUtils.nodeIsURI() &&
PlacesUtils.nodeIsLivemarkItem(selectedNode))
return true;
#endif
}
return false;
case "placesCmd_sortBy:name":
@ -181,15 +169,6 @@ PlacesController.prototype = {
!PlacesUtils.nodeIsReadOnly(selectedNode) &&
this._view.getResult().sortingMode ==
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE;
case "placesCmd_setAsBookmarksToolbarFolder":
if (this._view.hasSingleSelection) {
var selectedNode = this._view.selectedNode;
if (PlacesUtils.nodeIsFolder(selectedNode) &&
selectedNode.itemId != PlacesUtils.toolbarFolderId) {
return true;
}
}
return false;
default:
return false;
}
@ -266,7 +245,7 @@ PlacesController.prototype = {
this.moveSelectedBookmarks();
break;
case "placesCmd_reload":
this.reloadSelectedLivemarks();
this.reloadSelectedLivemark();
break;
case "placesCmd_reloadMicrosummary":
this.reloadSelectedMicrosummary();
@ -274,9 +253,6 @@ PlacesController.prototype = {
case "placesCmd_sortBy:name":
this.sortFolderByName();
break;
case "placesCmd_setAsBookmarksToolbarFolder":
this.setBookmarksToolbarFolder();
break;
}
},
@ -411,7 +387,6 @@ PlacesController.prototype = {
* "separator" node is a separator line
* "host" node is a host
* "mutable" node can have items inserted or reordered
* "allLivemarks" node is a query containing every livemark
*
* @returns an array of objects corresponding the selected nodes. Each
* object has each of the properties above set if its corresponding
@ -448,7 +423,6 @@ PlacesController.prototype = {
break;
case Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER:
nodeData["folder"] = true;
uri = PlacesUtils.bookmarks.getFolderURI(node.itemId);
break;
case Ci.nsINavHistoryResultNode.RESULT_TYPE_HOST:
nodeData["host"] = true;
@ -489,29 +463,15 @@ PlacesController.prototype = {
var names = PlacesUtils.annotations.getPageAnnotationNames(uri, {});
for (var j = 0; j < names.length; ++j)
nodeData[names[j]] = true;
}
// For items also include the item-specific annotations
if ("bookmark" in nodeData || "folder" in nodeData) {
names = PlacesUtils.annotations
.getItemAnnotationNames(node.itemId, {});
for (j = 0; j < names.length; ++j)
nodeData[names[j]] = true;
}
// For items also include the item-specific annotations
if (node.itemId != -1) {
names = PlacesUtils.annotations
.getItemAnnotationNames(node.itemId, {});
for (j = 0; j < names.length; ++j)
nodeData[names[j]] = true;
}
#ifdef EXTENDED_LIVEBOOKMARKS_UI
else if (nodeType == Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY) {
// Various queries might live in the left-hand side of the organizer
// window. If this one happens to have collected all the livemark feeds,
// allow its context menu to contain "Reload All Livemarks". That will
// usually only mean the Subscriptions folder, but if some other folder
// happens to use the same query, it's fine too. Queries have very
// limited data (no annotations), so we're left checking the query URI
// directly.
uri = PlacesUtils._uri(nodes[i].uri);
if (uri.spec == ORGANIZER_SUBSCRIPTIONS_QUERY)
nodeData["allLivemarks"] = true;
}
#endif
metadata.push(nodeData);
}
@ -716,32 +676,13 @@ PlacesController.prototype = {
},
/**
* Reloads the livemarks associated with the selection. For the
* "Subscriptions" folder, reloads all livemarks; for a livemark folder,
* reloads its children; for a single livemark, reloads its siblings (the
* children of its parent).
* Reloads the selected livemark if any.
*/
reloadSelectedLivemarks: function PC_reloadSelectedLivemarks() {
var selectedNode = this._view.selectedNode;
reloadSelectedLivemark: function PC_reloadSelectedLivemark() {
if (this._view.hasSingleSelection) {
#ifdef EXTENDED_LIVEBOOKMARKS_UI
if (selectedNode.uri.indexOf("livemark%2F") != -1) {
PlacesUtils.livemarks.reloadAllLivemarks();
return;
}
#endif
var folder = null;
if (PlacesUtils.nodeIsLivemarkContainer(selectedNode)) {
folder = selectedNode;
}
#ifdef EXTENDED_LIVEBOOKMARKS_UI
else if (PlacesUtils.nodeIsURI()) {
if (PlacesUtils.nodeIsLivemarkItem(selectedNode))
folder = selectedNode.parent;
}
#endif
if (folder)
PlacesUtils.livemarks.reloadLivemarkFolder(folder.itemId);
var selectedNode = this._view.selectedNode;
if (PlacesUtils.nodeIsLivemarkContainer(selectedNode))
PlacesUtils.livemarks.reloadLivemarkFolder(selectedNode.itemId);
}
},
@ -883,19 +824,6 @@ PlacesController.prototype = {
PlacesUtils.ptm.commitTransaction(txn);
},
/**
* Makes the selected node the bookmarks toolbar folder.
*/
setBookmarksToolbarFolder: function PC_setBookmarksToolbarFolder() {
if (!this._view.hasSingleSelection)
return;
var selectedNode = this._view.selectedNode;
var txn = PlacesUtils.ptm.setBookmarksToolbar(selectedNode.itemId);
PlacesUtils.ptm.commitTransaction(txn);
},
/**
* Walk the list of folders we're removing in this delete operation, and
* see if the selected node specified is already implicitly being removed
@ -1687,7 +1615,6 @@ function goUpdatePlacesCommands() {
updatePlacesCommand("placesCmd_new:separator");
updatePlacesCommand("placesCmd_show:info");
updatePlacesCommand("placesCmd_moveBookmarks");
updatePlacesCommand("placesCmd_setAsBookmarksToolbarFolder");
updatePlacesCommand("placesCmd_reload");
updatePlacesCommand("placesCmd_reloadMicrosummary");
updatePlacesCommand("placesCmd_sortBy:name");

Просмотреть файл

@ -205,12 +205,21 @@ var gEditItemOverlay = {
while (menupopup.childNodes.length > 4)
menupopup.removeChild(menupopup.lastChild);
// only show "All Bookmarks" if the url isn't bookmarked somewhere else
this._element("unfiledRootItem").hidden =
aSelectedFolder != PlacesUtils.unfiledRootId;
const bms = PlacesUtils.bookmarks;
const annos = PlacesUtils.annotations;
// Build the static list
var unfiledItem = this._element("unfiledRootItem");
unfiledItem.label = bms.getItemTitle(PlacesUtils.unfiledBookmarksFolderId);
// only show "Unfiled Bookmarks" if the url isn't bookmarked somewhere else
unfiledItem.hidden = aSelectedFolder != PlacesUtils.unfiledBookmarksFolderId;
this._element("bmRootItem").label =
bms.getItemTitle(PlacesUtils.bookmarksMenuFolderId);
this._element("toolbarFolderItem").label =
bms.getItemTitle(PlacesUtils.toolbarFolderId);
// List of recently used folders:
var annos = PlacesUtils.annotations;
var folderIds = annos.getItemsWithAnnotation(LAST_USED_ANNO, { });
/**
@ -571,25 +580,14 @@ var gEditItemOverlay = {
this._folderTree.collapsed = false;
if (!this._folderTree.place) {
const FOLDER_TREE_PLACE_URI =
"place:folder=2&excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1";
"place:excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1&folder=" +
window.top.PlacesUtils.allBookmarksFolderId;
this._folderTree.place = FOLDER_TREE_PLACE_URI;
}
var currentFolder = this._getFolderIdFromMenuList();
// Don't select anything in the tree if the item is "unfiled"
if (currentFolder == PlacesUtils.unfiledRootId)
this._folderTree.selectFolders([]);
else {
this._folderTree.selectFolders([currentFolder]);
this._folderTree.focus();
}
if ((currentFolder == PlacesUtils.bookmarksRootId ||
currentFolder == PlacesUtils.unfiledRootId) &&
!this._folderTree.treeBoxObject.view.isContainerOpen(0)) {
// Expand the root node if selectFolder didn't
this._folderTree.treeBoxObject.view.toggleOpenState(0);
}
this._folderTree.selectItems([currentFolder]);
this._folderTree.focus();
}
},
@ -598,9 +596,9 @@ var gEditItemOverlay = {
var selectedItem = this._folderMenuList.selectedItem
switch (selectedItem.id) {
case "editBMPanel_unfiledRootItem":
return PlacesUtils.unfiledRootId;
return PlacesUtils.unfiledBookmarksFolderId;
case "editBMPanel_bmRootItem":
return PlacesUtils.bookmarksRootId;
return PlacesUtils.bookmarksMenuFolderId;
case "editBMPanel_toolbarFolderItem":
return PlacesUtils.toolbarFolderId;
}
@ -633,9 +631,9 @@ var gEditItemOverlay = {
}
if (aCheckStaticFolderItems) {
if (aFolderId == PlacesUtils.unfiledRootId)
if (aFolderId == PlacesUtils.unfiledBookmarksFolderId)
return this._element("unfiledRootItem");
if (aFolderId == PlacesUtils.bookmarksRootId)
if (aFolderId == PlacesUtils.bookmarksMenuFolderId)
return this._element("bmRootItem");
if (aFolderId == PlacesUtils.toolbarFolderId)
return this._element("toolbarFolderItem");
@ -658,7 +656,7 @@ var gEditItemOverlay = {
// Mark the containing folder as recently-used if it isn't the
// "All Bookmarks" root
if (container != PlacesUtils.unfiledRootId)
if (container != PlacesUtils.unfiledBookmarksFolderId)
this._markFolderAsRecentlyUsed(container);
}
@ -666,7 +664,7 @@ var gEditItemOverlay = {
if (!this._folderTree.collapsed) {
var selectedNode = this._folderTree.selectedNode;
if (!selectedNode || selectedNode.itemId != container)
this._folderTree.selectFolders([container]);
this._folderTree.selectItems([container]);
}
},

Просмотреть файл

@ -41,6 +41,7 @@
]>
<?xml-stylesheet href="chrome://browser/skin/places/editBookmarkOverlay.css"?>
<?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
<overlay id="editBookmarkOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
@ -117,13 +118,10 @@
<menupopup>
<!-- Static item for special folders -->
<menuitem id="editBMPanel_unfiledRootItem"
label="&editBookmarkOverlay.allBookmarksFolderItem.label;"
class="menuitem-iconic folder-icon"/>
<menuitem id="editBMPanel_bmRootItem"
label="&editBookmarkOverlay.bookmarksMenuFolderItem.label;"
class="menuitem-iconic folder-icon"/>
<menuitem id="editBMPanel_toolbarFolderItem"
label="&editBookmarkOverlay.toolbarFolderItem.label;"
class="menuitem-iconic folder-icon"/>
<menuseparator id="editBMPanel_foldersSeparator" hidden="true"/>
</menupopup>
@ -143,7 +141,6 @@
height="150"
collapsed="true"
onselect="gEditItemOverlay.onFolderTreeSelect();"
showRoot="true"
hidecolumnpicker="true"
observes="paneElementsBroadcaster">
<treecols>

Просмотреть файл

@ -324,6 +324,10 @@
var title = aNode.title;
if (menuitem.getAttribute("label") != title)
menuitem.setAttribute("label", title);
if (!menuitem.hasAttribute("livemark") &&
PlacesUtils.nodeIsLivemarkContainer(aNode))
menuItem.setAttribute("livemark", "true");
},
itemReplaced:

Просмотреть файл

@ -52,9 +52,9 @@ var gMoveBookmarksDialog = {
this._nodes = window.arguments[0];
this._tm = window.arguments[1];
// select and expand the root node
this.foldersTree.selectFolders([PlacesUtils.bookmarksRootId]);
this.foldersTree.selectedNode.containerOpen = true;
this.foldersTree.place =
"place:excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1&folder=" +
PlacesUtils.allBookmarksFolderId;
},
onOK: function MBD_onOK(aEvent) {

Просмотреть файл

@ -67,9 +67,7 @@
class="placesTree"
flex="1"
type="places"
showRoot="true"
seltype="single"
place="place:folder=2&amp;excludeItems=1&amp;excludeReadOnlyFolders=1"
hidecolumnpicker="true">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>

Просмотреть файл

@ -37,35 +37,22 @@
*
* ***** END LICENSE BLOCK ***** */
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
/**
* Selects a place URI in the places list.
* This function is global so it can be easily accessed by openers.
* @param placeURI
* A place: URI string to select
*/
function selectPlaceURI(placeURI) {
PlacesOrganizer._places.selectPlaceURI(placeURI);
}
var PlacesOrganizer = {
_places: null,
_content: null,
_initFolderTree: function() {
var leftPaneRoot = PlacesUtils.leftPaneFolderId;
var allBookmarksId = PlacesUtils.allBookmarksFolderId;
this._places.place = "place:excludeItems=1&expandQueries=0&folder=" + leftPaneRoot;
this._places.selectItems([allBookmarksId]);
asContainer(this._places.selectedNode).containerOpen = true;
},
init: function PO_init() {
this._places = document.getElementById("placesList");
this._content = document.getElementById("placeContent");
OptionsFilter.init(Groupers);
Groupers.init();
// Select the specified place in the places list.
var placeURI = "place:";
if ("arguments" in window)
placeURI = window.arguments[0];
selectPlaceURI(placeURI);
this._initFolderTree();
var view = this._content.treeBoxObject.view;
if (view.rowCount > 0)
@ -140,99 +127,6 @@ var PlacesOrganizer = {
this.location = historyEntry;
},
HEADER_TYPE_SHOWING: 1,
HEADER_TYPE_SEARCH: 2,
HEADER_TYPE_ADVANCED_SEARCH: 3,
/**
* Updates the text shown in the heading banner above the content view.
* @param type
* The type of information being shown - normal (built-in history or
* other query, bookmark folder), search results from the toolbar
* search box, or advanced search.
* @param text
* The text (if any) to display
*/
setHeaderText: function PO_setHeaderText(type, text) {
NS_ASSERT(type == 1 || type == 2 || type == 3, "Invalid Header Type");
var prefix = document.getElementById("showingPrefix");
prefix.setAttribute("value",
PlacesUtils.getString("headerTextPrefix" + type));
var contentTitle = document.getElementById("contentTitle");
contentTitle.setAttribute("value", text);
},
onPlaceURIKeypress: function PO_onPlaceURIKeypress(aEvent) {
var keyCode = aEvent.keyCode;
if (keyCode == KeyEvent.DOM_VK_RETURN)
this.loadPlaceURI();
else if (keyCode == KeyEvent.DOM_VK_ESCAPE) {
event.target.value = "";
this.onPlaceSelected(true);
}
},
/**
* Shows or hides the debug panel.
*/
toggleDebugPanel: function PO_toggleDebugPanel() {
var dp = document.getElementById("debugPanel");
dp.hidden = !dp.hidden;
if (!dp.hidden)
document.getElementById("placeURI").focus();
},
/**
* Loads the place URI entered in the debug
*/
loadPlaceURI: function PO_loadPlaceURI() {
// clear forward history
this._forwardHistory.splice(0);
var placeURI = document.getElementById("placeURI");
var queriesRef = { }, optionsRef = { };
PlacesUtils.history.queryStringToQueries(placeURI.value,
queriesRef, { }, optionsRef);
// for debug panel
var autoFilterResults = document.getElementById("autoFilterResults");
if (autoFilterResults.checked) {
var options =
OptionsFilter.filter(queriesRef.value, optionsRef.value, null);
}
else
options = optionsRef.value;
this.location =
PlacesUtils.history.queriesToQueryString(queriesRef.value,
queriesRef.value.length,
options);
placeURI.value = this.location;
this.setHeaderText(this.HEADER_TYPE_SHOWING, "Debug results for: " + placeURI.value);
this.updateLoadedURI();
placeURI.focus();
},
/**
* Updates the URI displayed in the debug panel.
*/
updateLoadedURI: function PO_updateLoadedURI() {
var queryNode = asQuery(this._content.getResult().root);
var queries = queryNode.getQueries({});
var options = queryNode.queryOptions;
var loadedURI = document.getElementById("loadedURI");
loadedURI.value =
PlacesUtils.history.queriesToQueryString(queries, queries.length,
options);
},
/**
* Called when a place folder is selected in the left pane.
* @param resetSearchBox
@ -264,10 +158,6 @@ var PlacesOrganizer = {
searchFilter.reset();
}
this.setHeaderText(this.HEADER_TYPE_SHOWING, node.title);
this.updateLoadedURI();
// Update the "Find in <current collection>" command and the gray text in
// the search box in the toolbar if the active collection is the current
// collection.
@ -308,7 +198,22 @@ var PlacesOrganizer = {
}
},
onTreeDblClick: function PO_onTreeDblClick(aEvent) {
_openSelectedRow: function PO__openSelectedRow(aEvent) {
var node = this._content.selectedNode;
if (!node)
return;
if (PlacesUtils.nodeIsContainer(node)) {
if (node.itemId != -1)
this._places.selectItems([node.itemId]);
else if (PlacesUtils.nodeIsQuery(node))
this._places.selectPlaceURI(node.uri);
}
else if (PlacesUtils.nodeIsURI(this._content.selectedNode))
this._content.controller.openSelectedNodeWithEvent(aEvent);
},
onContentTreeDblClick: function PO_onContentTreeDblClick(aEvent) {
if (aEvent.button != 0 || !this._content.hasSingleSelection ||
aEvent.originalTarget.localName != "treechildren")
return;
@ -316,10 +221,15 @@ var PlacesOrganizer = {
var row = { }, col = { }, obj = { };
this._content.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row,
col, obj);
if (row.value == -1 || obj.value == "twisty")
if (row.value == -1)
return;
this._content.controller.openSelectedNodeWithEvent(aEvent);
this._openSelectedRow(aEvent);
},
onContentTreeKeypress: function PO_onContentTreeKeypress(aEvent) {
if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN)
this._openSelectedRow(aEvent);
},
/**
@ -555,6 +465,7 @@ var PlacesOrganizer = {
}
},
// NOT YET USED
updateThumbnailProportions: function PO_updateThumbnailProportions() {
var previewBox = document.getElementById("previewBox");
var canvas = document.getElementById("itemThumbnail");
@ -592,8 +503,6 @@ var PlacesOrganizer = {
{ hiddenRows: ["folderPicker"] });
this._detectAndSetDetailsPaneMinimalState(selectedNode);
this.updateThumbnailProportions();
this._updateThumbnail();
return;
}
}
@ -617,9 +526,6 @@ var PlacesOrganizer = {
[rowCount]);
}
}
this.updateThumbnailProportions();
this._updateThumbnail();
}
// Nothing to do if the pane was already disabled
@ -630,6 +536,7 @@ var PlacesOrganizer = {
}
},
// NOT YET USED
_updateThumbnail: function PO__updateThumbnail() {
var bo = document.getElementById("previewBox").boxObject;
var width = bo.width;
@ -711,7 +618,7 @@ var PlacesOrganizer = {
// Add the place: uri as a bookmark under the bookmarks root.
var txn = PlacesUtils.ptm.createItem(placeURI,
PlacesUtils.bookmarksRootId,
PlacesUtils.bookmarksMenuFolderId,
PlacesUtils.bookmarks.DEFAULT_INDEX,
input.value);
PlacesUtils.ptm.commitTransaction(txn);
@ -736,7 +643,9 @@ var PlacesSearchBox = {
_folders: [],
get folders() {
if (this._folders.length == 0)
this._folders.push(PlacesUtils.bookmarksRootId, PlacesUtils.unfiledRootId);
this._folders.push(PlacesUtils.bookmarksMenuFolderId,
PlacesUtils.unfiledBookmarksFolderId,
PlacesUtils.toolbarFolderId);
return this._folders;
},
set folders(aFolders) {
@ -774,8 +683,9 @@ var PlacesSearchBox = {
break;
case "bookmarks":
content.applyFilter(filterString, true,
[PlacesUtils.bookmarksRootId,
PlacesUtils.unfiledRootId]);
[PlacesUtils.bookmarksMenuFolderId,
PlacesUtils.toolbarFolderId,
PlacesUtils.unfiledBookmarksFolderId]);
break;
case "history":
if (currentOptions.queryType != Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
@ -794,7 +704,6 @@ var PlacesSearchBox = {
break;
}
PO.setHeaderText(PO.HEADER_TYPE_SEARCH, filterString);
PlacesSearchBox.showSearchUI();
this.searchFilter.setAttribute("filtered", "true");
},
@ -1029,9 +938,6 @@ var PlacesQueryBuilder = {
var titleDeck = document.getElementById("titleDeck");
titleDeck.setAttribute("selectedIndex", (this.numRows <= 1) ? 0 : 1);
const asType = PlacesOrganizer.HEADER_TYPE_ADVANCED_SEARCH;
PlacesOrganizer.setHeaderText(asType, "");
// Update the "can add more criteria" command to make sure various +
// buttons are disabled.
var command = document.getElementById("OrganizerCommand_search:moreCriteria");
@ -1374,7 +1280,6 @@ var PlacesQueryBuilder = {
// XXXben - find some public way of doing this!
PlacesOrganizer._content.load(this.queries,
OptionsFilter.filter(this.queries, this.options, null));
PlacesOrganizer.updateLoadedURI();
},
onScopeSelected: function PQB_onScopeSelected(aButton) {
@ -1403,7 +1308,7 @@ var PlacesQueryBuilder = {
break;
case "scopeBarMenu":
PlacesSearchBox.filterCollection = "collection";
folders.push(PlacesUtils.bookmarksRootId);
folders.push(PlacesUtils.bookmarksMenuFolderId);
break;
case "scopeBarHistory":
PlacesSearchBox.filterCollection = "history";
@ -1411,8 +1316,9 @@ var PlacesQueryBuilder = {
break;
default: // all bookmarks
PlacesSearchBox.filterCollection = "bookmarks";
folders.push(PlacesUtils.bookmarksRootId,
PlacesUtils.unfiledRootId);
folders.push(PlacesUtils.bookmarksMenuFolderId,
PlacesUtils.toolbarFolderId,
PlacesUtils.unfiledBookmarksFolderId);
}
// set scope, and re-search
@ -1505,7 +1411,7 @@ var ViewMenu = {
var columns = content.columns;
for (var i = 0; i < columns.count; ++i) {
var column = columns.getColumnAt(i).element;
var menuitem = document.createElementNS(XUL_NS, "menuitem");
var menuitem = document.createElement("menuitem");
menuitem.id = "menucol_" + column.id;
menuitem.setAttribute("column", column.id);
var label = column.getAttribute("label");
@ -1690,225 +1596,3 @@ var ViewMenu = {
OptionsFilter.update(result);
}
};
/**
* A "Configuration" set for a class of history query results. Some results
* will require that the grouping UI be labeled differently from the standard
* so this object is provided to allow those results to configure the UI when
* they are displayed.
* @param substr
* A prefix substring of an annotation that the result's query
* matches.
* @param onLabel
* The label for the "Grouping On" command
* @param onAccesskey
* The accesskey for the "Grouping On" command
* @param offLabel
* The label for the "Grouping Off" command
* @param offAccesskey
* The accesskey for the "Grouping Off" command
* @param onOncommand
* The "oncommand" attribute of the "Grouping On" command
* @param offOncommand
* The "oncommand" attribute of the "Grouping Off" command
* @param disabled
* Whether or not grouping is disabled for results that match this
* config.
*/
function GroupingConfig(substr, onLabel, onAccesskey, offLabel, offAccesskey,
onOncommand, offOncommand, disabled) {
this.substr = substr;
this.onLabel = onLabel;
this.onAccesskey = onAccesskey;
this.offLabel = offLabel;
this.offAccesskey = offAccesskey;
this.onOncommand = onOncommand;
this.offOncommand = offOncommand;
this.disabled = disabled;
}
/**
* Handles Grouping within the Content View, and the commands that support it.
*/
var Groupers = {
defaultGrouper: null,
annotationGroupers: [],
/**
* Initializes groupings for various view types.
*/
init: function G_init() {
this.defaultGrouper =
new GroupingConfig(null, PlacesUtils.getString("defaultGroupOnLabel"),
PlacesUtils.getString("defaultGroupOnAccesskey"),
PlacesUtils.getString("defaultGroupOffLabel"),
PlacesUtils.getString("defaultGroupOffAccesskey"),
"Groupers.groupBySite()",
"Groupers.groupByPage()", false);
var subscriptionConfig =
new GroupingConfig("livemark/", PlacesUtils.getString("livemarkGroupOnLabel"),
PlacesUtils.getString("livemarkGroupOnAccesskey"),
PlacesUtils.getString("livemarkGroupOffLabel"),
PlacesUtils.getString("livemarkGroupOffAccesskey"),
"Groupers.groupByFeed()",
"Groupers.groupByPost()", false);
this.annotationGroupers.push(subscriptionConfig);
},
/**
* Get the most appropriate GroupingConfig for the set of queries that are
* about to be executed.
* @param queries
* An array of queries that are about to be executed.
* @param handler
* Optionally specify which handler to use to filter the options.
* If null, the default handler for the queries will be used.
*/
_getConfig: function G__getConfig(queries, handler) {
if (!handler)
handler = OptionsFilter.getHandler(queries);
// If the queries will generate a bookmarks folder, there is no "grouper
// config" since all of the grouping UI should be hidden (there is only one
// grouping mode - group by folder).
if (handler == OptionsFilter.bookmarksHandler)
return null;
var query = queries[0];
for (var i = 0; i < this.annotationGroupers.length; ++i) {
var config = this.annotationGroupers[i];
if (query.annotation.substr(0, config.substr.length) == config.substr &&
!config.disabled)
return config;
}
return this.defaultGrouper;
},
/**
* Updates the grouping broadcasters for the given result.
* @param queries
* An array of queries that are going to be executed.
* @param options
* The options that are being used to generate the forthcoming
* result.
* @param handler
* Optionally specify which handler to use to filter the options.
* If null, the default handler for the queries will be used.
* @param
*/
updateGroupingUI: function G_updateGroupingUI(queries, options, handler) {
var separator = document.getElementById("placesBC_grouping:separator");
var groupOff = document.getElementById("placesBC_grouping:off");
var groupOn = document.getElementById("placesBC_grouping:on");
separator.removeAttribute("hidden");
groupOff.removeAttribute("hidden");
groupOn.removeAttribute("hidden");
// Walk the list of registered annotationGroupers, determining what are
// available and notifying the broadcaster
var config = this._getConfig(queries, handler);
if (!config) {
// Generic Bookmarks Folder or custom container that disables grouping.
separator.setAttribute("hidden", "true");
groupOff.setAttribute("hidden", "true");
groupOn.setAttribute("hidden", "true");
}
else {
groupOn.setAttribute("label", config.onLabel);
groupOn.setAttribute("accesskey", config.onAccesskey);
groupOn.setAttribute("oncommand", config.onOncommand);
groupOff.setAttribute("label", config.offLabel);
groupOff.setAttribute("accesskey", config.offAccesskey);
groupOff.setAttribute("oncommand", config.offOncommand);
// Update the checked state of the UI:
// Grouping UI is "enabled" if there is at least one set of grouping
// options.
var groupingsCountRef = { };
options.getGroupingMode(groupingsCountRef);
this._updateBroadcasters(groupingsCountRef.value > 0);
}
},
/**
* Update the visual state of UI that controls grouping.
*/
_updateBroadcasters: function G__updateGroupingBroadcasters(on) {
var groupingOn = document.getElementById("placesBC_grouping:on");
var groupingOff = document.getElementById("placesBC_grouping:off");
if (on) {
groupingOn.setAttribute("checked", "true");
groupingOff.removeAttribute("checked");
}
else {
groupingOff.setAttribute("checked", "true");
groupingOn.removeAttribute("checked");
}
},
/**
* Shows visited pages grouped by site.
*/
groupBySite: function G_groupBySite() {
var query = asQuery(PlacesOrganizer._content.getResult().root);
var queries = query.getQueries({ });
var options = query.queryOptions;
var newOptions = options.clone();
const NHQO = Ci.nsINavHistoryQueryOptions;
newOptions.setGroupingMode([NHQO.GROUP_BY_DOMAIN], 1);
var content = PlacesOrganizer._content;
content.load(queries, newOptions);
PlacesOrganizer.updateLoadedURI();
this._updateBroadcasters(true);
OptionsFilter.update(content.getResult());
},
/**
* Shows visited pages without grouping.
*/
groupByPage: function G_groupByPage() {
var query = asQuery(PlacesOrganizer._content.getResult().root);
var queries = query.getQueries({ });
var options = query.queryOptions;
var newOptions = options.clone();
newOptions.setGroupingMode([], 0);
var content = PlacesOrganizer._content;
content.load(queries, newOptions);
PlacesOrganizer.updateLoadedURI();
this._updateBroadcasters(false);
OptionsFilter.update(content.getResult());
},
/**
* Shows all subscribed feeds (Live Bookmarks) grouped under their parent
* feed.
*/
groupByFeed: function G_groupByFeed() {
var content = PlacesOrganizer._content;
var query = asQuery(content.getResult().root);
var queries = query.getQueries({ });
var newOptions = query.queryOptions.clone();
var newQuery = queries[0].clone();
newQuery.annotation = "livemark/feedURI";
content.load([newQuery], newOptions);
PlacesOrganizer.updateLoadedURI();
this._updateBroadcasters(false);
OptionsFilter.update(content.getResult());
},
/**
* Shows all subscribed feed (Live Bookmarks) content in a flat list
*/
groupByPost: function G_groupByPost() {
var content = PlacesOrganizer._content;
var query = asQuery(content.getResult().root);
var queries = query.getQueries({ });
var newOptions = query.queryOptions.clone();
var newQuery = queries[0].clone();
newQuery.annotation = "livemark/bookmarkFeedURI";
content.load([newQuery], newOptions);
PlacesOrganizer.updateLoadedURI();
this._updateBroadcasters(false);
OptionsFilter.update(content.getResult());
}
};

Просмотреть файл

@ -112,20 +112,11 @@
oncommand="PlacesOrganizer.forward();"/>
</commandset>
<broadcasterset id="placesGroupingBroadcasters">
<broadcaster id="placesBC_grouping:off"/>
<broadcaster id="placesBC_grouping:on"/>
<broadcaster id="placesBC_grouping:separator"/>
</broadcasterset>
<keyset id="placesOrganizerKeyset">
<!-- Instantiation Keys -->
<key id="placesKey_close" key="&cmd.close.key;" modifiers="accel"
oncommand="close();"/>
<key id="placesKey_show:debug"
key="e" modifiers="accel,shift"
oncommand="PlacesOrganizer.toggleDebugPanel();"/>
<!-- Command Keys -->
<key id="placesKey_find:all"
@ -136,24 +127,6 @@
command="OrganizerCommand_find:current"
key="&cmd.find.key;"
modifiers="accel,shift"/>
<key id="placesKey_open"
command="placesCmd_open"
keycode="VK_RETURN"/>
<key id="placesKey_open:window"
command="placesCmd_open:window"
keycode="VK_RETURN"
modifiers="shift"/>
<key id="placesKey_open:tab"
command="placesCmd_open:tab"
keycode="VK_RETURN"
modifiers="accel"/>
<key id="placesKey_show:info"
command="placesCmd_show:info"
key="&cmd.show_info.key;"
modifiers="accel"/>
<key id="placesKey_rename"
command="placesCmd_rename"
keycode="VK_F2"/>
</keyset>
<keyset id="editMenuKeys">
@ -195,6 +168,7 @@
label="&cmd.new_separator.label;"
accesskey="&cmd.new_separator.accesskey;"/>
#ifndef XP_MACOSX
<menuseparator id="orgCutSeparator"/>
<menuitem id="orgCut"
@ -234,14 +208,18 @@
key="key_selectAll"
accesskey="&selectAllCmd.accesskey;"/>
#endif
<menuseparator id="orgMoveSeparator"/>
<menuitem id="orgMoveBookmarks"
command="placesCmd_moveBookmarks"
label="&cmd.moveBookmarks.label;"
accesskey="cmd.moveBookmarks.accesskey"/>
<menuitem id="orgDelete"
command="cmd_delete"
label="&deleteCmd.label;"
key="key_delete"
accesskey="&deleteCmd.accesskey;"/>
#ifndef XP_MACOSX
<menuseparator id="orgCloseSeparator"/>
<menuitem id="orgClose"
@ -249,6 +227,7 @@
label="&file.close.label;"
accesskey="&file.close.accesskey;"
oncommand="close();"/>
#endif
</menupopup>
</toolbarbutton>
@ -351,18 +330,16 @@
<tree id="placesList"
class="placesTree"
type="places"
showRoot="true"
place="place:folder=2&amp;excludeItems=1&amp;queryType=1"
hidecolumnpicker="true" context="placesContext"
onselect="PlacesOrganizer.onPlaceSelected(true);"
onclick="PlacesOrganizer.onTreeClick(event);"
seltype="single"
persist="width"
width="160">
width="200">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
<treecol anonid="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren id="placesListChildren" view="placesList" flex="1"/>
<treechildren flex="1"/>
</tree>
<splitter id="splitter" collapse="before" persist="state">
<grippy/>
@ -370,12 +347,6 @@
<vbox id="contentView" flex="4">
<deck id="contentDeck" flex="1">
<vbox id="defaultView" flex="1">
<hbox id="titlebar">
<label id="showingPrefix"/>
<deck id="titleDeck" flex="1">
<label id="contentTitle" flex="1" crop="right"/>
</deck>
</hbox>
<vbox id="searchModifiers" hidden="true">
<toolbar id="organizerScopeBar" class="chromeclass-toolbar" align="center">
<label id="scopeBarTitle" value="&search.label;"/>
@ -418,47 +389,46 @@
</vbox>
<vbox flex="1">
<tree id="placeContent" class="placesTree" context="placesContext"
flex="1" type="places"
ondblclick="PlacesOrganizer.onTreeDblClick(event);"
onclick="PlacesOrganizer.onTreeClick(event);"
onselect="PlacesOrganizer.onContentTreeSelect();">
flex="1" type="places"
flatList="true"
ondblclick="PlacesOrganizer.onContentTreeDblClick(event);"
onkeypress="PlacesOrganizer.onContentTreeKeypress(event);"
onselect="PlacesOrganizer.onContentTreeSelect();"
onclick="PlacesOrganizer.onTreeClick(event);">
<treecols id="placeContentColumns">
<treecol label="&col.name.label;" id="title" flex="5" primary="true"
<treecol label="&col.name.label;" anonid="title" flex="5" primary="true"
persist="width hidden ordinal sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol label="&col.tags.label;" id="tags" flex="2"
<treecol label="&col.tags.label;" anonid="tags" flex="2"
persist="width hidden ordinal sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol label="&col.url.label;" id="url" flex="5"
<treecol label="&col.url.label;" anonid="url" flex="5"
persist="width hidden ordinal sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol label="&col.lastvisit.label;" id="date" flex="1" hidden="true"
<treecol label="&col.lastvisit.label;" anonid="date" flex="1" hidden="true"
persist="width hidden ordinal sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol label="&col.visitcount.label;" id="visitCount" flex="1" hidden="true"
<treecol label="&col.visitcount.label;" anonid="visitCount" flex="1" hidden="true"
persist="width hidden ordinal sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol label="&col.keyword.label;" id="keyword" flex="1" hidden="true"
<treecol label="&col.keyword.label;" anonid="keyword" flex="1" hidden="true"
persist="width hidden ordinal sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol label="&col.description.label;" id="description" flex="1" hidden="true"
<treecol label="&col.description.label;" anonid="description" flex="1" hidden="true"
persist="width hidden ordinal sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol label="&col.dateadded.label;" id="dateAdded" flex="1" hidden="true"
<treecol label="&col.dateadded.label;" anonid="dateAdded" flex="1" hidden="true"
persist="width hidden ordinal sortActive sortDirection"/>
<splitter class="tree-splitter"/>
<treecol label="&col.lastmodified.label;" id="lastModified" flex="1" hidden="true"
<treecol label="&col.lastmodified.label;" anonid="lastModified" flex="1" hidden="true"
persist="width hidden ordinal sortActive sortDirection"/>
</treecols>
<treechildren id="placeContentChildren" view="placeContent" flex="1"/>
<treechildren flex="1"/>
</tree>
<splitter id="contentSplitter" collapse="after" persist="state">
<grippy/>
</splitter>
<hbox persist="height" id="infoPane">
<hbox id="previewBox" style="min-width: 60px; -moz-border-end: 1px solid GrayText;">
<html:canvas id="itemThumbnail" notavailabletext="&detailsPane.noPreviewAvailable.label;"/>
</hbox>
<deck flex="1" id="detailsDeck">
<vbox align="center">
<spacer flex="3"/>
@ -484,39 +454,6 @@
</deck>
</hbox>
</vbox>
<vbox id="debugPanel" hidden="true">
<grid>
<columns>
<column/>
<column flex="1"/>
<column/>
</columns>
<rows>
<row align="center">
<label value="Debug:" control="placeURI"/>
<textbox id="placeURI" flex="1"
onkeypress="PlacesOrganizer.onPlaceURIKeypress(event);"/>
<button label="Load" oncommand="PlacesOrganizer.loadPlaceURI();"/>
</row>
<row>
<spacer/>
<hbox>
<checkbox id="autoFilterResults"
label="Apply user filtering of results"
checked="true"/>
</hbox>
<spacer/>
</row>
<separator class="thin"/>
<row align="center">
<label value="Loaded:" control="loadedURI"/>
<textbox id="loadedURI" flex="1" readonly="true"/>
<spacer/>
</row>
</rows>
</grid>
<separator class="thin"/>
</vbox>
</vbox>
</deck>
</vbox>

Просмотреть файл

@ -93,8 +93,6 @@
oncommand="goDoCommand('placesCmd_sortBy:name');"/>
<command id="placesCmd_moveBookmarks"
oncommand="goDoCommand('placesCmd_moveBookmarks');"/>
<command id="placesCmd_setAsBookmarksToolbarFolder"
oncommand="goDoCommand('placesCmd_setAsBookmarksToolbarFolder');"/>
</commandset>
<popup id="placesContext"
@ -187,7 +185,7 @@
label="&cmd.reloadLivebookmark.label;"
accesskey="&cmd.reloadLivebookmark.accesskey;"
closemenu="single"
selection="livemark/feedURI|allLivemarks"/>
selection="livemark/feedURI"/>
<menuitem id="placesContext_reloadMicrosummary"
command="placesCmd_reloadMicrosummary"
label="&cmd.reloadMicrosummary.label;"

Просмотреть файл

@ -195,7 +195,7 @@
if (PlacesUtils.containerTypes.indexOf(type) != -1) {
button.setAttribute("type", "menu");
button.setAttribute("container", "true");
if (iconURISpec == "chrome://browser/skin/places/livemarkItem.png")
if (PlacesUtils.nodeIsLivemarkContainer(aChild))
button.setAttribute("livemark", "true");
var popup = document.createElement("menupopup");
@ -548,6 +548,10 @@
if (onToolbar)
this._self.updateChevron();
}
if (!element.hasAttribute("livemark") &&
PlacesUtils.nodeIsLivemarkContainer(aNode))
element.setAttribute("livemark", "true");
},
itemReplaced:

Просмотреть файл

@ -46,9 +46,6 @@
<binding id="places-tree" extends="chrome://global/content/bindings/tree.xml#tree">
<implementation implements="nsINavHistoryResultViewObserver">
<constructor><![CDATA[
this._controller = new PlacesController(this);
this.controllers.appendController(this._controller);
// Force an initial build.
if (this.place)
this.place = this.place;
@ -138,9 +135,13 @@
<body><![CDATA[
var result = PlacesUtils.history.executeQueries(queries, queries.length,
options);
var treeView = new PlacesTreeView(this.showRoot);
var treeView = new PlacesTreeView(this.showRoot, this.flatList);
result.viewer = treeView;
this.view = treeView;
if (!this._controller) {
this._controller = new PlacesController(this);
this.controllers.appendController(this._controller);
}
this._cachedInsertionPoint = undefined;
]]></body>
</method>
@ -160,6 +161,21 @@
]]></setter>
</property>
<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>
<!--
Causes a particular node represented by the specified placeURI to be
selected in the tree. All containers above the node in the hierarchy
@ -168,22 +184,30 @@
<method name="selectPlaceURI">
<parameter name="placeURI"/>
<body><![CDATA[
function findNode(container, placeURI) {
if (container.uri == placeURI)
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);
container.containerOpen = true;
for (var i = 0; i < container.childCount; ++i) {
var child = container.getChild(i);
if (child.uri == placeURI)
var childURI = child.uri;
if (childURI == placeURI)
return child;
else if (PlacesUtils.nodeIsContainer(child)) {
var nested = findNode(asContainer(child), placeURI);
var nested = findNode(asContainer(child), placeURI, nodesURIChecked);
if (nested)
return nested;
}
}
container.containerOpen = false;
return null;
}
@ -192,7 +216,7 @@
if (!container)
return;
var child = findNode(container, placeURI);
var child = findNode(container, placeURI, []);
container.containerOpen = true;
if (child)
this.selectNode(child);
@ -487,7 +511,7 @@
if (this.hasSingleSelection && resultView.isContainer(max.value) &&
(resultView.isContainerOpen(max.value) ||
resultView.nodeForTreeIndex(max.value)
.itemId == PlacesUtils.bookmarksRootId))
.itemId == PlacesUtils.bookmarksMenuFolderId))
orientation = NHRVO.DROP_ON;
this._cachedInsertionPoint =
@ -570,123 +594,82 @@
]]></body>
</method>
<!-- This method returns the root node of the query results as
a container query result node. If it is unable to do this
(for instance, if we have no query results), it will
return null.
<!-- 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="_getRootNode">
<method name="selectItems">
<parameter name="aIDs"/>
<body><![CDATA[
var result = this.getResult();
if (!result)
return null;
return asContainer(result.root);
]]></body>
</method>
var ids = aIDs; // don't manipulate the caller's array
<!-- This method, when given a list of folder IDs, will select all
the nodes that match those IDs in the current tree.
It will open any parent nodes that it needs to in order to
show the selected folders.
-->
<method name="selectFolders">
<parameter name="ids"/>
<body><![CDATA[
/**
* Returns the number of properties on the object "obj", since
* we're using objects as sets and dictionaries in the
* code below.
*/
function len(obj) {
var count = 0;
for (property in obj)
++count;
return count;
}
// Array of nodes found by findNodes which are to be selected
var nodes = [];
// 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 folders
* with IDs in the set "indexes". When a matching folder
* is found, remove its ID from "indexes" and store the
* node in the dictionary "nodes".
* 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 folders in its subtree.
*
* @param node The root of the subtree to search for the folders.
* "node" itself will not be examined for a match.
* @param indexes A set of folder IDs, expressed as an object
* @param nodes A dictionary mapping folder IDs to folder
* result nodes, expressed as an object. This is
* empty at the initial start of the recursion and
* gets filled in as the recursion progresses.
* NOTE: This method will leave open any node that had matching items
* in its subtree.
*/
function findNodes(node, indexes, nodes) {
function findNodes(node) {
var foundOne = false;
// See if node matches an ID we wanted; add to results.
if (node.itemId in indexes) {
nodes[node.itemId] = node;
delete indexes[node.itemId];
if (!len(indexes))
return;
var index = ids.indexOf(node.itemId);
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;
nodesURIChecked.push(node.uri);
asContainer(node);
// 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;
var previousMatches = len(nodes);
node.containerOpen = true;
for (var child = 0;
(child < node.childCount) && (len(indexes) > 0);
for (var child = 0; child < node.childCount && ids.length > 0;
child++) {
var childNode = node.getChild(child);
if (!PlacesUtils.nodeIsFolder(childNode))
continue;
// See if child matches an ID we wanted; add to results.
if (childNode.itemId in indexes) {
nodes[childNode.itemId] = childNode;
delete indexes[childNode.itemId];
}
// If we are still searching, search down that child's subtree.
if (len(indexes))
findNodes(childNode, indexes, nodes);
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 (len(nodes) == previousMatches)
if (!foundOne)
node.containerOpen = previousOpenness;
return foundOne;
}
var indexes = {}; // Set of folder IDs to search for.
var nodes = {}; // Dictionary of found IDs to found nodes.
findNodes(this.getResultNode());
// Initialize input set
for (var i = 0; i < ids.length; i++)
indexes[ids[i]] = true;
var root = this._getRootNode();
if (!root) {
NS_ASSERT(root, "Couldn't select folders because no root node was available.");
return;
}
findNodes(root, indexes, nodes);
// For all the nodes we've found, highlight the corresponding
// index in the tree.
var resultview = this.getResultView();
var selection = this.view.selection;
selection.clearSelection();
for (idx in nodes) {
var index = resultview.treeIndexForNode(nodes[idx]);
for (var i=0; i < nodes.length; i++) {
var index = resultview.treeIndexForNode(nodes[i]);
selection.rangedSelect(index, index, true);
}
]]></body>
</method>
<!-- nsDragAndDrop -->
<method name="onDragStart">
<parameter name="event"/>

Просмотреть файл

@ -44,28 +44,12 @@ PlacesTreeView.prototype = {
getAtom(aString);
},
__separatorAtom: null,
get _separatorAtom() {
if (!this.__separatorAtom)
this.__separatorAtom = this._makeAtom("separator");
_atoms: [],
_getAtomFor: function PTV__getAtomFor(aName) {
if (!this._atoms[aName])
this._atoms[aName] = this._makeAtom(aName);
return this.__separatorAtom;
},
__sessionStartAtom: null,
get _sessionStartAtom() {
if (!this.__sessionStartAtom)
this.__sessionStartAtom = this._makeAtom("session-start");
return this.__sessionStartAtom;
},
__sessionContinueAtom: null,
get _sessionContinueAtom() {
if (!this.__sessionContinueAtom)
this.__sessionContinueAtom = this._makeAtom("session-continue");
return this.__sessionContinueAtom;
return this._atoms[aName];
},
_ensureValidRow: function PTV__ensureValidRow(aRow) {
@ -140,7 +124,6 @@ PlacesTreeView.prototype = {
SESSION_STATUS_START: 1,
SESSION_STATUS_CONTINUE: 2,
_getRowSessionStatus: function PTV__getRowSessionStatus(aRow) {
this._ensureValidRow(aRow);
var node = this._visibleElements[aRow];
if (!PlacesUtils.nodeIsVisit(node) || asVisit(node).sessionId == 0)
return this.SESSION_STATUS_NONE;
@ -251,7 +234,7 @@ PlacesTreeView.prototype = {
aVisible.push(curChild);
// recursively do containers
if (PlacesUtils.containerTypes.indexOf(curChildType) != -1) {
if (!this._flatList && PlacesUtils.containerTypes.indexOf(curChildType) != -1) {
asContainer(curChild);
var resource = this._getResourceForNode(curChild);
@ -371,7 +354,6 @@ PlacesTreeView.prototype = {
this._tree.rowCountChanged(startReplacement, -replaceCount);
if (newElements.length)
this._tree.rowCountChanged(startReplacement, newElements.length);
this._tree.endUpdateBatch();
// now, open any containers that were persisted
for (var i = 0; i < toOpenElements.length; i++) {
@ -389,6 +371,8 @@ PlacesTreeView.prototype = {
item.containerOpen = !item.containerOpen;
}
this._tree.endUpdateBatch();
// restore selection
if (nodesToSelect.length > 0) {
for each (var node in nodesToSelect) {
@ -892,40 +876,67 @@ PlacesTreeView.prototype = {
getRowProperties: function PTV_getRowProperties(aRow, aProperties) {
this._ensureValidRow(aRow);
var node = this._visibleElements[aRow];
// Handle properties for session information.
if (!this._showSessions)
return;
switch(this._getRowSessionStatus(aRow)) {
var status = this._getRowSessionStatus(aRow);
switch (status) {
case this.SESSION_STATUS_NONE:
break;
case this.SESSION_STATUS_START:
aProperties.AppendElement(this._sessionStartAtom);
aProperties.AppendElement(this._getAtomFor("session-start"));
break;
case this.SESSION_STATUS_CONTINUE:
aProperties.AppendElement(this._sessionContinueAtom);
aProperties.AppendElement(this._getAtomFor("session-continue"));
break
}
},
getCellProperties: function PTV_getCellProperties(aRow, aColumn, aProperties) {
var columnType = aColumn.id || aColumn.element.getAttribute("anonid");
this._ensureValidRow(aRow);
// for anonid-trees, we need to add the column-type manually
var columnType = aColumn.element.getAttribute("anonid");
if (columnType)
aProperties.AppendElement(this._getAtomFor(columnType));
else
var columnType = aColumn.id;
if (columnType != "title")
return;
this._ensureValidRow(aRow);
var node = this._visibleElements[aRow];
// To disable the tree gestures for containers (e.g. double-click to open)
// we don't mark container nodes as such in flat list mode. The container
// appearance is desired though, so we add the container atom manually.
if (this._flatList && PlacesUtils.nodeIsContainer(node))
aProperties.AppendElement(this._getAtomFor("container"));
if (PlacesUtils.nodeIsSeparator(node))
aProperties.AppendElement(this._separatorAtom);
aProperties.AppendElement(this._getAtomFor("separator"));
else if (node.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY)
aProperties.AppendElement(this._getAtomFor("query"));
else if (node.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER) {
if (PlacesUtils.annotations.itemHasAnnotation(node.itemId,
LMANNO_FEEDURI))
aProperties.AppendElement(this._getAtomFor("livemark"));
else if (PlacesUtils.bookmarks.getFolderIdForItem(node.itemId) ==
PlacesUtils.tagsFolderId) {
aProperties.AppendElement(this._getAtomFor("tagContainer"));
}
}
},
getColumnProperties: function(aColumn, aProperties) { },
isContainer: function PTV_isContainer(aRow) {
this._ensureValidRow(aRow);
if (this._flatList)
return false; // but see getCellProperties
var node = this._visibleElements[aRow];
if (PlacesUtils.nodeIsContainer(node)) {
// the root node is always expandable
@ -943,6 +954,9 @@ PlacesTreeView.prototype = {
},
isContainerOpen: function PTV_isContainerOpen(aRow) {
if (this._flatList)
return false;
this._ensureValidRow(aRow);
if (!PlacesUtils.nodeIsContainer(this._visibleElements[aRow]))
throw Cr.NS_ERROR_INVALID_ARG;
@ -951,7 +965,11 @@ PlacesTreeView.prototype = {
},
isContainerEmpty: function PTV_isContainerEmpty(aRow) {
if (this._flatList)
return true;
this._ensureValidRow(aRow);
if (!PlacesUtils.nodeIsContainer(this._visibleElements[aRow]))
throw Cr.NS_ERROR_INVALID_ARG;
@ -1050,7 +1068,8 @@ PlacesTreeView.prototype = {
this._ensureValidRow(aRow);
var node = this._visibleElements[aRow];
switch (this._getColumnType(aColumn)) {
var columnType = this._getColumnType(aColumn);
switch (columnType) {
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.
@ -1175,7 +1194,8 @@ PlacesTreeView.prototype = {
var newSort;
var newSortingAnnotation = "";
const NHQO = Ci.nsINavHistoryQueryOptions;
switch (this._getColumnType(aColumn)) {
var columnType = this._getColumnType(aColumn);
switch (columnType) {
case this.COLUMN_TYPE_TITLE:
if (oldSort == NHQO.SORT_BY_TITLE_ASCENDING)
newSort = NHQO.SORT_BY_TITLE_DESCENDING;
@ -1294,7 +1314,10 @@ PlacesTreeView.prototype = {
}
};
function PlacesTreeView(aShowRoot) {
function PlacesTreeView(aShowRoot, aFlatList) {
if (aShowRoot && aFlatList)
throw("Flat-list mode is not supported when show-root is set");
this._tree = null;
this._result = null;
this._collapseDuplicates = true;
@ -1303,4 +1326,5 @@ function PlacesTreeView(aShowRoot) {
this._visibleElements = [];
this._observers = [];
this._showRoot = aShowRoot;
this._flatList = aFlatList;
}

Просмотреть файл

@ -53,6 +53,7 @@ const DESCRIPTION_ANNO = "bookmarkProperties/description";
const POST_DATA_ANNO = "URIProperties/POSTData";
const LMANNO_FEEDURI = "livemark/feedURI";
const LMANNO_SITEURI = "livemark/siteURI";
const ORGANIZER_QUERY_ANNO = "PlacesOrganizer/OrganizerQuery";
#ifdef XP_MACOSX
// On Mac OSX, the transferable system converts "\r\n" to "\n\n", where we
@ -1425,35 +1426,28 @@ var PlacesUtils = {
// identifier getters for special folders
get placesRootId() {
if (!("_placesRootId" in this))
this._placesRootId = this.bookmarks.placesRoot;
return this._placesRootId;
delete this.placesRootId;
return this.placesRootId = this.bookmarks.placesRoot;
},
get bookmarksRootId() {
if (!("_bookmarksRootId" in this))
this._bookmarksRootId = this.bookmarks.bookmarksRoot;
return this._bookmarksRootId;
get bookmarksMenuFolderId() {
delete this.bookmarksMenuFolderId;
return this.bookmarksMenuFolderId = this.bookmarks.bookmarksMenuFolder;
},
get toolbarFolderId() {
return this.bookmarks.toolbarFolder;
delete this.toolbarFolderId;
return this.toolbarFolderId = this.bookmarks.toolbarFolder;
},
get tagRootId() {
if (!("_tagRootId" in this))
this._tagRootId = this.bookmarks.tagRoot;
return this._tagRootId;
get tagsFolderId() {
delete this.tagsFolderId;
return this.tagsFolderId = this.bookmarks.tagsFolder;
},
get unfiledRootId() {
if (!("_unfiledRootId" in this))
this._unfiledRootId = this.bookmarks.unfiledRoot;
return this._unfiledRootId;
get unfiledBookmarksFolderId() {
delete this.unfiledBookmarksFolderId;
return this.unfiledBookmarksFolderId = this.bookmarks.unfiledBookmarksFolder;
},
/**
@ -1507,11 +1501,11 @@ var PlacesUtils = {
for each (var bk in bmkIds) {
// Find the first folder which isn't a tag container
var parent = this.bookmarks.getFolderIdForItem(bk);
if (parent == this.unfiledRootId)
if (parent == this.unfiledBookmarksFolderId)
return bk;
var grandparent = this.bookmarks.getFolderIdForItem(parent);
if (grandparent != this.tagRootId &&
if (grandparent != this.tagsFolderId &&
!this.annotations.itemHasAnnotation(parent, LMANNO_FEEDURI))
return bk;
}
@ -1681,9 +1675,15 @@ var PlacesUtils = {
else if (this.containerTypes.indexOf(type) != -1) {
element = document.createElement("menu");
element.setAttribute("container", "true");
if (iconURISpec == "chrome://browser/skin/places/livemarkItem.png")
if (aNode.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY)
element.setAttribute("query", "true");
if (this.nodeIsLivemarkContainer(aNode))
element.setAttribute("livemark", "true");
else if (this.bookmarks
.getFolderIdForItem(aNode.itemId) == this.tagsFolderId) {
element.setAttribute("tagContainer", "true");
}
var popup = document.createElement("menupopup");
popup._resultNode = asContainer(aNode);
@ -1707,6 +1707,89 @@ var PlacesUtils = {
element.node.viewIndex = 0;
return element;
},
// get the folder id for the organizer left-pane folder
get leftPaneFolderId() {
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
var leftPaneRoot = -1;
var allBookmarksId;
try {
leftPaneRoot = prefs.getIntPref("browser.places.leftPaneFolderId");
// oh, easy!
delete this.leftPaneFolderId;
return this.leftPaneFolderId = leftPaneRoot;
}
catch (ex) { }
var self = this;
const EXPIRE_NEVER = this.annotations.EXPIRE_NEVER;
var callback = {
runBatched: function(aUserData) {
// Left Pane Root Folder
leftPaneRoot = self.bookmarks.createFolder(self.placesRootId, "", -1);
// History Query
let uri = IO.newURI("place:sort=4&");
let title = self.getString("OrganizerQueryHistory");
let itemId = self.bookmarks.insertBookmark(leftPaneRoot, uri, -1, title);
self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO,
"History", 0, EXPIRE_NEVER);
// XXX: Downloads
// Tags Query
uri = IO.newURI("place:folder=" + self.tagsFolderId);
itemId = self.bookmarks.insertBookmark(leftPaneRoot, uri, -1, null);
self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO,
"Tags", 0, EXPIRE_NEVER);
// All Bookmarks Folder
title = self.getString("OrganizerQueryAllBookmarks");
itemId = self.bookmarks.createFolder(leftPaneRoot, title, -1);
allBookmarksId = itemId;
self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO,
"AllBookmarks", 0, EXPIRE_NEVER);
// All Bookmarks->Bookmarks Toolbar Query
uri = IO.newURI("place:folder=" + self.toolbarFolderId);
itemId = self.bookmarks.insertBookmark(allBookmarksId, uri, -1, null);
self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO,
"BookmarksToolbar", 0, EXPIRE_NEVER);
// All Bookmarks->Bookmarks Menu Query
uri = IO.newURI("place:folder=" + self.bookmarksMenuFolderId);
itemId = self.bookmarks.insertBookmark(allBookmarksId, uri, -1, null);
self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO,
"BookmarksMenu", 0, EXPIRE_NEVER);
// All Bookmarks->Unfiled bookmarks
uri = IO.newURI("place:folder=" + self.unfiledBookmarksFolderId);
itemId = self.bookmarks.insertBookmark(allBookmarksId, uri, -1, null);
self.annotations.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO,
"UnfiledBookmarks", 0,
EXPIRE_NEVER);
// disallow manipulating this folder within the organizer UI
self.bookmarks.setFolderReadonly(leftPaneRoot, true);
}
};
this.bookmarks.runInBatchMode(callback, null);
prefs.setIntPref("browser.places.leftPaneFolderId", leftPaneRoot);
prefs.setIntPref("browser.places.allBookmarksFolderId", allBookmarksId);
delete this.leftPaneFolderId;
return this.leftPaneFolderId = leftPaneRoot;
},
get allBookmarksFolderId() {
// ensure the left-pane root is initialized;
this.leftPaneFolderId;
delete this.allBookmarksFolderId;
return this.allBookmarksFolderId =
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2).
getIntPref("browser.places.allBookmarksFolderId");
}
};

Просмотреть файл

@ -52,7 +52,7 @@ interface nsITransaction;
* the global scope of a js window.
*/
[scriptable, uuid(2d176a73-a908-420b-8c5d-209a45997f45)]
[scriptable, uuid(34cfb73e-ecd4-434d-b0f0-c17b8c7ceae9)]
interface nsIPlacesTransactionsService : nsISupports
{
/**
@ -306,15 +306,6 @@ interface nsIPlacesTransactionsService : nsISupports
nsITransaction sortFolderByName(in long long aFolderId,
in long long aFolderIndex);
/**
* Transaction for set the bookmarks toolbar folder.
*
* @param aFolderId
* id of the folder to set as toolbar folder
* @returns nsITransaction object
*/
nsITransaction setBookmarksToolbar(in long long aFolderId);
/**
* A reference to the transaction manager
*/

Просмотреть файл

@ -421,7 +421,6 @@ protected:
nsresult SetFaviconForURI(nsIURI* aPageURI, nsIURI* aFaviconURI,
const nsCString& aData);
nsresult SetFaviconForFolder(PRInt64 aFolder, const nsACString& aFavicon);
PRInt64 ConvertImportedIdToInternalId(const nsCString& aId);
PRTime ConvertImportedDateToInternalDate(const nsACString& aDate);
@ -465,7 +464,7 @@ BookmarkContentSink::Init(PRBool aAllowRootChanges,
// initialize the root frame with the menu root
PRInt64 menuRoot;
if (aFolder == 0) {
rv = mBookmarksService->GetBookmarksRoot(&menuRoot);
rv = mBookmarksService->GetBookmarksMenuFolder(&menuRoot);
NS_ENSURE_SUCCESS(rv, rv);
mFolderSpecified = false;
}
@ -1105,10 +1104,9 @@ BookmarkContentSink::HandleSeparator(const nsIParserNode& aNode)
printf("--------\n");
#endif
PRInt64 itemId;
mBookmarksService->InsertSeparator(frame.mContainerID,
mBookmarksService->DEFAULT_INDEX,
&itemId);
&frame.mPreviousId);
// Import separator title if set
nsAutoString name;
PRInt32 attrCount = aNode.GetAttributeCount();
@ -1120,7 +1118,7 @@ BookmarkContentSink::HandleSeparator(const nsIParserNode& aNode)
name.Trim(kWhitespace);
if (!name.IsEmpty())
mBookmarksService->SetItemTitle(itemId, name);
mBookmarksService->SetItemTitle(frame.mPreviousId, name);
// Note: we do not need to import ADD_DATE or LAST_MODIFIED for separators
// because pre-Places bookmarks does not support them.
@ -1142,7 +1140,8 @@ BookmarkContentSink::NewFrame()
PRInt64 ourID = 0;
nsString containerName;
BookmarkImportFrame::ContainerType containerType;
CurFrame().ConsumeHeading(&containerName, &containerType);
BookmarkImportFrame& frame = CurFrame();
frame.ConsumeHeading(&containerName, &containerType);
PRBool updateFolder = PR_FALSE;
@ -1163,32 +1162,32 @@ BookmarkContentSink::NewFrame()
break;
case BookmarkImportFrame::Container_Menu:
// menu root
rv = mBookmarksService->GetBookmarksRoot(&ourID);
rv = mBookmarksService->GetBookmarksMenuFolder(&ourID);
NS_ENSURE_SUCCESS(rv, rv);
if (mAllowRootChanges) {
if (mAllowRootChanges)
updateFolder = PR_TRUE;
rv = SetFaviconForFolder(ourID, NS_LITERAL_CSTRING(BOOKMARKS_MENU_ICON_URI));
NS_ENSURE_SUCCESS(rv, rv);
}
break;
case BookmarkImportFrame::Container_Toolbar:
// get toolbar folder
PRInt64 toolbarFolder;
rv = mBookmarksService->GetToolbarFolder(&toolbarFolder);
rv = mBookmarksService->GetToolbarFolder(&ourID);
NS_ENSURE_SUCCESS(rv, rv);
if (!toolbarFolder) {
// create new folder
rv = mBookmarksService->CreateFolder(CurFrame().mContainerID,
containerName,
mBookmarksService->DEFAULT_INDEX, &ourID);
// In Fx2, the toolbar folder is a child of the bookmarks menu, listed
// between two separators:
// 1) Get Bookmarks Addons 2) Separator 3) Bookmarks Toolbar Folder
// 4) Separator 5) Mozilla Firefox Folder
// In Places, the toolbar folder is a direct child of the places root,
// meaning that we end up with two sequential separators.
if (frame.mPreviousId > 0) {
PRUint16 itemType;
rv = mBookmarksService->GetItemType(frame.mPreviousId, &itemType);
NS_ENSURE_SUCCESS(rv, rv);
// there's no toolbar folder, so make us the toolbar folder
rv = mBookmarksService->SetToolbarFolder(ourID);
NS_ENSURE_SUCCESS(rv, rv);
}
else {
ourID = toolbarFolder;
}
if (itemType == nsINavBookmarksService::TYPE_SEPARATOR) {
// remove it
rv = mBookmarksService->RemoveItem(frame.mPreviousId);
NS_ENSURE_SUCCESS(rv, rv);
}
}
break;
default:
NS_NOTREACHED("Unknown container type");
@ -1212,7 +1211,6 @@ BookmarkContentSink::NewFrame()
printf("\n");
#endif
BookmarkImportFrame& frame = CurFrame();
if (frame.mPreviousDateAdded > 0) {
nsresult rv = mBookmarksService->SetItemDateAdded(ourID, frame.mPreviousDateAdded);
NS_ASSERTION(NS_SUCCEEDED(rv), "SetItemDateAdded failed");
@ -1351,34 +1349,6 @@ BookmarkContentSink::SetFaviconForURI(nsIURI* aPageURI, nsIURI* aIconURI,
return NS_OK;
}
// BookmarkContentSink::SetFaviconForFolder
//
// This sets the given favicon URI for the given folder. It is used to
// initialize the favicons for the bookmarks menu and toolbar. We don't
// actually set any data here because we assume the URI is a chrome: URI.
// These do not have to contain any data for them to work.
nsresult
BookmarkContentSink::SetFaviconForFolder(PRInt64 aFolder,
const nsACString& aFavicon)
{
nsresult rv;
nsCOMPtr<nsIFaviconService> faviconService(do_GetService(NS_FAVICONSERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> folderURI;
rv = mBookmarksService->GetFolderURI(aFolder,
getter_AddRefs(folderURI));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> faviconURI;
rv = NS_NewURI(getter_AddRefs(faviconURI), aFavicon);
NS_ENSURE_SUCCESS(rv, rv);
return faviconService->SetFaviconUrlForPage(folderURI, faviconURI);
}
// Converts a string id (ITEM_ID) into an int id
PRInt64
BookmarkContentSink::ConvertImportedIdToInternalId(const nsCString& aId) {
@ -1694,8 +1664,8 @@ nsPlacesImportExportService::WriteContainerHeader(nsINavHistoryResultNode* aFold
rv = mBookmarksService->GetPlacesRoot(&placesRoot);
NS_ENSURE_SUCCESS(rv,rv);
PRInt64 bookmarksRoot;
rv = mBookmarksService->GetBookmarksRoot(&bookmarksRoot);
PRInt64 bookmarksMenuFolder;
rv = mBookmarksService->GetBookmarksMenuFolder(&bookmarksMenuFolder);
NS_ENSURE_SUCCESS(rv,rv);
PRInt64 toolbarFolder;
@ -1706,23 +1676,13 @@ nsPlacesImportExportService::WriteContainerHeader(nsINavHistoryResultNode* aFold
if (folderId == placesRoot) {
rv = aOutput->Write(kPlacesRootAttribute, sizeof(kPlacesRootAttribute)-1, &dummy);
NS_ENSURE_SUCCESS(rv, rv);
} else if (folderId == bookmarksRoot) {
} else if (folderId == bookmarksMenuFolder) {
rv = aOutput->Write(kBookmarksRootAttribute, sizeof(kBookmarksRootAttribute)-1, &dummy);
NS_ENSURE_SUCCESS(rv, rv);
} else if (folderId == toolbarFolder) {
rv = aOutput->Write(kToolbarFolderAttribute, sizeof(kToolbarFolderAttribute)-1, &dummy);
NS_ENSURE_SUCCESS(rv, rv);
}
// favicon (most folders won't have one)
nsCOMPtr<nsIURI> folderURI;
rv = mBookmarksService->GetFolderURI(folderId, getter_AddRefs(folderURI));
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString folderSpec;
rv = folderURI->GetSpec(folderSpec);
NS_ENSURE_SUCCESS(rv, rv);
rv = WriteFaviconAttribute(folderSpec, aOutput);
NS_ENSURE_SUCCESS(rv, rv);
// ">"
rv = aOutput->Write(kCloseAngle, sizeof(kCloseAngle)-1, &dummy);
@ -2176,18 +2136,6 @@ nsPlacesImportExportService::WriteContainerContents(nsINavHistoryResultNode* aFo
rv = folderNode->SetContainerOpen(PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 placesRoot;
rv = mBookmarksService->GetPlacesRoot(&placesRoot);
NS_ENSURE_SUCCESS(rv,rv);
PRInt64 bookmarksRoot;
rv = mBookmarksService->GetBookmarksRoot(&bookmarksRoot);
NS_ENSURE_SUCCESS(rv,rv);
PRInt64 toolbarFolder;
rv = mBookmarksService->GetToolbarFolder(&toolbarFolder);
NS_ENSURE_SUCCESS(rv,rv);
PRUint32 childCount = 0;
folderNode->GetChildCount(&childCount);
for (PRUint32 i = 0; i < childCount; ++i) {
@ -2202,14 +2150,6 @@ nsPlacesImportExportService::WriteContainerContents(nsINavHistoryResultNode* aFo
PRInt64 childFolderId;
rv = child->GetItemId(&childFolderId);
NS_ENSURE_SUCCESS(rv, rv);
if (folderId == placesRoot && (childFolderId == toolbarFolder ||
childFolderId == bookmarksRoot)) {
// don't write out the bookmarks menu folder from the
// places root. When writing to bookmarks.html, it is reparented
// to the menu, which is the root of the namespace. This provides
// better backwards compatability.
continue;
}
// it could be a regular folder or it could be a livemark
PRBool isLivemark;
@ -2310,11 +2250,11 @@ nsPlacesImportExportService::RunBatched(nsISupports* aUserData)
{
nsresult rv;
if (mIsImportDefaults) {
PRInt64 bookmarksRoot;
rv = mBookmarksService->GetBookmarksRoot(&bookmarksRoot);
PRInt64 bookmarksMenuFolder;
rv = mBookmarksService->GetBookmarksMenuFolder(&bookmarksMenuFolder);
NS_ENSURE_SUCCESS(rv,rv);
rv = mBookmarksService->RemoveFolderChildren(bookmarksRoot);
rv = mBookmarksService->RemoveFolderChildren(bookmarksMenuFolder);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -2394,9 +2334,13 @@ nsPlacesImportExportService::ExportHTMLToFile(nsILocalFile* aBookmarksFile)
rv = NS_NewBufferedOutputStream(getter_AddRefs(strm), out, 4096);
NS_ENSURE_SUCCESS(rv, rv);
// get bookmarks root id
PRInt64 bookmarksRoot;
rv = mBookmarksService->GetBookmarksRoot(&bookmarksRoot);
// get bookmarks menu folder id
PRInt64 bookmarksMenuFolder;
rv = mBookmarksService->GetBookmarksMenuFolder(&bookmarksMenuFolder);
NS_ENSURE_SUCCESS(rv,rv);
PRInt64 toolbarFolder;
rv = mBookmarksService->GetToolbarFolder(&toolbarFolder);
NS_ENSURE_SUCCESS(rv,rv);
// file header
@ -2415,7 +2359,7 @@ nsPlacesImportExportService::ExportHTMLToFile(nsILocalFile* aBookmarksFile)
NS_ENSURE_SUCCESS(rv, rv);
// query for just this folder
rv = query->SetFolders(&bookmarksRoot, 1);
rv = query->SetFolders(&bookmarksMenuFolder, 1);
NS_ENSURE_SUCCESS(rv, rv);
// execute query
@ -2432,16 +2376,6 @@ nsPlacesImportExportService::ExportHTMLToFile(nsILocalFile* aBookmarksFile)
rv = strm->Write(kRootIntro, sizeof(kRootIntro)-1, &dummy); // <H1
NS_ENSURE_SUCCESS(rv, rv);
// bookmarks menu favicon
nsCOMPtr<nsIURI> folderURI;
rv = mBookmarksService->GetFolderURI(bookmarksRoot, getter_AddRefs(folderURI));
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString folderSpec;
rv = folderURI->GetSpec(folderSpec);
NS_ENSURE_SUCCESS(rv, rv);
rv = WriteFaviconAttribute(folderSpec, strm);
NS_ENSURE_SUCCESS(rv, rv);
// '>Bookmarks</H1>
rv = strm->Write(kCloseAngle, sizeof(kCloseAngle)-1, &dummy); // >
NS_ENSURE_SUCCESS(rv, rv);
@ -2462,6 +2396,21 @@ nsPlacesImportExportService::ExportHTMLToFile(nsILocalFile* aBookmarksFile)
rv = WriteContainerContents(rootNode, EmptyCString(), strm);
NS_ENSURE_SUCCESS(rv, rv);
// write out the toolbar folder contents as a folder under the bookmarks-menu
// for backwards compatibility
rv = query->SetFolders(&toolbarFolder, 1);
NS_ENSURE_SUCCESS(rv, rv);
rv = mHistoryService->ExecuteQuery(query, options, getter_AddRefs(result));
NS_ENSURE_SUCCESS(rv, rv);
// get root (folder) node
rv = result->GetRoot(getter_AddRefs(rootNode));
NS_ENSURE_SUCCESS(rv, rv);
rv = WriteContainer(rootNode, nsDependentCString(kIndent), strm);
NS_ENSURE_SUCCESS(rv, rv);
// epilogue
rv = WriteContainerEpilogue(EmptyCString(), strm);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -139,10 +139,6 @@ placesTransactionsService.prototype = {
return new placesSortFolderByNameTransactions(aFolderId, aFolderIndex);
},
setBookmarksToolbar: function placesSetBkmkToolbar(aFolderId) {
return new placesSetBookmarksToolbarTransactions(aFolderId);
},
commitTransaction: function placesCommitTxn(txn) {
this.mTransactionManager.doTransaction(txn);
},
@ -741,23 +737,6 @@ placesSortFolderByNameTransactions.prototype = {
}
};
function placesSetBookmarksToolbarTransactions(aFolderId) {
this._folderId = aFolderId;
this.redoTransaction = this.doTransaction;
this._oldFolderId = PlacesUtils.bookmarks.toolbarFolder;
}
placesSetBookmarksToolbarTransactions.prototype = {
__proto__: placesBaseTransaction.prototype,
doTransaction: function PSBTT_doTransaction() {
PlacesUtils.bookmarks.toolbarFolder = this._folderId;
},
undoTransaction: function PSBTT_undoTransaction() {
PlacesUtils.bookmarks.toolbarFolder = this._oldFolderId;
}
};
function NSGetModule(aCompMgr, aFileSpec) {
return XPCOMUtils.generateModule([placesTransactionsService]);
}

Просмотреть файл

@ -109,7 +109,7 @@ function run_test() {
try {
importer.importHTMLFromFile(bookmarksFileOld, true);
} catch(ex) { do_throw("couldn't import legacy bookmarks file: " + ex); }
testCanonicalBookmarks(bmsvc.bookmarksRoot);
testCanonicalBookmarks(bmsvc.bookmarksMenuFolder);
// Test exporting a Places canonical bookmarks file.
// 1. export to bookmarks.exported.html
@ -119,18 +119,18 @@ function run_test() {
try {
importer.exportHTMLToFile(bookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
bmsvc.removeFolderChildren(bmsvc.bookmarksRoot);
bmsvc.removeFolderChildren(bmsvc.bookmarksMenuFolder);
try {
importer.importHTMLFromFile(bookmarksFileNew, true);
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
testCanonicalBookmarks(bmsvc.bookmarksRoot);
testCanonicalBookmarks(bmsvc.bookmarksMenuFolder);
/*
// XXX import-to-folder tests disabled due to bug 363634
// Test importing a pre-Places canonical bookmarks file to a specific folder.
// 1. create a new folder
// 2. import bookmarks.preplaces.html to that folder
// 3. run the test-suite
var testFolder = bmsvc.createFolder(bmsvc.bookmarksRoot, "test-import", bmsvc.DEFAULT_INDEX);
var testFolder = bmsvc.createFolder(bmsvc.bookmarksMenuFolder, "test-import", bmsvc.DEFAULT_INDEX);
try {
importer.importHTMLFromFileToFolder(bookmarksFileOld, testFolder, false);
} catch(ex) { do_throw("couldn't import the exported file to folder: " + ex); }
@ -141,7 +141,7 @@ function run_test() {
// 1. create a new folder
// 2. import bookmarks.exported.html to that folder
// 3. run the test-suite
var testFolder = bmsvc.createFolder(bmsvc.bookmarksRoot, "test-import", bmsvc.DEFAULT_INDEX);
var testFolder = bmsvc.createFolder(bmsvc.bookmarksMenuFolder, "test-import", bmsvc.DEFAULT_INDEX);
try {
importer.importHTMLFromFileToFolder(bookmarksFileNew, testFolder, false);
} catch(ex) { do_throw("couldn't import the exported file to folder: " + ex); }
@ -157,7 +157,7 @@ function run_test() {
// 3. export to file
// 3. import the exported bookmarks file
// 4. run the test-suite
bmsvc.removeFolderChildren(bmsvc.bookmarksRoot);
bmsvc.removeFolderChildren(bmsvc.bookmarksMenuFolder);
try {
importer.importHTMLFromFile(bookmarksFileNew, true);
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
@ -167,7 +167,7 @@ function run_test() {
try {
importer.importHTMLFromFile(bookmarksFileNew, true);
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
testCanonicalBookmarks(bmsvc.bookmarksRoot);
testCanonicalBookmarks(bmsvc.bookmarksMenuFolder);
*/
/*
XXX if there are new fields we add to the bookmarks HTML format
@ -189,31 +189,13 @@ function testCanonicalBookmarks(aFolder) {
var result = histsvc.executeQuery(query, histsvc.getNewQueryOptions());
var rootNode = result.root;
rootNode.containerOpen = true;
do_check_eq(rootNode.childCount, 6);
// bookmarks toolbar
var toolbar = rootNode.getChild(2);
toolbar.QueryInterface(Ci.nsINavHistoryQueryResultNode);
toolbar.containerOpen = true;
do_check_eq(toolbar.childCount, 2);
// livemark
var livemark = toolbar.getChild(1);
// title
do_check_eq("Latest Headlines", livemark.title);
// livemark check
do_check_true(livemarksvc.isLivemark(livemark.itemId));
// site url
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
livemarksvc.getSiteURI(livemark.itemId).spec);
// feed url
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
livemarksvc.getFeedURI(livemark.itemId).spec);
toolbar.containerOpen = false;
// 6-2: the toolbar contents are imported to the places-toolbar folder,
// the separator above it is removed.
do_check_eq(rootNode.childCount, 4);
// get test folder
var testFolder = rootNode.getChild(5);
var testFolder = rootNode.getChild(3);
do_check_eq(testFolder.type, testFolder.RESULT_TYPE_FOLDER);
do_check_eq(testFolder.title, "test");
@ -289,4 +271,26 @@ function testCanonicalBookmarks(aFolder) {
// clean up
testFolder.containerOpen = false;
rootNode.containerOpen = false;
query.setFolders([bmsvc.toolbarFolder], 1);
result = histsvc.executeQuery(query, histsvc.getNewQueryOptions());
// bookmarks toolbar
var toolbar = result.root;
toolbar.containerOpen = true;
do_check_eq(toolbar.childCount, 2);
// livemark
var livemark = toolbar.getChild(1);
// title
do_check_eq("Latest Headlines", livemark.title);
// livemark check
do_check_true(livemarksvc.isLivemark(livemark.itemId));
// site url
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
livemarksvc.getSiteURI(livemark.itemId).spec);
// feed url
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
livemarksvc.getFeedURI(livemark.itemId).spec);
toolbar.containerOpen = false;
}

Просмотреть файл

@ -114,10 +114,10 @@ var observer = {
bmsvc.addObserver(observer, false);
// get bookmarks root index
var root = bmsvc.bookmarksRoot;
var root = bmsvc.bookmarksMenuFolder;
// index at which items should begin
var bmStartIndex = 1;
var bmStartIndex = 0;
// main
function run_test() {
@ -185,22 +185,22 @@ function run_test() {
// Moving items between the same folder
do_check_eq(observer._itemMovedId, bkmk1Id);
do_check_eq(observer._itemMovedOldParent, root);
do_check_eq(observer._itemMovedOldIndex, 1);
do_check_eq(observer._itemMovedOldIndex, 0);
do_check_eq(observer._itemMovedNewParent, root);
do_check_eq(observer._itemMovedNewIndex, 2);
do_check_eq(observer._itemMovedNewIndex, 1);
txn3.undoTransaction();
do_check_eq(observer._itemMovedId, bkmk1Id);
do_check_eq(observer._itemMovedOldParent, root);
do_check_eq(observer._itemMovedOldIndex, 2);
do_check_eq(observer._itemMovedOldIndex, 1);
do_check_eq(observer._itemMovedNewParent, root);
do_check_eq(observer._itemMovedNewIndex, 1);
do_check_eq(observer._itemMovedNewIndex, 0);
// Moving items between different folders
var txn3b = ptSvc.moveItem(bkmk1Id, fldrId, -1);
txn3b.doTransaction();
do_check_eq(observer._itemMovedId, bkmk1Id);
do_check_eq(observer._itemMovedOldParent, root);
do_check_eq(observer._itemMovedOldIndex, 1);
do_check_eq(observer._itemMovedOldIndex, 0);
do_check_eq(observer._itemMovedNewParent, fldrId);
do_check_eq(observer._itemMovedNewIndex, 2);
txn3.undoTransaction();
@ -208,7 +208,7 @@ function run_test() {
do_check_eq(observer._itemMovedOldParent, fldrId);
do_check_eq(observer._itemMovedOldIndex, 2);
do_check_eq(observer._itemMovedNewParent, root);
do_check_eq(observer._itemMovedNewIndex, 1);
do_check_eq(observer._itemMovedNewIndex, 0);
// Test Removing a Folder
ptSvc.commitTransaction(ptSvc.createFolder("Folder2", root, -1));
@ -217,22 +217,22 @@ function run_test() {
txn4.doTransaction();
do_check_eq(observer._itemRemovedId, fldrId2);
do_check_eq(observer._itemRemovedFolder, root);
do_check_eq(observer._itemRemovedIndex, 3);
do_check_eq(observer._itemRemovedIndex, 2);
txn4.undoTransaction();
do_check_eq(observer._itemAddedId, fldrId2);
do_check_eq(observer._itemAddedParent, root);
do_check_eq(observer._itemAddedIndex, 3);
do_check_eq(observer._itemAddedIndex, 2);
// Test removing an item
var txn5 = ptSvc.removeItem(bkmk2Id);
txn5.doTransaction();
do_check_eq(observer._itemRemovedId, bkmk2Id);
do_check_eq(observer._itemRemovedFolder, root);
do_check_eq(observer._itemRemovedIndex, 1);
do_check_eq(observer._itemRemovedIndex, 0);
txn5.undoTransaction();
do_check_eq(observer._itemAddedParent, root);
do_check_eq(observer._itemAddedIndex, 1);
do_check_eq(observer._itemAddedIndex, 0);
// Test creating a separator
var txn6 = ptSvc.createSeparator(root, 1);
@ -330,15 +330,6 @@ function run_test() {
do_check_eq(observer._itemChangedProperty, "livemark/feedURI");
do_check_eq(observer._itemChangedValue, "");
// setBookmarksToolbar
ptSvc.commitTransaction(ptSvc.createFolder("Testing toolbar folder", root, bmStartIndex));
var tmpFolderId = bmsvc.getChildFolder(root, "Testing toolbar folder");
var txn15 = ptSvc.setBookmarksToolbar(tmpFolderId);
txn15.doTransaction();
do_check_eq(observer._itemChangedId, tmpFolderId);
do_check_eq(observer._itemChangedProperty, "became_toolbar_folder");
txn15.undoTransaction();
// Test setLoadInSidebar
var txn16 = ptSvc.setLoadInSidebar(bkmk1Id, true);
txn16.doTransaction();

Просмотреть файл

@ -4,9 +4,6 @@
<!ENTITY editBookmarkOverlay.siteLocation.label "Site Location:">
<!ENTITY editBookmarkOverlay.liveTitlesSeparator.label "Live Titles">
<!ENTITY editBookmarkOverlay.folder.label "Folder:">
<!ENTITY editBookmarkOverlay.allBookmarksFolderItem.label "All Bookmarks">
<!ENTITY editBookmarkOverlay.bookmarksMenuFolderItem.label "Bookmarks Menu">
<!ENTITY editBookmarkOverlay.toolbarFolderItem.label "Bookmarks Toolbar">
<!ENTITY editBookmarkOverlay.foldersExpanderDown.tooltip "Show all the bookmarks folders">
<!ENTITY editBookmarkOverlay.expanderUp.tooltip "Hide">
<!ENTITY editBookmarkOverlay.tags.label "Tags:">

Просмотреть файл

@ -114,10 +114,6 @@
<!ENTITY cmd.moveBookmarks.label "Move...">
<!ENTITY cmd.moveBookmarks.accesskey "M">
<!ENTITY cmd.moveBookmarks.menuLabel "Move Bookmark(s)...">
<!ENTITY cmd.moveBookmarks.menuAccesskey "M">
<!ENTITY cmd.personalToolbarFolder.menuLabel "Set as Bookmarks Toolbar Folder">
<!ENTITY cmd.personalToolbarFolder.menuAccesskey "b">
<!ENTITY col.name.label "Name">
<!ENTITY col.tags.label "Tags">

Просмотреть файл

@ -105,3 +105,7 @@ mostVisitedBookmarksTitle=Most Visited Starred Pages
recentlyUsedTagsTitle=Recently Used Tags
mostUsedTagsTitle=Most Used Tags
mostVisitedSitesTitle=Most Visited Pages
OrganizerQueryHistory=History
OrganizerQueryDownloads=Downloads
OrganizerQueryAllBookmarks=All Bookmarks

Просмотреть файл

@ -182,6 +182,14 @@ toolbarbutton.bookmark-item .toolbarbutton-text {
list-style-image: url("chrome://browser/skin/page-livemarks.png");
}
.bookmark-item[tagContainer] {
list-style-image: url("chrome://mozapps/skin/places/tagContainerIcon.png");
}
.bookmark-item[query] {
list-style-image: url("chrome://browser/skin/places/query.png");
}
.bookmark-item[livemark] .menuitem-iconic {
list-style-image: url("chrome://browser/skin/places/livemarkItem.png");
}

Просмотреть файл

@ -102,21 +102,33 @@ treechildren::-moz-tree-image(title) {
treechildren::-moz-tree-image(title, container),
treechildren::-moz-tree-image(title, open) {
list-style-image: url("chrome://global/skin/tree/folder.png") !important;
-moz-image-region: rect(0px, 16px, 16px, 0px);
list-style-image: url("chrome://global/skin/tree/folder.png");
-moz-image-region: rect(0, 16px, 16px, 0);
}
treechildren::-moz-tree-image(title, separator) {
list-style-image: none;
width: 0px !important;
height: 0px !important;
margin: 0px 0px;
width: 0 !important;
height: 0 !important;
margin: 0;
}
treechildren::-moz-tree-row(session-start) {
border-top:1px dotted ThreeDShadow;
}
treechildren::-moz-tree-image(container, livemark) {
list-style-image: url("chrome://browser/skin/page-livemarks.png");
}
treechildren::-moz-tree-image(container, tagContainer) {
list-style-image: url("chrome://mozapps/skin/places/tagContainerIcon.png");
}
treechildren::-moz-tree-image(container, query) {
list-style-image: url("chrome://browser/skin/places/query.png");
}
/* FIXME this should make the date field invisible, but only does it for
unselected items and maybe won't work for different color schemes. */
treechildren::-moz-tree-cell-text(date, session-continue) {

Просмотреть файл

@ -202,50 +202,53 @@ menuitem.bookmark-item {
/* ::::: bookmark items ::::: */
.bookmark-item {
list-style-image: url("chrome://global/skin/icons/folder-item.png") !important;
list-style-image: url("chrome://global/skin/icons/folder-item.png");
-moz-image-region: rect(0px, 16px, 16px, 0px)
}
.bookmark-item[container="true"] {
-moz-image-region: rect(0px, 32px, 16px, 16px) !important;
.bookmark-item[container] {
-moz-image-region: rect(0px, 32px, 16px, 16px);
}
.bookmark-item[open="true"],
.bookmark-item[container="true"][open="true"] {
-moz-image-region: rect(16px, 32px, 32px, 16px) !important;
.bookmark-item[container][open] {
-moz-image-region: rect(16px, 32px, 32px, 16px);
}
/* livemarks have the same layout as folder-item, but in the browser-only livemark-item.png */
/* only the folder icon has any effect for now, item icon is unused */
.bookmark-item[livemark="true"] {
list-style-image: url("chrome://browser/skin/livemark-folder.png") !important;
-moz-image-region: rect(0px, 16px, 16px, 0px) !important;
.bookmark-item[container][livemark] {
list-style-image: url("chrome://browser/skin/livemark-folder.png");
-moz-image-region: rect(0px, 16px, 16px, 0px);
}
.bookmark-item[livemark="true"][chromedir="rtl"] {
list-style-image: url("chrome://browser/skin/livemark-folder-rtl.png") !important;
-moz-image-region: rect(0px, 16px, 16px, 0px) !important;
.bookmark-item[container][livemark][chromedir="rtl"] {
list-style-image: url("chrome://browser/skin/livemark-folder-rtl.png");
-moz-image-region: rect(0px, 16px, 16px, 0px);
}
.bookmark-item[livemark="true"][open="true"],
.bookmark-item[livemark="true"][open="true"][chromedir="rtl"] {
-moz-image-region: rect(16px, 16px, 32px, 0px) !important;
.bookmark-item[container][livemark][open],
.bookmark-item[container][livemark][open][chromedir="rtl"] {
-moz-image-region: rect(16px, 16px, 32px, 0px);
}
.bookmark-item[type="menu"][livemark="true"],
.bookmark-item[type="menu"][livemark="true"][chromedir="rtl"] {
-moz-image-region: rect(0px, 32px, 16px, 16px) !important;
.bookmark-item[type="menu"][livemark],
.bookmark-item[type="menu"][livemark][chromedir="rtl"] {
-moz-image-region: rect(0px, 32px, 16px, 16px);
}
.bookmark-item[type="menu"][livemark="true"][open="true"],
.bookmark-item[type="menu"][livemark="true"][open="true"][chromedir="rtl"] {
-moz-image-region: rect(16px, 32px, 32px, 16px) !important;
.bookmark-item[type="menu"][livemark][open],
.bookmark-item[type="menu"][livemark][open][chromedir="rtl"] {
-moz-image-region: rect(16px, 32px, 32px, 16px);
}
/* ::::: query items ::::: */
.bookmark-item[container][tagContainer] {
list-style-image: url("chrome://mozapps/skin/places/tagContainerIcon.png");
-moz-image-region: auto;
}
.query-item[container] {
.bookmark-item[container][query] {
list-style-image: url("chrome://browser/skin/places/query.png");
-moz-image-region: auto;
}
/* ::::: primary toolbar buttons ::::: */

Просмотреть файл

@ -104,13 +104,8 @@ treechildren::-moz-tree-image(title, separator) {
height: 0;
}
treechildren::-moz-tree-image(title, livemark\/bookmarkFeedURI) {
list-style-image: url("chrome://browser/skin/livemark-item.png") !important;
-moz-image-region: rect(0px, 16px, 16px, 0px);
}
treechildren::-moz-tree-image(title, container) {
list-style-image: url("chrome://global/skin/icons/folder-item.png") !important;
list-style-image: url("chrome://global/skin/icons/folder-item.png");
-moz-image-region: rect(0px, 32px, 16px, 16px);
}
@ -118,6 +113,21 @@ treechildren::-moz-tree-image(title, open) {
-moz-image-region: rect(16px, 32px, 32px, 16px);
}
treechildren::-moz-tree-image(title, container, livemark) {
list-style-image: url("chrome://browser/skin/page-livemarks.png");
-moz-image-region: auto;
}
treechildren::-moz-tree-image(title, container, tagContainer) {
list-style-image: url("chrome://mozapps/skin/places/tagContainerIcon.png");
-moz-image-region: auto;
}
treechildren::-moz-tree-image(title, container, query) {
list-style-image: url("chrome://browser/skin/places/query.png");
-moz-image-region: auto;
}
treechildren::-moz-tree-row(session-start) {
border-top:1px dotted ThreeDShadow;
font-weight: bold;

Просмотреть файл

@ -458,7 +458,7 @@ nsProfileCollector::LogBookmarks(nsIMetricsEventItem *profile)
LogBookmarkLocation(bookmarksItem, NS_LITERAL_CSTRING("full-tree"),
&counter, root, PR_TRUE);
rv = bmSvc->GetBookmarksRoot(&root);
rv = bmSvc->GetBookmarksMenuFolder(&root);
NS_ENSURE_SUCCESS(rv, rv);
LogBookmarkLocation(bookmarksItem, NS_LITERAL_CSTRING("root"),

Просмотреть файл

@ -163,33 +163,33 @@ interface nsINavBookmarkObserver : nsISupports
* folders. A URI in history can be contained in one or more such folders.
*/
[scriptable, uuid(3ba9f6ca-0003-43b9-bdfb-7014dfec5b76)]
[scriptable, uuid(fb8dc678-681b-453b-a5fe-ab3cc19b3698)]
interface nsINavBookmarksService : nsISupports
{
/**
* The folder ID of the Places root.
* The item ID of the Places root.
*/
readonly attribute long long placesRoot;
/**
* The folder ID of the bookmarks root.
* The item ID of the bookmarks menu folder.
*/
readonly attribute long long bookmarksRoot;
readonly attribute long long bookmarksMenuFolder;
/**
* The folder ID of the top-level folders that contain the tag "folders".
* The item ID of the top-level folder that contain the tag "folders".
*/
readonly attribute long long tagRoot;
readonly attribute long long tagsFolder;
/**
* The folder ID of the unfiled-bookmarks root
* The item ID of the unfiled-bookmarks folder.
*/
readonly attribute long long unfiledRoot;
readonly attribute long long unfiledBookmarksFolder;
/**
* The folder ID of the personal toolbar.
* The item ID of the personal toolbar folder.
*/
attribute long long toolbarFolder;
readonly attribute long long toolbarFolder;
/**
* This value should be used for APIs that allow passing in an index
@ -424,18 +424,6 @@ interface nsINavBookmarksService : nsISupports
*/
void setItemIndex(in long long aItemId, in long aNewIndex);
/**
* Get the place: url for a bookmark folder. You can use this value to
* get/set the icon for a folder. Its important that you use this function
* instead of just serializing the query/options for a given folder because
* you may have different options or query parameters. This function will
* give the canonical value.
* @param aFolder
* The folder whose URI should be retrieved
* @returns The URI for the folder
*/
nsIURI getFolderURI(in long long aFolder);
/**
* Get an item's type (bookmark, separator, folder).
* The type is one of the TYPE_* constants defined above.

Просмотреть файл

@ -911,10 +911,9 @@ interface nsINavHistoryQuery : nsISupports
* remove everything that doesn't have that annotation. Asking for things
* that DO have a given annotation is a little different. It also includes
* things that have never been visited. This allows place queries to be
* returned (which might include bookmark folders -- use the bookmark
* service's GetFolderURI) as well as anything else that may have been
* tagged with an annotation. This will only work for RESULTS_AS_URI since
* there will be no visits for these items.
* returned as well as anything else that may have been tagged with an
* annotation. This will only work for RESULTS_AS_URI since there will be
* no visits for these items.
*/
attribute boolean annotationIsNot;
attribute AUTF8String annotation;
@ -939,7 +938,7 @@ interface nsINavHistoryQuery : nsISupports
/**
* This object represents the global options for executing a query.
*/
[scriptable, uuid(ed29f063-0c5f-471c-b4bc-b1e889524cd2)]
[scriptable, uuid(ff73bf85-2755-4c1a-a48d-8c91ccca770e)]
interface nsINavHistoryQueryOptions : nsISupports
{
/**
@ -1131,13 +1130,6 @@ interface nsINavHistoryQueryOptions : nsISupports
* ones, and THEN sort by title.
*/
attribute unsigned long maxResults;
/**
* if a bookmark title is null (note, not empty),
* attempt to use the history title.
* Note, this is false by default.
*/
attribute boolean resolveNullBookmarkTitles;
/**
* only apply our query options to the containers

Просмотреть файл

@ -41,7 +41,7 @@
interface nsIURI;
interface nsIVariant;
[scriptable, uuid(3acd6c94-232b-4ac4-b99e-0631b7e96ed9)]
[scriptable, uuid(6c473fa6-8c2c-406c-b31f-62f40a2841bc)]
interface nsITaggingService : nsISupports
{
/**
@ -90,11 +90,6 @@ interface nsITaggingService : nsISupports
* Retrieves all tags used to tag URIs in the data-base (sorted by name).
*/
readonly attribute nsIVariant allTags;
/**
* Retrieves the URL spec for the tag container icon
*/
readonly attribute AUTF8String tagContainerIconSpec;
};
%{C++

Просмотреть файл

@ -309,13 +309,9 @@ LivemarkService.prototype = {
var livemarkID = bms.createFolder(folder, name, index);
this._bms.setFolderReadonly(livemarkID, true);
// Add an annotation to map the folder URI to the livemark feed URI
// Add an annotation to map the folder id to the livemark feed URI
this._ans.setItemAnnotation(livemarkID, LMANNO_FEEDURI, feedURI.spec, 0,
this._ans.EXPIRE_NEVER);
// Set the favicon
var faviconService = Cc[FAV_CONTRACTID].getService(Ci.nsIFaviconService);
var livemarkURI = bms.getFolderURI(livemarkID);
faviconService.setFaviconUrlForPage(livemarkURI, this._iconURI);
if (siteURI) {
// Add an annotation to map the folder URI to the livemark site URI

Просмотреть файл

@ -153,7 +153,7 @@ nsNavBookmarks::Init()
// Results are kGetInfoIndex_*
nsCAutoString selectChildren(
NS_LITERAL_CSTRING("SELECT h.id, h.url, a.title, "
NS_LITERAL_CSTRING("SELECT h.id, h.url, COALESCE(a.title, h.title), "
"h.rev_host, h.visit_count, "
"(SELECT MAX(visit_date) FROM moz_historyvisits WHERE place_id = h.id), "
"f.url, null, a.id, "
@ -285,9 +285,6 @@ nsNavBookmarks::Init()
rv = InitRoots();
NS_ENSURE_SUCCESS(rv, rv);
rv = InitToolbarFolder();
NS_ENSURE_SUCCESS(rv, rv);
rv = transaction.Commit();
NS_ENSURE_SUCCESS(rv, rv);
@ -433,14 +430,43 @@ nsNavBookmarks::InitRoots()
getter_AddRefs(getRootStatement));
NS_ENSURE_SUCCESS(rv, rv);
PRBool importDefaults = PR_FALSE;
rv = CreateRoot(getRootStatement, NS_LITERAL_CSTRING("places"), &mRoot, 0, &importDefaults);
PRBool createdPlacesRoot = PR_FALSE;
rv = CreateRoot(getRootStatement, NS_LITERAL_CSTRING("places"), &mRoot, 0, &createdPlacesRoot);
NS_ENSURE_SUCCESS(rv, rv);
getRootStatement->Reset();
rv = CreateRoot(getRootStatement, NS_LITERAL_CSTRING("menu"), &mBookmarksRoot, mRoot, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
PRBool createdToolbarFolder;
getRootStatement->Reset();
rv = CreateRoot(getRootStatement, NS_LITERAL_CSTRING("toolbar"), &mToolbarFolder, mRoot, &createdToolbarFolder);
NS_ENSURE_SUCCESS(rv, rv);
// Once toolbar was not a root, we may need to move over the items and
// delete the custom folder
if (!createdPlacesRoot && createdToolbarFolder) {
nsAnnotationService* annosvc = nsAnnotationService::GetAnnotationService();
NS_ENSURE_TRUE(annosvc, NS_ERROR_OUT_OF_MEMORY);
nsTArray<PRInt64> folders;
annosvc->GetItemsWithAnnotationTArray(BOOKMARKS_TOOLBAR_FOLDER_ANNO,
&folders);
if (folders.Length() > 0) {
nsCOMPtr<mozIStorageStatement> moveItems;
rv = DBConn()->CreateStatement(NS_LITERAL_CSTRING("UPDATE moz_bookmarks SET parent = ?1 WHERE parent=?2"),
getter_AddRefs(moveItems));
rv = moveItems->BindInt64Parameter(0, mToolbarFolder);
NS_ENSURE_SUCCESS(rv, rv);
rv = moveItems->BindInt64Parameter(1, folders[0]);
NS_ENSURE_SUCCESS(rv, rv);
rv = moveItems->Execute();
NS_ENSURE_SUCCESS(rv, rv);
rv = RemoveFolder(folders[0]);
NS_ENSURE_SUCCESS(rv, rv);
}
}
getRootStatement->Reset();
rv = CreateRoot(getRootStatement, NS_LITERAL_CSTRING("tags"), &mTagRoot, mRoot, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
@ -449,11 +475,23 @@ nsNavBookmarks::InitRoots()
rv = CreateRoot(getRootStatement, NS_LITERAL_CSTRING("unfiled"), &mUnfiledRoot, mRoot, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
if (importDefaults) {
// when there is no places root, we should define the hierarchy by
// importing the default one.
// Set titles for special folders
// We cannot rely on createdPlacesRoot due to Fx3beta->final migration path
nsCOMPtr<nsIPrefService> prefService =
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = prefService->GetBranch("", getter_AddRefs(prefBranch));
NS_ENSURE_SUCCESS(rv, rv);
PRBool importDefaults = PR_TRUE;
rv = prefBranch->GetBoolPref("browser.places.importDefaults", &importDefaults);
if (NS_FAILED(rv) || importDefaults) {
rv = InitDefaults();
NS_ENSURE_SUCCESS(rv, rv);
rv = prefBranch->SetBoolPref("browser.places.importDefaults", PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
@ -467,45 +505,37 @@ nsNavBookmarks::InitRoots()
nsresult
nsNavBookmarks::InitDefaults()
{
// give bookmarks root folder a title "Bookmarks"
// Bookmarks Menu
nsXPIDLString bookmarksTitle;
nsresult rv = mBundle->GetStringFromName(NS_LITERAL_STRING("PlacesBookmarksRootTitle").get(),
nsresult rv = mBundle->GetStringFromName(NS_LITERAL_STRING("BookmarksMenuFolderTitle").get(),
getter_Copies(bookmarksTitle));
NS_ENSURE_SUCCESS(rv, rv);
rv = SetItemTitle(mBookmarksRoot, bookmarksTitle);
NS_ENSURE_SUCCESS(rv, rv);
// create toolbar folder, parent bookmarks root, entitled "Bookmarks Toolbar Folder"
PRInt64 toolbarId;
// Bookmarks Toolbar
nsXPIDLString toolbarTitle;
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("PlacesBookmarksToolbarTitle").get(),
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("BookmarksToolbarFolderTitle").get(),
getter_Copies(toolbarTitle));
NS_ENSURE_SUCCESS(rv, rv);
rv = CreateFolder(mBookmarksRoot, toolbarTitle,
nsINavBookmarksService::DEFAULT_INDEX, &toolbarId);
NS_ENSURE_SUCCESS(rv, rv);
rv = SetToolbarFolder(toolbarId);
rv = SetItemTitle(mToolbarFolder, toolbarTitle);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
// Unfiled Bookmarks
nsXPIDLString unfiledTitle;
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("UnfiledBookmarksFolderTitle").get(),
getter_Copies(unfiledTitle));
NS_ENSURE_SUCCESS(rv, rv);
rv = SetItemTitle(mUnfiledRoot, unfiledTitle);
NS_ENSURE_SUCCESS(rv, rv);
/**
* Initialize the toolbar folder
*/
nsresult
nsNavBookmarks::InitToolbarFolder()
{
nsAnnotationService* annosvc = nsAnnotationService::GetAnnotationService();
NS_ENSURE_TRUE(annosvc, NS_ERROR_OUT_OF_MEMORY);
nsTArray<PRInt64> folders;
nsresult rv = annosvc->GetItemsWithAnnotationTArray(BOOKMARKS_TOOLBAR_FOLDER_ANNO,
&folders);
if (NS_FAILED(rv) || folders.Length() == 0)
mToolbarFolder = -1;
else
mToolbarFolder = folders[0];
// Tags
nsXPIDLString tagsTitle;
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("TagsFolderTitle").get(),
getter_Copies(tagsTitle));
NS_ENSURE_SUCCESS(rv, rv);
rv = SetItemTitle(mTagRoot, tagsTitle);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -858,7 +888,7 @@ nsNavBookmarks::GetPlacesRoot(PRInt64 *aRoot)
}
NS_IMETHODIMP
nsNavBookmarks::GetBookmarksRoot(PRInt64 *aRoot)
nsNavBookmarks::GetBookmarksMenuFolder(PRInt64 *aRoot)
{
*aRoot = mBookmarksRoot;
return NS_OK;
@ -872,47 +902,14 @@ nsNavBookmarks::GetToolbarFolder(PRInt64 *aFolderId)
}
NS_IMETHODIMP
nsNavBookmarks::SetToolbarFolder(PRInt64 aFolderId)
{
// XXX - validate that input is a valid folder id
if (aFolderId < 0)
return NS_ERROR_INVALID_ARG;
if (aFolderId == mToolbarFolder)
return NS_OK;
nsresult rv;
nsAnnotationService* annosvc = nsAnnotationService::GetAnnotationService();
NS_ENSURE_TRUE(annosvc, NS_ERROR_OUT_OF_MEMORY);
if (mToolbarFolder != 0) {
rv = annosvc->RemoveItemAnnotation(mToolbarFolder,
BOOKMARKS_TOOLBAR_FOLDER_ANNO);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = annosvc->SetItemAnnotationInt32(aFolderId, BOOKMARKS_TOOLBAR_FOLDER_ANNO,
1, 0, nsIAnnotationService::EXPIRE_NEVER);
NS_ENSURE_SUCCESS(rv, rv);
// update local
mToolbarFolder = aFolderId;
// notify observers
ENUMERATE_WEAKARRAY(mObservers, nsINavBookmarkObserver,
OnItemChanged(mToolbarFolder, NS_LITERAL_CSTRING("became_toolbar_folder"),
PR_FALSE, EmptyCString()));
return NS_OK;
}
NS_IMETHODIMP
nsNavBookmarks::GetTagRoot(PRInt64 *aRoot)
nsNavBookmarks::GetTagsFolder(PRInt64 *aRoot)
{
*aRoot = mTagRoot;
return NS_OK;
}
NS_IMETHODIMP
nsNavBookmarks::GetUnfiledRoot(PRInt64 *aRoot)
nsNavBookmarks::GetUnfiledBookmarksFolder(PRInt64 *aRoot)
{
*aRoot = mUnfiledRoot;
return NS_OK;
@ -1948,21 +1945,6 @@ nsNavBookmarks::ResultNodeForContainer(PRInt64 aID,
return NS_OK;
}
NS_IMETHODIMP
nsNavBookmarks::GetFolderURI(PRInt64 aFolder, nsIURI **aURI)
{
// Create a query for the folder; the URI is the querystring from that
// query. We could create a proper query and serialize it, which might
// make it less prone to breakage since we'd only have one code path.
// However, this gets called a lot (every time we make a folder node)
// and constructing fake queries and options each time just to
// serialize them would be a waste. Therefore, we just synthesize the
// correct string here.
nsCAutoString spec("place:folder=");
spec.AppendInt(aFolder);
return NS_NewURI(aURI, spec);
}
nsresult
nsNavBookmarks::QueryFolderChildren(PRInt64 aFolderId,
nsNavHistoryQueryOptions *aOptions,

Просмотреть файл

@ -112,7 +112,6 @@ private:
nsresult InitRoots();
nsresult InitDefaults();
nsresult InitToolbarFolder();
nsresult CreateRoot(mozIStorageStatement* aGetRootStatement,
const nsCString& name, PRInt64* aID,
PRInt64 aParentID, PRBool* aWasCreated);
@ -166,7 +165,8 @@ private:
nsresult IsBookmarkedInDatabase(PRInt64 aBookmarkID, PRBool* aIsBookmarked);
nsCOMPtr<mozIStorageStatement> mDBGetChildren; // kGetInfoIndex_* results + kGetChildrenIndex_* results
// kGetInfoIndex_* results + kGetChildrenIndex_* results
nsCOMPtr<mozIStorageStatement> mDBGetChildren;
static const PRInt32 kGetChildrenIndex_Position;
static const PRInt32 kGetChildrenIndex_Type;
static const PRInt32 kGetChildrenIndex_ForeignKey;

Просмотреть файл

@ -270,7 +270,7 @@ nsNavHistory::nsNavHistory() : mNowValid(PR_FALSE),
mBatchLevel(0),
mLock(nsnull),
mBatchHasTransaction(PR_FALSE),
mTagRoot(-1)
mTagsFolder(-1)
{
#ifdef LAZY_ADD
mLazyTimerSet = PR_TRUE;
@ -2174,7 +2174,9 @@ PRBool NeedToFilterResultSet(const nsCOMArray<nsNavHistoryQuery>& aQueries,
PRUint32 groupCount;
const PRUint16 *groupings = aOptions->GroupingMode(&groupCount);
if (groupCount != 0 || aOptions->ExcludeQueries())
// Always filter bookmarks queries to avoid the inclusion of query nodes
if (groupCount != 0 ||
aOptions->QueryType() == nsINavHistoryQueryOptions::QUERY_TYPE_BOOKMARKS)
return PR_TRUE;
nsCString parentAnnotationToExclude;
@ -2282,16 +2284,7 @@ nsNavHistory::ConstructQueryString(const nsCOMArray<nsNavHistoryQuery>& aQueries
"LEFT OUTER JOIN moz_favicons f ON h.favicon_id = f.id ");
groupBy = NS_LITERAL_CSTRING(" GROUP BY h.id");
} else if (aOptions->QueryType() == nsINavHistoryQueryOptions::QUERY_TYPE_BOOKMARKS) {
queryString = NS_LITERAL_CSTRING("SELECT b.fk, h.url, ");
if (aOptions->ResolveNullBookmarkTitles()) {
// COALESCE, first non NULL param
queryString += NS_LITERAL_CSTRING(
"COALESCE(b.title, "
"(SELECT h.title FROM moz_bookmarks b2, moz_places h2 WHERE b2.fk = h2.id AND b2.id = b.id)), ");
}
else {
queryString += NS_LITERAL_CSTRING("b.title, ");
}
queryString = NS_LITERAL_CSTRING("SELECT b.fk, h.url, COALESCE(b.title, h.title), ");
queryString += NS_LITERAL_CSTRING(
"h.rev_host, h.visit_count, "
"(SELECT MAX(visit_date) FROM moz_historyvisits WHERE place_id = b.fk), "
@ -4125,19 +4118,19 @@ nsNavHistory::GroupByHost(nsNavHistoryQueryResultNode *aResultNode,
}
PRInt64
nsNavHistory::GetTagRoot()
nsNavHistory::GetTagsFolder()
{
// cache our tag root
// cache our tags folder
// note, we can't do this in nsNavHistory::Init(),
// as getting the bookmarks service would initialize it.
if (mTagRoot == -1) {
if (mTagsFolder == -1) {
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, -1);
nsresult rv = bookmarks->GetTagRoot(&mTagRoot);
nsresult rv = bookmarks->GetTagsFolder(&mTagsFolder);
NS_ENSURE_SUCCESS(rv, -1);
}
return mTagRoot;
return mTagsFolder;
}
// nsNavHistory::GroupByFolder
@ -4151,14 +4144,6 @@ nsNavHistory::GroupByFolder(nsNavHistoryQueryResultNode *aResultNode,
if (!folders.Init(512))
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsITaggingService> tagService =
do_GetService(TAGGING_SERVICE_CID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString tagContainerIconSpec;
rv = tagService->GetTagContainerIconSpec(tagContainerIconSpec);
NS_ENSURE_SUCCESS(rv, rv);
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
if (!bookmarks)
return NS_ERROR_OUT_OF_MEMORY;
@ -4185,22 +4170,17 @@ nsNavHistory::GroupByFolder(nsNavHistoryQueryResultNode *aResultNode,
rv = CreatePlacesPersistURN(aResultNode, parentId, NS_ConvertUTF16toUTF8(title), urn);
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 grandparentId;
rv = bookmarks->GetFolderIdForItem(parentId, &grandparentId);
NS_ENSURE_SUCCESS(rv, rv);
// create parent node
// if the grandparent is the tag root, the parent is a tag container
// so use the tag container icon
folderNode = new nsNavHistoryContainerResultNode(urn,
NS_ConvertUTF16toUTF8(title),
(grandparentId == GetTagRoot()) ? tagContainerIconSpec : EmptyCString(),
EmptyCString(),
nsNavHistoryResultNode::RESULT_TYPE_FOLDER,
PR_TRUE, EmptyCString(), aResultNode->mOptions);
if (!folders.Put(parentId, folderNode))
return NS_ERROR_OUT_OF_MEMORY;
folderNode->mItemId = parentId;
rv = aDest->AppendObject(folderNode);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -4237,10 +4217,8 @@ nsNavHistory::URIHasTag(nsIURI* aURI, const nsAString& aTag)
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
PRInt64 tagRoot;
rv = bookmarks->GetTagRoot(&tagRoot);
NS_ENSURE_SUCCESS(rv, rv);
rv = mDBURIHasTag->BindInt64Parameter(2, tagRoot);
PRInt64 tagsFolder = GetTagsFolder();
rv = mDBURIHasTag->BindInt64Parameter(2, tagsFolder);
NS_ENSURE_SUCCESS(rv, rv);
PRBool hasTag = PR_FALSE;
@ -4594,7 +4572,14 @@ nsNavHistory::RowToResult(mozIStorageValueArray* aRow,
if (IsQueryURI(url)) {
// special case "place:" URIs: turn them into containers
PRInt64 itemId = aRow->AsInt64(kGetInfoIndex_ItemId);
return QueryRowToResult(itemId, url, title, accessCount, time, favicon, aResult);
rv = QueryRowToResult(itemId, url, title, accessCount, time, favicon, aResult);
// If it's a simple folder node (i.e. a shortcut to another folder), apply
// our options for it.
if (*aResult && (*aResult)->IsFolder()) {
(*aResult)->GetAsContainer()->mOptions = aOptions;
}
return rv;
} else if (aOptions->ResultType() == nsNavHistoryQueryOptions::RESULTS_AS_URI) {
*aResult = new nsNavHistoryResultNode(url, title, accessCount, time,
favicon);

Просмотреть файл

@ -615,8 +615,8 @@ protected:
static void IdleTimerCallback(nsITimer* aTimer, void* aClosure);
nsresult OnIdle();
PRInt64 mTagRoot;
PRInt64 GetTagRoot();
PRInt64 mTagsFolder;
PRInt64 GetTagsFolder();
};
/**

Просмотреть файл

@ -493,11 +493,9 @@ nsNavHistory::AutoCompleteTagsSearch()
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
PRInt64 tagRoot;
nsresult rv = bookmarks->GetTagRoot(&tagRoot);
NS_ENSURE_SUCCESS(rv, rv);
PRInt64 tagsFolder = GetTagsFolder();
rv = mDBTagAutoCompleteQuery->BindInt64Parameter(0, tagRoot);
nsresult rv = mDBTagAutoCompleteQuery->BindInt64Parameter(0, tagsFolder);
NS_ENSURE_SUCCESS(rv, rv);
nsString escapedSearchString;

Просмотреть файл

@ -167,7 +167,6 @@ static void SetOptionsKeyUint32(const nsCString& aValue,
#define QUERYKEY_FORCE_ORIGINAL_TITLE "originalTitle"
#define QUERYKEY_INCLUDE_HIDDEN "includeHidden"
#define QUERYKEY_SHOW_SESSIONS "showSessions"
#define QUERYKEY_RESOLVE_NULL_BOOKMARK_TITLES "resolveNullBookmarkTitles"
#define QUERYKEY_APPLY_OPTIONS_TO_CONTAINERS "applyOptionsToContainers"
#define QUERYKEY_MAX_RESULTS "maxResults"
#define QUERYKEY_QUERY_TYPE "queryType"
@ -413,7 +412,7 @@ nsNavHistory::QueriesToQueryString(nsINavHistoryQuery **aQueries,
for (PRUint32 i = 0; i < folderCount; ++i) {
AppendAmpersandIfNonempty(queryString);
queryString += NS_LITERAL_CSTRING(QUERYKEY_FOLDER "=");
AppendInt64(queryString, folders[0]);
AppendInt64(queryString, folders[i]);
}
nsMemory::Free(folders);
}
@ -502,12 +501,6 @@ nsNavHistory::QueriesToQueryString(nsINavHistoryQuery **aQueries,
queryString += NS_LITERAL_CSTRING(QUERYKEY_SHOW_SESSIONS "=1");
}
// resolve null bookmark titles
if (options->ResolveNullBookmarkTitles()) {
AppendAmpersandIfNonempty(queryString);
queryString += NS_LITERAL_CSTRING(QUERYKEY_RESOLVE_NULL_BOOKMARK_TITLES "=1");
}
// apply options to containers
if (options->ApplyOptionsToContainers()) {
AppendAmpersandIfNonempty(queryString);
@ -761,11 +754,6 @@ nsNavHistory::TokensToQueries(const nsTArray<QueryKeyValuePair>& aTokens,
} else if (kvp.key.EqualsLiteral(QUERYKEY_SHOW_SESSIONS)) {
SetOptionsKeyBool(kvp.value, aOptions,
&nsINavHistoryQueryOptions::SetShowSessions);
// resolve null bookmark titles
} else if (kvp.key.EqualsLiteral(QUERYKEY_RESOLVE_NULL_BOOKMARK_TITLES)) {
SetOptionsKeyBool(kvp.value, aOptions,
&nsINavHistoryQueryOptions::SetResolveNullBookmarkTitles);
// apply options to containers
} else if (kvp.key.EqualsLiteral(QUERYKEY_APPLY_OPTIONS_TO_CONTAINERS)) {
SetOptionsKeyBool(kvp.value, aOptions,
@ -1299,20 +1287,6 @@ nsNavHistoryQueryOptions::SetShowSessions(PRBool aShowSessions)
return NS_OK;
}
// resolveNullBookmarkTitles
NS_IMETHODIMP
nsNavHistoryQueryOptions::GetResolveNullBookmarkTitles(PRBool* aResolveNullBookmarkTitles)
{
*aResolveNullBookmarkTitles = mResolveNullBookmarkTitles;
return NS_OK;
}
NS_IMETHODIMP
nsNavHistoryQueryOptions::SetResolveNullBookmarkTitles(PRBool aResolveNullBookmarkTitles)
{
mResolveNullBookmarkTitles = aResolveNullBookmarkTitles;
return NS_OK;
}
// applyOptionsToContainers
NS_IMETHODIMP
nsNavHistoryQueryOptions::GetApplyOptionsToContainers(PRBool* aApplyOptionsToContainers)
@ -1389,7 +1363,6 @@ nsNavHistoryQueryOptions::Clone(nsNavHistoryQueryOptions **aResult)
result->mExcludeItems = mExcludeItems;
result->mExcludeQueries = mExcludeQueries;
result->mShowSessions = mShowSessions;
result->mResolveNullBookmarkTitles = mResolveNullBookmarkTitles;
result->mApplyOptionsToContainers = mApplyOptionsToContainers;
result->mExpandQueries = mExpandQueries;
result->mMaxResults = mMaxResults;

Просмотреть файл

@ -125,7 +125,6 @@ public:
mExpandQueries(PR_TRUE),
mIncludeHidden(PR_FALSE),
mShowSessions(PR_FALSE),
mResolveNullBookmarkTitles(PR_FALSE),
mApplyOptionsToContainers(PR_FALSE),
mMaxResults(0),
mQueryType(nsINavHistoryQueryOptions::QUERY_TYPE_HISTORY)
@ -151,7 +150,6 @@ public:
PRBool ExpandQueries() const { return mExpandQueries; }
PRBool IncludeHidden() const { return mIncludeHidden; }
PRBool ShowSessions() const { return mShowSessions; }
PRBool ResolveNullBookmarkTitles() const { return mResolveNullBookmarkTitles; }
PRBool ApplyOptionsToContainers() const { return mApplyOptionsToContainers; }
PRUint32 MaxResults() const { return mMaxResults; }
PRUint16 QueryType() const { return mQueryType; }
@ -181,7 +179,6 @@ private:
PRPackedBool mExpandQueries;
PRPackedBool mIncludeHidden;
PRPackedBool mShowSessions;
PRPackedBool mResolveNullBookmarkTitles;
PRPackedBool mApplyOptionsToContainers;
PRUint32 mMaxResults;
PRUint16 mQueryType;

Просмотреть файл

@ -72,8 +72,6 @@
#include "nsAnnotationService.h"
#include "nsCycleCollectionParticipant.h"
#define ICONURI_QUERY "chrome://browser/skin/places/query.png"
// What we want is: NS_INTERFACE_MAP_ENTRY(self) for static IID accessors,
// but some of our classes (like nsNavHistoryResult) have an ambiguous base
// class of nsISupports which prevents this from working (the default macro
@ -1954,9 +1952,6 @@ nsNavHistoryQueryResultNode::nsNavHistoryQueryResultNode(
mContentsValid(PR_FALSE),
mBatchInProgress(PR_FALSE)
{
// queries have special icons if not otherwise set
if (mFaviconURI.IsEmpty())
mFaviconURI.AppendLiteral(ICONURI_QUERY);
}
nsNavHistoryQueryResultNode::nsNavHistoryQueryResultNode(
@ -1976,26 +1971,6 @@ nsNavHistoryQueryResultNode::nsNavHistoryQueryResultNode(
NS_ASSERTION(history, "History service missing");
mLiveUpdate = history->GetUpdateRequirements(mQueries, mOptions,
&mHasSearchTerms);
// queries have special icons if not otherwise set
if (mFaviconURI.IsEmpty()) {
mFaviconURI.AppendLiteral(ICONURI_QUERY);
// see if there's a favicon explicitly set on this query
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
if (! faviconService)
return;
nsresult rv = VerifyQueriesSerialized();
if (NS_FAILED(rv)) return;
nsCOMPtr<nsIURI> queryURI;
rv = NS_NewURI(getter_AddRefs(queryURI), mURI);
if (NS_FAILED(rv)) return;
nsCOMPtr<nsIURI> favicon;
rv = faviconService->GetFaviconForPage(queryURI, getter_AddRefs(favicon));
if (NS_FAILED(rv)) return;
favicon->GetSpec(mFaviconURI);
}
}
@ -2761,35 +2736,6 @@ nsNavHistoryFolderResultNode::nsNavHistoryFolderResultNode(
mContentsValid(PR_FALSE)
{
mItemId = aFolderId;
// Get the favicon, if any, for this folder. Errors aren't too important
// here, so just give up if anything bad happens.
//
// PERFORMANCE: This is not very efficient, we may want to pass this as
// a parameter and integrate it into the query that generates the
// bookmark results.
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
if (! bookmarks)
return;
// This is the folder URI used for the favicon. It IS NOT the folder URI
// that we will return from GetUri. That one will include the options for
// this specific query, while the folderURI is invariant w.r.t. options.
nsCOMPtr<nsIURI> folderURI;
nsresult rv = bookmarks->GetFolderURI(aFolderId, getter_AddRefs(folderURI));
if (NS_FAILED(rv))
return;
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
if (! faviconService)
return;
nsCOMPtr<nsIURI> favicon;
rv = faviconService->GetFaviconForPage(folderURI, getter_AddRefs(favicon));
if (NS_FAILED(rv))
return; // this will happen when there is no favicon (most common case)
// we have a favicon, save it
favicon->GetSpec(mFaviconURI);
}
@ -3944,14 +3890,11 @@ nsNavHistoryResult::OnItemChanged(PRInt64 aItemId,
nsresult rv = bookmarkService->GetItemType(aItemId, &itemType);
NS_ENSURE_SUCCESS(rv, rv);
if (itemType == nsINavBookmarksService::TYPE_FOLDER) {
// simple case: Just notify the folder nodes directly
ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(aItemId,
OnItemChanged(aItemId, aProperty, aIsAnnotationProperty, aValue));
return NS_OK;
}
// Note: folder-nodes set their own bookmark observer only once they're
// opened, meaning we cannot optimize this code path for changes done to
// folder-nodes.
// Here we need to find the changed items under the folders list
// Find the changed items under the folders list
PRInt64 folderId;
rv = bookmarkService->GetFolderIdForItem(aItemId, &folderId);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -49,8 +49,6 @@ const ANNO_CONTRACTID = "@mozilla.org/browser/annotation-service;1";
const FAV_CONTRACTID = "@mozilla.org/browser/favicon-service;1";
const OBSS_CONTRACTID = "@mozilla.org/observer-service;1";
const TAG_CONTAINER_ICON_URI = "chrome://mozapps/skin/places/tagContainerIcon.png"
var gIoService = Cc[IO_CONTRACTID].getService(Ci.nsIIOService);
/**
@ -82,7 +80,7 @@ TaggingService.prototype = {
if (!this.__tagsResult) {
var options = this._history.getNewQueryOptions();
var query = this._history.getNewQuery();
query.setFolders([this._bms.tagRoot], 1);
query.setFolders([this._bms.tagsFolder], 1);
this.__tagsResult = this._history.executeQuery(query, options);
this.__tagsResult.root.containerOpen = true;
@ -117,15 +115,6 @@ TaggingService.prototype = {
return null;
},
get _tagContainerIcon() {
if (!this.__tagContainerIcon) {
this.__tagContainerIcon =
gIoService.newURI(TAG_CONTAINER_ICON_URI, null, null);
}
return this.__tagContainerIcon;
},
/**
* Creates a tag container under the tags-root with the given name.
*
@ -134,15 +123,8 @@ TaggingService.prototype = {
* @returns the id of the new container.
*/
_createTag: function TS__createTag(aName) {
var id = this._bms.createFolder(this._bms.tagRoot, aName,
this._bms.DEFAULT_INDEX);
// Set the favicon
var faviconService = Cc[FAV_CONTRACTID].getService(Ci.nsIFaviconService);
var uri = this._bms.getFolderURI(id);
faviconService.setFaviconUrlForPage(uri, this._tagContainerIcon);
return id;
return this._bms.createFolder(this._bms.tagsFolder, aName,
this._bms.DEFAULT_INDEX);
},
/**
@ -293,11 +275,6 @@ TaggingService.prototype = {
tags.sort();
return tags;
},
// nsITaggingService
get tagContainerIconSpec() {
return TAG_CONTAINER_ICON_URI;
},
// nsIObserver
observe: function TS_observe(subject, topic, data) {

Просмотреть файл

@ -104,20 +104,20 @@ var observer = {
};
bmsvc.addObserver(observer, false);
// get bookmarks root id
var root = bmsvc.bookmarksRoot;
// get bookmarks menu folder id
var root = bmsvc.bookmarksMenuFolder;
// index at which items should begin
var bmStartIndex = 1;
var bmStartIndex = 0;
// main
function run_test() {
// test roots
// test special folders
do_check_true(bmsvc.placesRoot > 0);
do_check_true(bmsvc.bookmarksRoot > 0);
do_check_true(bmsvc.tagRoot > 0);
do_check_true(bmsvc.bookmarksMenuFolder > 0);
do_check_true(bmsvc.tagsFolder > 0);
do_check_true(bmsvc.toolbarFolder > 0);
do_check_true(bmsvc.unfiledRoot > 0);
do_check_true(bmsvc.unfiledBookmarksFolder > 0);
// test getFolderIdForItem() with bogus item id will throw
try {
@ -132,9 +132,11 @@ function run_test() {
} catch(ex) {}
// test root parentage
do_check_eq(bmsvc.getFolderIdForItem(bmsvc.bookmarksRoot), bmsvc.placesRoot);
do_check_eq(bmsvc.getFolderIdForItem(bmsvc.tagRoot), bmsvc.placesRoot);
do_check_eq(bmsvc.getFolderIdForItem(bmsvc.bookmarksMenuFolder), bmsvc.placesRoot);
do_check_eq(bmsvc.getFolderIdForItem(bmsvc.tagsFolder), bmsvc.placesRoot);
do_check_eq(bmsvc.getFolderIdForItem(bmsvc.toolbarFolder), bmsvc.placesRoot);
do_check_eq(bmsvc.getFolderIdForItem(bmsvc.unfiledBookmarksFolder), bmsvc.placesRoot);
// create a folder to hold all the tests
// this makes the tests more tolerant of changes to default_places.html
var testRoot = bmsvc.createFolder(root, "places bookmarks xpcshell tests", bmsvc.DEFAULT_INDEX);
@ -539,15 +541,6 @@ function run_test() {
var bmIndex = bmsvc.getItemIndex(newId12);
do_check_eq(1, bmIndex);
// test changing the bookmarks toolbar folder
var oldToolbarFolder = bmsvc.toolbarFolder;
var newToolbarFolderId = bmsvc.createFolder(testRoot, "new toolbar folder", -1);
bmsvc.toolbarFolder = newToolbarFolderId;
do_check_eq(bmsvc.toolbarFolder, newToolbarFolderId);
do_check_eq(observer._itemChangedId, newToolbarFolderId);
do_check_eq(observer._itemChangedProperty, "became_toolbar_folder");
do_check_eq(observer._itemChangedValue, "");
// insert a bookmark with title ZZZXXXYYY and then search for it.
// this test confirms that we can find bookmarks that we haven't visited
// (which are "hidden") and that we can find by title.
@ -556,7 +549,7 @@ function run_test() {
bmsvc.DEFAULT_INDEX, "");
do_check_eq(observer._itemAddedId, newId13);
do_check_eq(observer._itemAddedParent, testRoot);
do_check_eq(observer._itemAddedIndex, 12);
do_check_eq(observer._itemAddedIndex, 11);
// set bookmark title
bmsvc.setItemTitle(newId13, "ZZZXXXYYY");

Просмотреть файл

@ -50,8 +50,8 @@ try {
do_throw("Could not get history service\n");
}
// get bookmarks root id
var testRoot = bmsvc.bookmarksRoot;
// get bookmarks menu folder id
var testRoot = bmsvc.bookmarksMenuFolder;
// main
function run_test() {

Просмотреть файл

@ -134,14 +134,11 @@ function run_test() {
var root = result.root;
root.containerOpen = true;
do_check_eq(root.childCount, 3);
// these containers are nsNavHistoryContainerResultNodes,
// created in GroupByFolder() and not nsNavHistoryFolderResultNodes,
// so they should not have an item id.
do_check_eq(root.getChild(0).itemId, -1);
// note these containers are nsNavHistoryContainerResultNodes,
// created in GroupByFolder() and not nsNavHistoryFolderResultNodes,
do_check_eq(root.getChild(0).title, "test folder");
do_check_eq(root.getChild(1).itemId, -1);
do_check_eq(root.getChild(1).title, "subfolder 1");
do_check_eq(root.getChild(2).itemId, -1);
do_check_eq(root.getChild(2).title, "subfolder 2");
// check the contents of the "test folder" container

Просмотреть файл

@ -187,7 +187,7 @@ function run_test() {
var options = histsvc.getNewQueryOptions();
var query = histsvc.getNewQuery();
query.setFolders([bmsvc.bookmarksRoot], 1);
query.setFolders([bmsvc.bookmarksMenuFolder], 1);
var result = histsvc.executeQuery(query, options);
result.viewer = viewer;
var root = result.root;
@ -198,7 +198,7 @@ function run_test() {
// nsINavHistoryResultViewer.itemInserted
// add a bookmark
var testBookmark = bmsvc.insertBookmark(bmsvc.bookmarksRoot, testURI, bmsvc.DEFAULT_INDEX, "foo");
var testBookmark = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, testURI, bmsvc.DEFAULT_INDEX, "foo");
do_check_eq("foo", viewer.insertedItem.title);
do_check_eq(testURI.spec, viewer.insertedItem.uri);
@ -211,7 +211,7 @@ function run_test() {
do_check_eq(viewer.changedItem.title, "baz");
// nsINavHistoryResultViewer.itemRemoved
var removedBookmark = bmsvc.insertBookmark(bmsvc.bookmarksRoot, uri("http://google.com"), bmsvc.DEFAULT_INDEX, "foo");
var removedBookmark = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, uri("http://google.com"), bmsvc.DEFAULT_INDEX, "foo");
bmsvc.removeItem(removedBookmark);
do_check_eq(removedBookmark, viewer.removedItem.itemId);

Просмотреть файл

@ -80,26 +80,12 @@ function run_test() {
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
options.maxResults = 2;
// test without the "resolveNullBookmarkTitles" option,
// our tag items don't have titles.
var query = histsvc.getNewQuery();
query.setFolders([bmsvc.tagRoot], 1);
var result = histsvc.executeQuery(query, options);
var root = result.root;
root.containerOpen = true;
do_check_eq(root.childCount, 2);
do_check_eq(root.getChild(0).title, null);
do_check_eq(root.getChild(1).title, null);
// test with the "resolveNullBookmarkTitles" option,
// our tag items have titles from history
options = histsvc.getNewQueryOptions();
options.resolveNullBookmarkTitles = true;
options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
options.maxResults = 2;
query = histsvc.getNewQuery();
query.setFolders([bmsvc.tagRoot], 1);
query.setFolders([bmsvc.tagsFolder], 1);
var result = histsvc.executeQuery(query, options);
var root = result.root;
root.containerOpen = true;

Просмотреть файл

@ -67,7 +67,7 @@ function run_test() {
var options = histsvc.getNewQueryOptions();
var query = histsvc.getNewQuery();
query.setFolders([bmsvc.tagRoot], 1);
query.setFolders([bmsvc.tagsFolder], 1);
var result = histsvc.executeQuery(query, options);
var tagRoot = result.root;
tagRoot.containerOpen = true;

Просмотреть файл

@ -1,6 +1,4 @@
PlacesBookmarksRootTitle=Bookmarks
PlacesBookmarksRootDescription=Add bookmarks to this folder to see them displayed on the Bookmarks Menu
PlacesBookmarksRootIconURI=chrome://browser/skin/places/bookmarksMenu.png
PlacesBookmarksToolbarTitle=Bookmarks Toolbar Folder
PlacesBookmarksToolbarDescription=Add bookmarks to this folder to see them displayed on the Bookmarks Toolbar
BookmarksMenuFolderTitle=Bookmarks Menu
BookmarksToolbarFolderTitle=Bookmarks Toolbar
UnfiledBookmarksFolderTitle=Unfiled Bookmarks
TagsFolderTitle=Tags