B2G/gecko/browser/components/places/content/controller.js
/**
   * Creates a set of transactions for the removal of a range of items.
   * A range is an array of adjacent nodes in a view.
   * @param   [in] range
   *          An array of nodes to remove. Should all be adjacent.
   * @param   [out] transactions
   *          An array of transactions.
   * @param   [optional] removedFolders
   *          An array of folder nodes that have already been removed.
   */
Creates a set of transactions for the removal of a range of items.
A range is an array of adjacent nodes in a view.
@param   [in] range
An array of nodes to remove. Should all be adjacent.
@param   [out] transactions
An array of transactions.
@param   [optional] removedFolders
An array of folder nodes that have already been removed.
Creates a set of transactions for the removal of a range of items . A range is an array of adjacent nodes in a view . @param [ in ] range An array of nodes to remove . Should all be adjacent . @param [ out ] transactions An array of transactions . @param [ optional ] removedFolders An array of folder nodes that have already been removed .
function PC__removeRange(range, transactions, removedFolders) {
    NS_ASSERT(transactions instanceof Array, "Must pass a transactions array");
    if (!removedFolders)
      removedFolders = [];
    for (var i = 0; i < range.length; ++i) {
      var node = range[i];
      if (this._shouldSkipNode(node, removedFolders))
        continue;
      if (PlacesUtils.nodeIsTagQuery(node.parent)) {
        var tagItemId = PlacesUtils.getConcreteItemId(node.parent);
        var uri = NetUtil.newURI(node.uri);
        let txn = new PlacesUntagURITransaction(uri, [tagItemId]);
        transactions.push(txn);
      }
      else if (PlacesUtils.nodeIsTagQuery(node) && node.parent &&
               PlacesUtils.nodeIsQuery(node.parent) &&
               PlacesUtils.asQuery(node.parent).queryOptions.resultType ==
                 Ci.nsINavHistoryQueryOptions.RESULTS_AS_TAG_QUERY) {
        var tag = node.title;
        var URIs = PlacesUtils.tagging.getURIsForTag(tag);
        for (var j = 0; j < URIs.length; j++) {
          let txn = new PlacesUntagURITransaction(URIs[j], [tag]);
          transactions.push(txn);
        }
      }
      else if (PlacesUtils.nodeIsURI(node) &&
               PlacesUtils.nodeIsQuery(node.parent) &&
               PlacesUtils.asQuery(node.parent).queryOptions.queryType ==
                 Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
        PlacesUtils.bhistory.removePage(NetUtil.newURI(node.uri));
      }
      else if (node.itemId == -1 &&
               PlacesUtils.nodeIsQuery(node) &&
               PlacesUtils.asQuery(node).queryOptions.queryType ==
                 Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
        this._removeHistoryContainer(node);
      }
      else {
        if (PlacesUtils.nodeIsFolder(node)) {
          removedFolders.push(node);
        }
        let txn = new PlacesRemoveItemTransaction(node.itemId);
        transactions.push(txn);
      }
    }
  }
function PC__removeRange ( range , transactions , removedFolders ) { NS_ASSERT ( transactions instanceof Array , "Must pass a transactions array" ) ; if ( ! removedFolders ) removedFolders = [ ] ; for ( var i = 0 ; i < range . length ; ++ i ) { var node = range [ i ] ; if ( this . _shouldSkipNode ( node , removedFolders ) ) continue ; if ( PlacesUtils . nodeIsTagQuery ( node . parent ) ) { var tagItemId = PlacesUtils . getConcreteItemId ( node . parent ) ; var uri = NetUtil . newURI ( node . uri ) ; let txn = new PlacesUntagURITransaction ( uri , [ tagItemId ] ) ; transactions . push ( txn ) ; } else if ( PlacesUtils . nodeIsTagQuery ( node ) && node . parent && PlacesUtils . nodeIsQuery ( node . parent ) && PlacesUtils . asQuery ( node . parent ) . queryOptions . resultType == Ci . nsINavHistoryQueryOptions . RESULTS_AS_TAG_QUERY ) { var tag = node . title ; var URIs = PlacesUtils . tagging . getURIsForTag ( tag ) ; for ( var j = 0 ; j < URIs . length ; j ++ ) { let txn = new PlacesUntagURITransaction ( URIs [ j ] , [ tag ] ) ; transactions . push ( txn ) ; } } else if ( PlacesUtils . nodeIsURI ( node ) && PlacesUtils . nodeIsQuery ( node . parent ) && PlacesUtils . asQuery ( node . parent ) . queryOptions . queryType == Ci . nsINavHistoryQueryOptions . QUERY_TYPE_HISTORY ) { PlacesUtils . bhistory . removePage ( NetUtil . newURI ( node . uri ) ) ; } else if ( node . itemId == - 1 && PlacesUtils . nodeIsQuery ( node ) && PlacesUtils . asQuery ( node ) . queryOptions . queryType == Ci . nsINavHistoryQueryOptions . QUERY_TYPE_HISTORY ) { this . _removeHistoryContainer ( node ) ; } else { if ( PlacesUtils . nodeIsFolder ( node ) ) { removedFolders . push ( node ) ; } let txn = new PlacesRemoveItemTransaction ( node . itemId ) ; transactions . push ( txn ) ; } } }
Creates a set of transactions for the removal of a range of items.
Creates a set of transactions for the removal of a range of items .
// This is a uri node inside a tag container.  It needs a special // untag transaction. // This is a tag container. // Untag all URIs tagged with this tag only if the tag container is // child of the "Tags" query in the library, in all other places we // must only remove the query node. // This is a uri node inside an history query. // History deletes are not undoable, so we don't have a transaction. // This is a dynamically generated history query, like queries // grouped by site, time or both.  Dynamically generated queries don't // have an itemId even if they are descendants of a bookmark. // History deletes are not undoable, so we don't have a transaction. // This is a common bookmark item. // If this is a folder we add it to our array of folders, used // to skip nodes that are children of an already removed folder.