Bug 1248616 - move simulated places nodes after a successful drag 'n drop operation, which applies to Recently Bookmarked items. r=mak
authorMike de Boer <mdeboer@mozilla.com>
Tue, 31 May 2016 11:06:37 +0200
changeset 340658 a9d17539d46af1dc601c51277eee909874d0e9ad
parent 340657 7759a4010be36a0a774f2d2282bd1a333ce8c9d1
child 340659 8bf67bdad00282eed87c14a08c166a0ca90bf621
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1248616
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1248616 - move simulated places nodes after a successful drag 'n drop operation, which applies to Recently Bookmarked items. r=mak
browser/components/places/content/controller.js
browser/components/places/content/menu.xml
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -1545,29 +1545,37 @@ var PlacesControllerDragHelper = {
            aUnwrappedNode.grandParentId != PlacesUtils.tagsFolderId;
   },
 
   /**
    * Determines if a node can be moved.
    *
    * @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);
   },
 
   /**
    * Handles the drop of one or more items onto a view.
    * @param   insertionPoint
    *          The insertion point where the items should be dropped
--- a/browser/components/places/content/menu.xml
+++ b/browser/components/places/content/menu.xml
@@ -341,24 +341,25 @@
         if (elt.parentNode != this)
           return;
 
         if (window.XULBrowserWindow)
           window.XULBrowserWindow.setOverLink("", null);
       ]]></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.
         this._rootView._draggedElt = draggedElt;
         this._rootView.controller.setDataTransfer(event);
         this.setAttribute("dragstart", "true");
         event.stopPropagation();
       ]]></handler>