Bug 1248616 - move simulated places nodes after a successful drag 'n drop operation, which applies to Recently Bookmarked items. r=mak

This commit is contained in:
Mike de Boer 2016-05-31 11:06:37 +02:00
parent 2ed19fb31d
commit da651f3cb1
2 changed files with 17 additions and 8 deletions

View File

@ -1550,19 +1550,27 @@ var PlacesControllerDragHelper = {
*
* @param aNode
* A nsINavHistoryResultNode node.
* @param [optional] aDOMNode
* A XUL DOM node.
* @return True if the node can be moved, false otherwise.
*/
canMoveNode:
function PCDH_canMoveNode(aNode) {
canMoveNode(aNode, aDOMNode) {
// Only bookmark items are movable.
if (aNode.itemId == -1)
return false;
let parentNode = aNode.parent;
if (!parentNode) {
// Normally parentless places nodes can not be moved,
// but simulated bookmarked URI nodes are special.
return !!aDOMNode &&
aDOMNode.hasAttribute("simulated-places-node") &&
PlacesUtils.nodeIsBookmark(aNode);
}
// Once tags and bookmarked are divorced, the tag-query check should be
// removed.
let parentNode = aNode.parent;
return parentNode != null &&
!(PlacesUtils.nodeIsFolder(parentNode) &&
return !(PlacesUtils.nodeIsFolder(parentNode) &&
PlacesUIUtils.isContentsReadOnly(parentNode)) &&
!PlacesUtils.nodeIsTagQuery(parentNode);
},

View File

@ -346,14 +346,15 @@
]]></handler>
<handler event="dragstart"><![CDATA[
if (!event.target._placesNode)
let elt = event.target;
if (!elt._placesNode)
return;
let draggedElt = event.target._placesNode;
let draggedElt = elt._placesNode;
// Force a copy action if parent node is a query or we are dragging a
// not-removable node.
if (!PlacesControllerDragHelper.canMoveNode(draggedElt))
if (!PlacesControllerDragHelper.canMoveNode(draggedElt, elt))
event.dataTransfer.effectAllowed = "copyLink";
// Activate the view and cache the dragged element.