зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1160476 - ‘Bookmark this link’ context menu option doesn’t work. r=ttaubert
This commit is contained in:
Родитель
30b9e0482c
Коммит
57cc9e22c7
|
@ -483,38 +483,32 @@ var PlacesCommandHook = {
|
|||
* the address of the link target
|
||||
* @param aTitle
|
||||
* The link text
|
||||
* @param [optional] aDescription
|
||||
* The linked page description, if available
|
||||
*/
|
||||
bookmarkLink: Task.async(function* (aParentId, aURL, aTitle) {
|
||||
let node = null;
|
||||
if (PlacesUIUtils.useAsyncTransactions) {
|
||||
node = yield PlacesUIUtils.fetchNodeLike({ url: aURL });
|
||||
}
|
||||
else {
|
||||
let linkURI = makeURI(aURL);
|
||||
let itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI);
|
||||
if (itemId != -1) {
|
||||
node = { itemId, uri: aURL };
|
||||
PlacesUIUtils.completeNodeLikeObjectForItemId(node);
|
||||
}
|
||||
}
|
||||
|
||||
bookmarkLink: Task.async(function* (aParentId, aURL, aTitle, aDescription="") {
|
||||
let node = yield PlacesUIUtils.fetchNodeLike({ url: aURL });
|
||||
if (node) {
|
||||
PlacesUIUtils.showBookmarkDialog({ action: "edit"
|
||||
, type: "bookmark"
|
||||
, node
|
||||
}, window);
|
||||
}
|
||||
else {
|
||||
PlacesUIUtils.showBookmarkDialog({ action: "add"
|
||||
, type: "bookmark"
|
||||
, uri: linkURI
|
||||
, title: aTitle
|
||||
, hiddenRows: [ "description"
|
||||
, "location"
|
||||
, "loadInSidebar"
|
||||
, "keyword" ]
|
||||
}, window);
|
||||
}, window.top);
|
||||
return;
|
||||
}
|
||||
|
||||
let ip = new InsertionPoint(aParentId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
Components.interfaces.nsITreeView.DROP_ON);
|
||||
PlacesUIUtils.showBookmarkDialog({ action: "add"
|
||||
, type: "bookmark"
|
||||
, uri: makeURI(aURL)
|
||||
, title: aTitle
|
||||
, description: aDescription
|
||||
, defaultInsertionPoint: ip
|
||||
, hiddenRows: [ "description"
|
||||
, "location"
|
||||
, "loadInSidebar"
|
||||
, "keyword" ]
|
||||
}, window.top);
|
||||
}),
|
||||
|
||||
/**
|
||||
|
@ -586,7 +580,9 @@ var PlacesCommandHook = {
|
|||
else
|
||||
description = PlacesUIUtils.getDescriptionFromDocument(doc);
|
||||
|
||||
var toolbarIP = new InsertionPoint(PlacesUtils.toolbarFolderId, -1);
|
||||
var toolbarIP = new InsertionPoint(PlacesUtils.toolbarFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
Components.interfaces.nsITreeView.DROP_ON);
|
||||
PlacesUIUtils.showBookmarkDialog({ action: "add"
|
||||
, type: "livemark"
|
||||
, feedURI: feedURI
|
||||
|
@ -1001,7 +997,7 @@ var PlacesMenuDNDHandler = {
|
|||
onDragOver: function PMDH_onDragOver(event) {
|
||||
let ip = new InsertionPoint(PlacesUtils.bookmarksMenuFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
Ci.nsITreeView.DROP_ON);
|
||||
Components.interfaces.nsITreeView.DROP_ON);
|
||||
if (ip && PlacesControllerDragHelper.canDrop(ip, event.dataTransfer))
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -1017,7 +1013,7 @@ var PlacesMenuDNDHandler = {
|
|||
// Put the item at the end of bookmark menu.
|
||||
let ip = new InsertionPoint(PlacesUtils.bookmarksMenuFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
Ci.nsITreeView.DROP_ON);
|
||||
Components.interfaces.nsITreeView.DROP_ON);
|
||||
PlacesControllerDragHelper.onDrop(ip, event.dataTransfer);
|
||||
PlacesControllerDragHelper.currentDropTarget = null;
|
||||
event.stopPropagation();
|
||||
|
|
|
@ -1630,30 +1630,17 @@ nsContextMenu.prototype = {
|
|||
let onMessage = (message) => {
|
||||
mm.removeMessageListener("ContextMenu:BookmarkFrame:Result", onMessage);
|
||||
|
||||
let itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
|
||||
if (itemId == -1) {
|
||||
PlacesUIUtils.showBookmarkDialog({ action: "add"
|
||||
, type: "bookmark"
|
||||
, uri: uri
|
||||
, title: message.data.title
|
||||
, description: message.data.description
|
||||
, hiddenRows: [ "description"
|
||||
, "location"
|
||||
, "loadInSidebar"
|
||||
, "keyword" ]
|
||||
}, window.top);
|
||||
}
|
||||
else {
|
||||
PlacesUIUtils.showBookmarkDialog({ action: "edit"
|
||||
, type: "bookmark"
|
||||
, itemId: itemId
|
||||
}, window.top);
|
||||
}
|
||||
window.top.PlacesCommandHook.bookmarkLink(PlacesUtils.bookmarksMenuFolderId,
|
||||
uri.spec,
|
||||
message.data.title,
|
||||
message.data.description)
|
||||
.catch(Components.utils.reportError);
|
||||
};
|
||||
mm.addMessageListener("ContextMenu:BookmarkFrame:Result", onMessage);
|
||||
|
||||
mm.sendAsyncMessage("ContextMenu:BookmarkFrame", null, { target: this.target });
|
||||
},
|
||||
|
||||
markLink: function CM_markLink(origin) {
|
||||
// send link to social, if it is the page url linkURI will be null
|
||||
SocialMarks.markLink(origin, this.linkURI ? this.linkURI.spec : null, this.target);
|
||||
|
|
|
@ -235,14 +235,10 @@ var BookmarkPropertiesPanel = {
|
|||
else { // edit
|
||||
this._node = dialogInfo.node;
|
||||
this._title = this._node.title;
|
||||
switch (dialogInfo.type) {
|
||||
case "bookmark":
|
||||
this._itemType = BOOKMARK_ITEM;
|
||||
break;
|
||||
case "folder":
|
||||
this._itemType = BOOKMARK_FOLDER;
|
||||
break;
|
||||
}
|
||||
if (PlacesUtils.nodeIsFolder(this._node))
|
||||
this._itemType = BOOKMARK_FOLDER;
|
||||
else if (PlacesUtils.nodeIsURI(this._node))
|
||||
this._itemType = BOOKMARK_ITEM;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче