B2G/gecko/browser/components/places/content/treeView.js
/**
   * THIS FUNCTION DOES NOT HANDLE cases where a collapsed node is being
   * removed but the node it is collapsed with is not being removed (this then
   * just swap out the removee with its collapsing partner). The only time
   * when we really remove things is when deleting URIs, which will apply to
   * all collapsees. This function is called sometimes when resorting items.
   * However, we won't do this when sorted by date because dates will never
   * change for visits, and date sorting is the only time things are collapsed.
   */
THIS FUNCTION DOES NOT HANDLE cases where a collapsed node is being
removed but the node it is collapsed with is not being removed (this then
just swap out the removee with its collapsing partner). The only time
when we really remove things is when deleting URIs, which will apply to
all collapsees. This function is called sometimes when resorting items.
However, we won't do this when sorted by date because dates will never
change for visits, and date sorting is the only time things are collapsed.
THIS FUNCTION DOES NOT HANDLE cases where a collapsed node is being removed but the node it is collapsed with is not being removed ( this then just swap out the removee with its collapsing partner ) . The only time when we really remove things is when deleting URIs which will apply to all collapsees . This function is called sometimes when resorting items . However we won ' t do this when sorted by date because dates will never change for visits and date sorting is the only time things are collapsed .
function PTV_nodeRemoved(aParentNode, aNode, aOldIndex) {
    NS_ASSERT(this._result, "Got a notification but have no result!");
    if (!this._tree || !this._result)
      return;
    if (aNode == this._rootNode)
      throw Cr.NS_ERROR_NOT_IMPLEMENTED;
    if (PlacesUtils.nodeIsSeparator(aNode) && this.isSorted())
      return;
    let parentRow = aParentNode == this._rootNode ?
                    undefined : this._getRowForNode(aParentNode, true);
    let oldRow = this._getRowForNode(aNode, true, parentRow, aOldIndex);
    if (oldRow < 0)
      throw Cr.NS_ERROR_UNEXPECTED;
    let selectNext = false;
    let selection = this.selection;
    if (selection.getRangeCount() == 1) {
      let min = { }, max = { };
      selection.getRangeAt(0, min, max);
      if (min.value == max.value &&
          this.nodeForTreeIndex(min.value) == aNode)
        selectNext = true;
    }
    let count = this._countVisibleRowsForNodeAtRow(oldRow);
    this._rows.splice(oldRow, count);
    this._tree.rowCountChanged(oldRow, -count);
    if (aParentNode != this._rootNode && !aParentNode.hasChildren) {
      let parentRow = oldRow - 1;
      this._tree.invalidateRow(parentRow);
    }
    if (!selectNext)
      return;
    let rowToSelect = Math.min(oldRow, this._rows.length - 1);
    this.selection.rangedSelect(rowToSelect, rowToSelect, true);
  }
function PTV_nodeRemoved ( aParentNode , aNode , aOldIndex ) { NS_ASSERT ( this . _result , "Got a notification but have no result!" ) ; if ( ! this . _tree || ! this . _result ) return ; if ( aNode == this . _rootNode ) throw Cr . NS_ERROR_NOT_IMPLEMENTED ; if ( PlacesUtils . nodeIsSeparator ( aNode ) && this . isSorted ( ) ) return ; let parentRow = aParentNode == this . _rootNode ? undefined : this . _getRowForNode ( aParentNode , true ) ; let oldRow = this . _getRowForNode ( aNode , true , parentRow , aOldIndex ) ; if ( oldRow < 0 ) throw Cr . NS_ERROR_UNEXPECTED ; let selectNext = false ; let selection = this . selection ; if ( selection . getRangeCount ( ) == 1 ) { let min = { } , max = { } ; selection . getRangeAt ( 0 , min , max ) ; if ( min . value == max . value && this . nodeForTreeIndex ( min . value ) == aNode ) selectNext = true ; } let count = this . _countVisibleRowsForNodeAtRow ( oldRow ) ; this . _rows . splice ( oldRow , count ) ; this . _tree . rowCountChanged ( oldRow , - count ) ; if ( aParentNode != this . _rootNode && ! aParentNode . hasChildren ) { let parentRow = oldRow - 1 ; this . _tree . invalidateRow ( parentRow ) ; } if ( ! selectNext ) return ; let rowToSelect = Math . min ( oldRow , this . _rows . length - 1 ) ; this . selection . rangedSelect ( rowToSelect , rowToSelect , true ) ; }
THIS FUNCTION DOES NOT HANDLE cases where a collapsed node is being
 removed but the node it is collapsed with is not being removed (this then
 just swap out the removee with its collapsing partner).
THIS FUNCTION DOES NOT HANDLE cases where a collapsed node is being removed but the node it is collapsed with is not being removed ( this then just swap out the removee with its collapsing partner ) .
// XXX bug 517701: We don't know what to do when the root node is removed. // Bail out for hidden separators. // If the node was exclusively selected, the node next to it will be // selected. // Remove the node and its children, if any. // Redraw the parent if its twisty state has changed. // Restore selection if the node was exclusively selected. // Restore selection.