B2G/gecko/browser/components/places/content/treeView.js
/**
   * Restores a given selection state as near as possible to the original
   * selection state.
   *
   * @param aNodesInfo
   *        The persisted selection state as returned by
   *        _getSelectedNodesInRange.
   * @param aUpdatedContainer
   *        The container which was updated.
   */
Restores a given selection state as near as possible to the original
selection state.

@param aNodesInfo
The persisted selection state as returned by
_getSelectedNodesInRange.
@param aUpdatedContainer
The container which was updated.
Restores a given selection state as near as possible to the original selection state . @param aNodesInfo The persisted selection state as returned by _getSelectedNodesInRange . @param aUpdatedContainer The container which was updated .
function PTV__restoreSelection(aNodesInfo, aUpdatedContainer) {
    if (aNodesInfo.length == 0)
      return;
    let selection = this.selection;
    let scrollToRow = -1;
    for (let i = 0; i < aNodesInfo.length; i++) {
      let nodeInfo = aNodesInfo[i];
      let row = this._getNewRowForRemovedNode(aUpdatedContainer,
                                              aNodesInfo[i].node);
      if (row != -1) {
        selection.rangedSelect(row, row, true);
        if (nodeInfo.wasVisible && scrollToRow == -1)
          scrollToRow = row;
      }
    }
    if (aNodesInfo.length == 1 && selection.count == 0) {
      let row = Math.min(aNodesInfo[0].oldRow, this._rows.length - 1);
      selection.rangedSelect(row, row, true);
      if (aNodesInfo[0].wasVisible && scrollToRow == -1)
        scrollToRow = aNodesInfo[0].oldRow;
    }
    if (scrollToRow != -1)
      this._tree.ensureRowIsVisible(scrollToRow);
  }
function PTV__restoreSelection ( aNodesInfo , aUpdatedContainer ) { if ( aNodesInfo . length == 0 ) return ; let selection = this . selection ; let scrollToRow = - 1 ; for ( let i = 0 ; i < aNodesInfo . length ; i ++ ) { let nodeInfo = aNodesInfo [ i ] ; let row = this . _getNewRowForRemovedNode ( aUpdatedContainer , aNodesInfo [ i ] . node ) ; if ( row != - 1 ) { selection . rangedSelect ( row , row , true ) ; if ( nodeInfo . wasVisible && scrollToRow == - 1 ) scrollToRow = row ; } } if ( aNodesInfo . length == 1 && selection . count == 0 ) { let row = Math . min ( aNodesInfo [ 0 ] . oldRow , this . _rows . length - 1 ) ; selection . rangedSelect ( row , row , true ) ; if ( aNodesInfo [ 0 ] . wasVisible && scrollToRow == - 1 ) scrollToRow = aNodesInfo [ 0 ] . oldRow ; } if ( scrollToRow != - 1 ) this . _tree . ensureRowIsVisible ( scrollToRow ) ; }
Restores a given selection state as near as possible to the original
 selection state.
Restores a given selection state as near as possible to the original selection state .
// Attempt to ensure that previously-visible selection will be visible // if it's re-selected.  However, we can only ensure that for one row. // Select the found node, if any. // If only one node was previously selected and there's no selection now, // select the node at its old row, if any.