Places:Drag & Drop

From MozillaWiki
Revision as of 00:46, 4 April 2006 by Ben (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Tree Drop Handling

The Places Tree View (tree.xml) implements nsINavHistoryResultViewObserver, which provides a method onDrop which is called by the view when a drop occurs. When this happens, the following steps occur:

  1. Check whether or not the drop is valid by calling the canDrop method, returning silently if it is not.
  2. Determine how many new items will be inserted into open folders in the tree view after the drop completes.
  3. If the drag and drop operation occured within the same view, adjust the insertion index to account for the fact that items may have been removed before it.
  4. Call the controller's onDrop helper.

Controller Drop Handling Helper

The PlacesControllerDragHelper provides an onDrop method that performs view-agnostic drop handling. This method performs the following actions:

  1. Determine what mime types of objects are being dragged (from the dragged transferable), and compares this list of types supported as droppable by the target view (peerDropTypes, childDropTypes).
  2. For each dropped item, unwrap the data, generate insertion or copy transactions, and execute the transactions on the transaction manager.