Places:Drag & Drop: Difference between revisions
Jump to navigation
Jump to search
| Line 10: | Line 10: | ||
== Controller Drop Handling Helper == | == Controller Drop Handling Helper == | ||
The <code>PlacesControllerDragHelper</code> | The <code>PlacesControllerDragHelper</code> is an helper object providing methods and informations to views. | ||
# Determine what mime types of objects are being dragged (from the | Every drag & drop event in our views saves the current DataTransfer object (https://developer.mozilla.org/En/DragDrop/DataTransfer) to <code>PlacesControllerDragHelper.currentDataTransfer</code>. Helper methods will use this cached value to check for drop validity and perform it. | ||
# | |||
It provides an <code>onDrop</code> method that performs view-agnostic drop handling. | |||
For each dropped item this method performs the following actions: | |||
# Determine what mime types of objects are being dragged (from the <code>PlacesControllerDragHelper.currentDataTransfer</code> cached object), and compares this list of types supported as droppable with the list of flavors supported by Places' Views (<code>PlacesControllerDragHelper.GENERIC_VIEW_DROP_TYPES</code>). | |||
# In case this is a tab drag&drop converts data to an acceptable flavor. | |||
# Unwrap the data, generate insertion or copy transactions, aggregates the transaction and executes them through the transaction manager. | |||
Revision as of 14:30, 9 March 2009
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:
- Check whether or not the drop is valid by calling the
canDropmethod, returning silently if it is not. - Determine how many new items will be inserted into open folders in the tree view after the drop completes.
- 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.
- Call the controller's onDrop helper.
Controller Drop Handling Helper
The PlacesControllerDragHelper is an helper object providing methods and informations to views.
Every drag & drop event in our views saves the current DataTransfer object (https://developer.mozilla.org/En/DragDrop/DataTransfer) to PlacesControllerDragHelper.currentDataTransfer. Helper methods will use this cached value to check for drop validity and perform it.
It provides an onDrop method that performs view-agnostic drop handling.
For each dropped item this method performs the following actions:
- Determine what mime types of objects are being dragged (from the
PlacesControllerDragHelper.currentDataTransfercached object), and compares this list of types supported as droppable with the list of flavors supported by Places' Views (PlacesControllerDragHelper.GENERIC_VIEW_DROP_TYPES). - In case this is a tab drag&drop converts data to an acceptable flavor.
- Unwrap the data, generate insertion or copy transactions, aggregates the transaction and executes them through the transaction manager.