B2G/gecko/browser/components/places/content/controller.js
/**
   * Handles the drop of one or more items onto a view.
   * @param   insertionPoint
   *          The insertion point where the items should be dropped
   */
Handles the drop of one or more items onto a view.
@param   insertionPoint
The insertion point where the items should be dropped
Handles the drop of one or more items onto a view . @param insertionPoint The insertion point where the items should be dropped
function PCDH_onDrop(insertionPoint, dt) {
    let doCopy = ["copy", "link"].indexOf(dt.dropEffect) != -1;
    let transactions = [];
    let dropCount = dt.mozItemCount;
    let movedCount = 0;
    for (let i = 0; i < dropCount; ++i) {
      let flavor = this.getFirstValidFlavor(dt.mozTypesAt(i));
      if (!flavor)
        return;
      let data = dt.mozGetDataAt(flavor, i);
      let unwrapped;
      if (flavor != TAB_DROP_TYPE) {
        unwrapped = PlacesUtils.unwrapNodes(data, flavor)[0];
      }
      else if (data instanceof XULElement && data.localName == "tab" &&
               data.ownerDocument.defaultView instanceof ChromeWindow) {
        let uri = data.linkedBrowser.currentURI;
        let spec = uri ? uri.spec : "about:blank";
        let title = data.label;
        unwrapped = { uri: spec,
                      title: data.label,
                      type: PlacesUtils.TYPE_X_MOZ_URL};
      }
      else
        throw("bogus data was passed as a tab")
      let index = insertionPoint.index;
      let dragginUp = insertionPoint.itemId == unwrapped.parent &&
                      index < PlacesUtils.bookmarks.getItemIndex(unwrapped.id);
      if (index != -1 && dragginUp)
        index+= movedCount++;
      if (insertionPoint.isTag &&
          insertionPoint.orientation == Ci.nsITreeView.DROP_ON) {
        let uri = NetUtil.newURI(unwrapped.uri);
        let tagItemId = insertionPoint.itemId;
        let tagTxn = new PlacesTagURITransaction(uri, [tagItemId]);
        transactions.push(tagTxn);
      }
      else {
        transactions.push(PlacesUIUtils.makeTransaction(unwrapped,
                          flavor, insertionPoint.itemId,
                          index, doCopy));
      }
    }
    let txn = new PlacesAggregatedTransaction("DropItems", transactions);
    PlacesUtils.transactionManager.doTransaction(txn);
  }
function PCDH_onDrop ( insertionPoint , dt ) { let doCopy = [ "copy" , "link" ] . indexOf ( dt . dropEffect ) != - 1 ; let transactions = [ ] ; let dropCount = dt . mozItemCount ; let movedCount = 0 ; for ( let i = 0 ; i < dropCount ; ++ i ) { let flavor = this . getFirstValidFlavor ( dt . mozTypesAt ( i ) ) ; if ( ! flavor ) return ; let data = dt . mozGetDataAt ( flavor , i ) ; let unwrapped ; if ( flavor != TAB_DROP_TYPE ) { unwrapped = PlacesUtils . unwrapNodes ( data , flavor ) [ 0 ] ; } else if ( data instanceof XULElement && data . localName == "tab" && data . ownerDocument . defaultView instanceof ChromeWindow ) { let uri = data . linkedBrowser . currentURI ; let spec = uri ? uri . spec : "about:blank" ; let title = data . label ; unwrapped = { uri : spec , title : data . label , type : PlacesUtils . TYPE_X_MOZ_URL } ; } else throw ( "bogus data was passed as a tab" ) let index = insertionPoint . index ; let dragginUp = insertionPoint . itemId == unwrapped . parent && index < PlacesUtils . bookmarks . getItemIndex ( unwrapped . id ) ; if ( index != - 1 && dragginUp ) index += movedCount ++ ; if ( insertionPoint . isTag && insertionPoint . orientation == Ci . nsITreeView . DROP_ON ) { let uri = NetUtil . newURI ( unwrapped . uri ) ; let tagItemId = insertionPoint . itemId ; let tagTxn = new PlacesTagURITransaction ( uri , [ tagItemId ] ) ; transactions . push ( tagTxn ) ; } else { transactions . push ( PlacesUIUtils . makeTransaction ( unwrapped , flavor , insertionPoint . itemId , index , doCopy ) ) ; } } let txn = new PlacesAggregatedTransaction ( "DropItems" , transactions ) ; PlacesUtils . transactionManager . doTransaction ( txn ) ; }
Handles the drop of one or more items onto a view.
Handles the drop of one or more items onto a view .
// There's only ever one in the D&D case. // Adjust insertion index to prevent reversal of dragged items. When you // drag multiple elts upward: need to increment index or each successive // elt will be inserted at the same index, each above the previous. // If dragging over a tag container we should tag the item.