mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 509676 - Can't drag and drop a tag container to another standard point, r=dietrich
This commit is contained in:
parent
e5e63e4341
commit
bb2570b817
@ -1112,7 +1112,7 @@ PlacesController.prototype = {
|
||||
*/
|
||||
setDataTransfer: function PC_setDataTransfer(aEvent) {
|
||||
var dt = aEvent.dataTransfer;
|
||||
var doCopy = dt.effectAllowed == "copyLink" || dt.effectAllowed == "copy";
|
||||
var doCopy = ["copyLink", "copy", "link"].indexOf(dt.effectAllowed) != -1;
|
||||
|
||||
var result = this._view.getResult();
|
||||
var oldViewer = result.viewer;
|
||||
@ -1519,7 +1519,7 @@ var PlacesControllerDragHelper = {
|
||||
*/
|
||||
onDrop: function PCDH_onDrop(insertionPoint) {
|
||||
var dt = this.currentDataTransfer;
|
||||
var doCopy = dt.dropEffect == "copy";
|
||||
var doCopy = ["copy", "link"].indexOf(dt.dropEffect) != -1;
|
||||
|
||||
var transactions = [];
|
||||
var dropCount = dt.mozItemCount;
|
||||
|
@ -291,7 +291,7 @@ var PlacesUIUtils = {
|
||||
}
|
||||
|
||||
// tag folders use tag transactions
|
||||
if (aContainer == PlacesUtils.bookmarks.tagsFolder) {
|
||||
if (aContainer == PlacesUtils.tagsFolderId) {
|
||||
var txns = [];
|
||||
if (aData.children) {
|
||||
aData.children.forEach(function(aChild) {
|
||||
@ -364,30 +364,24 @@ var PlacesUIUtils = {
|
||||
case PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER:
|
||||
if (copy)
|
||||
return this._getFolderCopyTransaction(data, container, index);
|
||||
else { // Move the item
|
||||
var id = data.folder ? data.folder.id : data.id;
|
||||
return this.ptm.moveItem(id, container, index);
|
||||
}
|
||||
// Otherwise move the item.
|
||||
return this.ptm.moveItem(data.id, container, index);
|
||||
break;
|
||||
case PlacesUtils.TYPE_X_MOZ_PLACE:
|
||||
if (data.id <= 0) // non-bookmark item
|
||||
if (data.id == -1) // Not bookmarked.
|
||||
return this._getURIItemCopyTransaction(data, container, index);
|
||||
|
||||
if (copy) {
|
||||
// Copying a child of a live-bookmark by itself should result
|
||||
// as a new normal bookmark item (bug 376731)
|
||||
return this._getBookmarkItemCopyTransaction(data, container, index,
|
||||
["livemark/bookmarkFeedURI"]);
|
||||
}
|
||||
else
|
||||
return this.ptm.moveItem(data.id, container, index);
|
||||
if (copy)
|
||||
return this._getBookmarkItemCopyTransaction(data, container, index);
|
||||
// Otherwise move the item.
|
||||
return this.ptm.moveItem(data.id, container, index);
|
||||
break;
|
||||
case PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR:
|
||||
// There is no data in a separator, so copying it just amounts to
|
||||
// inserting a new separator.
|
||||
if (copy)
|
||||
return this.ptm.createSeparator(container, index);
|
||||
// Move the separator otherwise
|
||||
// Otherwise move the item.
|
||||
return this.ptm.moveItem(data.id, container, index);
|
||||
break;
|
||||
default:
|
||||
|
@ -883,7 +883,9 @@ var PlacesUtils = {
|
||||
});
|
||||
},
|
||||
|
||||
// identifier getters for special folders
|
||||
// Identifier getters for special folders.
|
||||
// You should use these everywhere PlacesUtils is available to avoid XPCOM
|
||||
// traversal just to get roots' ids.
|
||||
get placesRootId() {
|
||||
delete this.placesRootId;
|
||||
return this.placesRootId = this.bookmarks.placesRoot;
|
||||
@ -1358,7 +1360,7 @@ var PlacesUtils = {
|
||||
var id = -1;
|
||||
switch (aData.type) {
|
||||
case this.TYPE_X_MOZ_PLACE_CONTAINER:
|
||||
if (aContainer == PlacesUtils.bookmarks.tagsFolder) {
|
||||
if (aContainer == PlacesUtils.tagsFolderId) {
|
||||
// node is a tag
|
||||
if (aData.children) {
|
||||
aData.children.forEach(function(aChild) {
|
||||
@ -1495,10 +1497,8 @@ var PlacesUtils = {
|
||||
|
||||
function addGenericProperties(aPlacesNode, aJSNode) {
|
||||
aJSNode.title = aPlacesNode.title;
|
||||
var id = aPlacesNode.itemId;
|
||||
if (id != -1) {
|
||||
aJSNode.id = id;
|
||||
|
||||
aJSNode.id = aPlacesNode.itemId;
|
||||
if (aJSNode.id != -1) {
|
||||
var parent = aPlacesNode.parent;
|
||||
if (parent)
|
||||
aJSNode.parent = parent.itemId;
|
||||
@ -1512,7 +1512,7 @@ var PlacesUtils = {
|
||||
// XXX need a hasAnnos api
|
||||
var annos = [];
|
||||
try {
|
||||
annos = self.getAnnotationsForItem(id).filter(function(anno) {
|
||||
annos = self.getAnnotationsForItem(aJSNode.id).filter(function(anno) {
|
||||
// XXX should whitelist this instead, w/ a pref for
|
||||
// backup/restore of non-whitelisted annos
|
||||
// XXX causes JSON encoding errors, so utf-8 encode
|
||||
@ -1560,32 +1560,37 @@ var PlacesUtils = {
|
||||
}
|
||||
|
||||
function addContainerProperties(aPlacesNode, aJSNode) {
|
||||
// saved queries
|
||||
var concreteId = PlacesUtils.getConcreteItemId(aPlacesNode);
|
||||
if (aJSNode.id != -1 && (PlacesUtils.nodeIsQuery(aPlacesNode) ||
|
||||
(concreteId != aPlacesNode.itemId && !aResolveShortcuts))) {
|
||||
if (concreteId != -1) {
|
||||
// This is a bookmark or a tag container.
|
||||
if (PlacesUtils.nodeIsQuery(aPlacesNode) ||
|
||||
(concreteId != aPlacesNode.itemId && !aResolveShortcuts)) {
|
||||
aJSNode.type = self.TYPE_X_MOZ_PLACE;
|
||||
aJSNode.uri = aPlacesNode.uri;
|
||||
// folder shortcut
|
||||
if (aIsUICommand)
|
||||
aJSNode.concreteId = concreteId;
|
||||
}
|
||||
else { // Bookmark folder or a shortcut we should convert to folder.
|
||||
aJSNode.type = self.TYPE_X_MOZ_PLACE_CONTAINER;
|
||||
|
||||
// Mark root folders.
|
||||
if (aJSNode.id == self.placesRootId)
|
||||
aJSNode.root = "placesRoot";
|
||||
else if (aJSNode.id == self.bookmarksMenuFolderId)
|
||||
aJSNode.root = "bookmarksMenuFolder";
|
||||
else if (aJSNode.id == self.tagsFolderId)
|
||||
aJSNode.root = "tagsFolder";
|
||||
else if (aJSNode.id == self.unfiledBookmarksFolderId)
|
||||
aJSNode.root = "unfiledBookmarksFolder";
|
||||
else if (aJSNode.id == self.toolbarFolderId)
|
||||
aJSNode.root = "toolbarFolder";
|
||||
}
|
||||
}
|
||||
else {
|
||||
// This is a grouped container query, generated on the fly.
|
||||
aJSNode.type = self.TYPE_X_MOZ_PLACE;
|
||||
aJSNode.uri = aPlacesNode.uri;
|
||||
// folder shortcut
|
||||
if (aIsUICommand)
|
||||
aJSNode.concreteId = concreteId;
|
||||
return;
|
||||
}
|
||||
else if (aJSNode.id != -1) { // bookmark folder
|
||||
if (concreteId != aPlacesNode.itemId)
|
||||
aJSNode.type = self.TYPE_X_MOZ_PLACE;
|
||||
aJSNode.type = self.TYPE_X_MOZ_PLACE_CONTAINER;
|
||||
// mark special folders
|
||||
if (aJSNode.id == self.bookmarks.placesRoot)
|
||||
aJSNode.root = "placesRoot";
|
||||
else if (aJSNode.id == self.bookmarks.bookmarksMenuFolder)
|
||||
aJSNode.root = "bookmarksMenuFolder";
|
||||
else if (aJSNode.id == self.bookmarks.tagsFolder)
|
||||
aJSNode.root = "tagsFolder";
|
||||
else if (aJSNode.id == self.bookmarks.unfiledBookmarksFolder)
|
||||
aJSNode.root = "unfiledBookmarksFolder";
|
||||
else if (aJSNode.id == self.bookmarks.toolbarFolder)
|
||||
aJSNode.root = "toolbarFolder";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1736,7 +1741,7 @@ var PlacesUtils = {
|
||||
var options = this.history.getNewQueryOptions();
|
||||
options.expandQueries = false;
|
||||
var query = this.history.getNewQuery();
|
||||
query.setFolders([this.bookmarks.placesRoot], 1);
|
||||
query.setFolders([this.placesRootId], 1);
|
||||
var result = this.history.executeQuery(query, options);
|
||||
result.root.containerOpen = true;
|
||||
// serialize as JSON, write to stream
|
||||
|
Loading…
Reference in New Issue
Block a user