B2G/gecko/browser/components/places/content/browserPlacesViews.js
/**
   * This function returns information about where to drop when dragging over
   * the toolbar.  The returned object has the following properties:
   * - ip: the insertion point for the bookmarks service.
   * - beforeIndex: child index to drop before, for the drop indicator.
   * - folderElt: the folder to drop into, if applicable.
   */
This function returns information about where to drop when dragging over
the toolbar.  The returned object has the following properties:
- ip: the insertion point for the bookmarks service.
- beforeIndex: child index to drop before, for the drop indicator.
- folderElt: the folder to drop into, if applicable.
This function returns information about where to drop when dragging over the toolbar . The returned object has the following properties : - ip : the insertion point for the bookmarks service . - beforeIndex : child index to drop before for the drop indicator . - folderElt : the folder to drop into if applicable .
function PT__getDropPoint(aEvent) {
    let result = this.result;
    if (!PlacesUtils.nodeIsFolder(this._resultNode))
      return null;
    let dropPoint = { ip: null, beforeIndex: null, folderElt: null };
    let elt = aEvent.target;
    if (elt._placesNode && elt != this._rootElt &&
        elt.localName != "menupopup") {
      let eltRect = elt.getBoundingClientRect();
      let eltIndex = Array.indexOf(this._rootElt.childNodes, elt);
      if (PlacesUtils.nodeIsFolder(elt._placesNode) &&
          !PlacesUtils.nodeIsReadOnly(elt._placesNode)) {
        let threshold = eltRect.width * 0.25;
        if (this.isRTL ? (aEvent.clientX > eltRect.right - threshold)
                       : (aEvent.clientX < eltRect.left + threshold)) {
          dropPoint.ip =
            new InsertionPoint(PlacesUtils.getConcreteItemId(this._resultNode),
                               eltIndex, Ci.nsITreeView.DROP_BEFORE);
          dropPoint.beforeIndex = eltIndex;
        }
        else if (this.isRTL ? (aEvent.clientX > eltRect.left + threshold)
                            : (aEvent.clientX < eltRect.right - threshold)) {
          dropPoint.ip =
            new InsertionPoint(PlacesUtils.getConcreteItemId(elt._placesNode),
                               -1, Ci.nsITreeView.DROP_ON,
                               PlacesUtils.nodeIsTagQuery(elt._placesNode));
          dropPoint.beforeIndex = eltIndex;
          dropPoint.folderElt = elt;
        }
        else {
          let beforeIndex =
            (eltIndex == this._rootElt.childNodes.length - 1) ?
            -1 : eltIndex + 1;
          dropPoint.ip =
            new InsertionPoint(PlacesUtils.getConcreteItemId(this._resultNode),
                               beforeIndex, Ci.nsITreeView.DROP_BEFORE);
          dropPoint.beforeIndex = beforeIndex;
        }
      }
      else {
        let threshold = eltRect.width * 0.5;
        if (this.isRTL ? (aEvent.clientX > eltRect.left + threshold)
                       : (aEvent.clientX < eltRect.left + threshold)) {
          dropPoint.ip =
            new InsertionPoint(PlacesUtils.getConcreteItemId(this._resultNode),
                               eltIndex, Ci.nsITreeView.DROP_BEFORE);
          dropPoint.beforeIndex = eltIndex;
        }
        else {
          let beforeIndex =
            eltIndex == this._rootElt.childNodes.length - 1 ?
            -1 : eltIndex + 1;
          dropPoint.ip =
            new InsertionPoint(PlacesUtils.getConcreteItemId(this._resultNode),
                               beforeIndex, Ci.nsITreeView.DROP_BEFORE);
          dropPoint.beforeIndex = beforeIndex;
        }
      }
    }
    else {
      dropPoint.ip =
        new InsertionPoint(PlacesUtils.getConcreteItemId(this._resultNode),
                           -1, Ci.nsITreeView.DROP_BEFORE);
      dropPoint.beforeIndex = -1;
    }
    return dropPoint;
  }
function PT__getDropPoint ( aEvent ) { let result = this . result ; if ( ! PlacesUtils . nodeIsFolder ( this . _resultNode ) ) return null ; let dropPoint = { ip : null , beforeIndex : null , folderElt : null } ; let elt = aEvent . target ; if ( elt . _placesNode && elt != this . _rootElt && elt . localName != "menupopup" ) { let eltRect = elt . getBoundingClientRect ( ) ; let eltIndex = Array . indexOf ( this . _rootElt . childNodes , elt ) ; if ( PlacesUtils . nodeIsFolder ( elt . _placesNode ) && ! PlacesUtils . nodeIsReadOnly ( elt . _placesNode ) ) { let threshold = eltRect . width * 0.25 ; if ( this . isRTL ? ( aEvent . clientX > eltRect . right - threshold ) : ( aEvent . clientX < eltRect . left + threshold ) ) { dropPoint . ip = new InsertionPoint ( PlacesUtils . getConcreteItemId ( this . _resultNode ) , eltIndex , Ci . nsITreeView . DROP_BEFORE ) ; dropPoint . beforeIndex = eltIndex ; } else if ( this . isRTL ? ( aEvent . clientX > eltRect . left + threshold ) : ( aEvent . clientX < eltRect . right - threshold ) ) { dropPoint . ip = new InsertionPoint ( PlacesUtils . getConcreteItemId ( elt . _placesNode ) , - 1 , Ci . nsITreeView . DROP_ON , PlacesUtils . nodeIsTagQuery ( elt . _placesNode ) ) ; dropPoint . beforeIndex = eltIndex ; dropPoint . folderElt = elt ; } else { let beforeIndex = ( eltIndex == this . _rootElt . childNodes . length - 1 ) ? - 1 : eltIndex + 1 ; dropPoint . ip = new InsertionPoint ( PlacesUtils . getConcreteItemId ( this . _resultNode ) , beforeIndex , Ci . nsITreeView . DROP_BEFORE ) ; dropPoint . beforeIndex = beforeIndex ; } } else { let threshold = eltRect . width * 0.5 ; if ( this . isRTL ? ( aEvent . clientX > eltRect . left + threshold ) : ( aEvent . clientX < eltRect . left + threshold ) ) { dropPoint . ip = new InsertionPoint ( PlacesUtils . getConcreteItemId ( this . _resultNode ) , eltIndex , Ci . nsITreeView . DROP_BEFORE ) ; dropPoint . beforeIndex = eltIndex ; } else { let beforeIndex = eltIndex == this . _rootElt . childNodes . length - 1 ? - 1 : eltIndex + 1 ; dropPoint . ip = new InsertionPoint ( PlacesUtils . getConcreteItemId ( this . _resultNode ) , beforeIndex , Ci . nsITreeView . DROP_BEFORE ) ; dropPoint . beforeIndex = beforeIndex ; } } } else { dropPoint . ip = new InsertionPoint ( PlacesUtils . getConcreteItemId ( this . _resultNode ) , - 1 , Ci . nsITreeView . DROP_BEFORE ) ; dropPoint . beforeIndex = - 1 ; } return dropPoint ; }
This function returns information about where to drop when dragging over
 the toolbar.
This function returns information about where to drop when dragging over the toolbar .
// This is a folder. // If we are in the middle of it, drop inside it. // Otherwise, drop before it, with regards to RTL mode. // Drop before this folder. // Drop inside this folder. // Drop after this folder. // This is a non-folder node or a read-only folder. // Drop before it with regards to RTL mode. // Drop before this bookmark. // Drop after this bookmark. // We are most likely dragging on the empty area of the // toolbar, we should drop after the last node.