B2G/gecko/browser/components/places/content/treeView.js
/**
   * This takes a container and recursively appends our rows array per its
   * contents.  Assumes that the rows arrays has no rows for the given
   * container.
   *
   * @param [in] aContainer
   *        A container result node.
   * @param [in] aFirstChildRow
   *        The first row at which nodes may be inserted to the row array.
   *        In other words, that's aContainer's row + 1.
   * @param [out] aToOpen
   *        An array of containers to open once the build is done.
   *
   * @return the number of rows which were inserted.
   */
This takes a container and recursively appends our rows array per its
contents.  Assumes that the rows arrays has no rows for the given
container.

@param [in] aContainer
A container result node.
@param [in] aFirstChildRow
The first row at which nodes may be inserted to the row array.
In other words, that's aContainer's row + 1.
@param [out] aToOpen
An array of containers to open once the build is done.

@return the number of rows which were inserted.
This takes a container and recursively appends our rows array per its contents . Assumes that the rows arrays has no rows for the given container . @param [ in ] aContainer A container result node . @param [ in ] aFirstChildRow The first row at which nodes may be inserted to the row array . In other words that ' s aContainer ' s row + 1 . @param [ out ] aToOpen An array of containers to open once the build is done . @return the number of rows which were inserted .
function PTV__buildVisibleSection(aContainer, aFirstChildRow, aToOpen)
  {
    if (!aContainer.containerOpen)
      return 0;
    let cc = aContainer.childCount;
    let newElements = new Array(cc);
    this._rows = this._rows.splice(0, aFirstChildRow)
                     .concat(newElements, this._rows);
    if (this._isPlainContainer(aContainer))
      return cc;
    const openLiteral = PlacesUIUtils.RDF.GetResource("http://home.netscape.com/NC-rdf#open");
    const trueLiteral = PlacesUIUtils.RDF.GetLiteral("true");
    let sortingMode = this._result.sortingMode;
    let rowsInserted = 0;
    for (let i = 0; i < cc; i++) {
      let curChild = aContainer.getChild(i);
      let curChildType = curChild.type;
      let row = aFirstChildRow + rowsInserted;
      if (curChildType == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR) {
        if (sortingMode != Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) {
          this._rows.splice(row, 1);
          continue;
        }
      }
      this._rows[row] = curChild;
      rowsInserted++;
      if (!this._flatList &&
          curChild instanceof Ci.nsINavHistoryContainerResultNode &&
          !this._controller.hasCachedLivemarkInfo(curChild)) {
        let resource = this._getResourceForNode(curChild);
        let isopen = resource != null &&
                     PlacesUIUtils.localStore.HasAssertion(resource,
                                                           openLiteral,
                                                           trueLiteral, true);
        if (isopen != curChild.containerOpen)
          aToOpen.push(curChild);
        else if (curChild.containerOpen && curChild.childCount > 0)
          rowsInserted += this._buildVisibleSection(curChild, row + 1, aToOpen);
      }
    }
    return rowsInserted;
  }
function PTV__buildVisibleSection ( aContainer , aFirstChildRow , aToOpen ) { if ( ! aContainer . containerOpen ) return 0 ; let cc = aContainer . childCount ; let newElements = new Array ( cc ) ; this . _rows = this . _rows . splice ( 0 , aFirstChildRow ) . concat ( newElements , this . _rows ) ; if ( this . _isPlainContainer ( aContainer ) ) return cc ; const openLiteral = PlacesUIUtils . RDF . GetResource ( "http://home.netscape.com/NC-rdf#open" ) ; const trueLiteral = PlacesUIUtils . RDF . GetLiteral ( "true" ) ; let sortingMode = this . _result . sortingMode ; let rowsInserted = 0 ; for ( let i = 0 ; i < cc ; i ++ ) { let curChild = aContainer . getChild ( i ) ; let curChildType = curChild . type ; let row = aFirstChildRow + rowsInserted ; if ( curChildType == Ci . nsINavHistoryResultNode . RESULT_TYPE_SEPARATOR ) { if ( sortingMode != Ci . nsINavHistoryQueryOptions . SORT_BY_NONE ) { this . _rows . splice ( row , 1 ) ; continue ; } } this . _rows [ row ] = curChild ; rowsInserted ++ ; if ( ! this . _flatList && curChild instanceof Ci . nsINavHistoryContainerResultNode && ! this . _controller . hasCachedLivemarkInfo ( curChild ) ) { let resource = this . _getResourceForNode ( curChild ) ; let isopen = resource != null && PlacesUIUtils . localStore . HasAssertion ( resource , openLiteral , trueLiteral , true ) ; if ( isopen != curChild . containerOpen ) aToOpen . push ( curChild ) ; else if ( curChild . containerOpen && curChild . childCount > 0 ) rowsInserted += this . _buildVisibleSection ( curChild , row + 1 , aToOpen ) ; } } return rowsInserted ; }
This takes a container and recursively appends our rows array per its
 contents.
This takes a container and recursively appends our rows array per its contents .
// There's nothing to do if the container is closed. // Inserting the new elements into the rows array in one shot (by // Array.concat) is faster than resizing the array (by splice) on each loop // iteration. // Don't display separators when sorted. // Remove the element for the filtered separator. // Notice that the rows array was initially resized to include all // children. // Recursively do containers.