B2G/gecko/browser/components/places/content/controller.js
/**
   * Gathers information about the selected nodes according to the following
   * rules:
   *    "link"              node is a URI
   *    "bookmark"          node is a bookamrk
   *    "livemarkChild"     node is a child of a livemark
   *    "tagChild"          node is a child of a tag
   *    "folder"            node is a folder
   *    "query"             node is a query
   *    "separator"         node is a separator line
   *    "host"              node is a host
   *
   * @returns an array of objects corresponding the selected nodes. Each
   *          object has each of the properties above set if its corresponding
   *          node matches the rule. In addition, the annotations names for each
   *          node are set on its corresponding object as properties.
   * Notes:
   *   1) This can be slow, so don't call it anywhere performance critical!
   *   2) A single-object array corresponding the root node is returned if
   *      there's no selection.
   */


@returns an array of objects corresponding the selected nodes. Each
object has each of the properties above set if its corresponding
node matches the rule. In addition, the annotations names for each
node are set on its corresponding object as properties.
Notes:
1) This can be slow, so don't call it anywhere performance critical.
2) A single-object array corresponding the root node is returned if
there's no selection.
@returns an array of objects corresponding the selected nodes . Each object has each of the properties above set if its corresponding node matches the rule . In addition the annotations names for each node are set on its corresponding object as properties . Notes : 1 ) This can be slow so don ' t call it anywhere performance critical . 2 ) A single - object array corresponding the root node is returned if there ' s no selection .
function PC__buildSelectionMetadata() {
    var metadata = [];
    var root = this._view.result.root;
    var nodes = this._view.selectedNodes;
    if (nodes.length == 0)
      nodes.push(root); 
    for (var i = 0; i < nodes.length; i++) {
      var nodeData = {};
      var node = nodes[i];
      var nodeType = node.type;
      var uri = null;
      switch (nodeType) {
        case Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY:
          nodeData["query"] = true;
          if (node.parent) {
            switch (PlacesUtils.asQuery(node.parent).queryOptions.resultType) {
              case Ci.nsINavHistoryQueryOptions.RESULTS_AS_SITE_QUERY:
                nodeData["host"] = true;
                break;
              case Ci.nsINavHistoryQueryOptions.RESULTS_AS_DATE_SITE_QUERY:
              case Ci.nsINavHistoryQueryOptions.RESULTS_AS_DATE_QUERY:
                nodeData["day"] = true;
                break;
            }
          }
          break;
        case Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER:
        case Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT:
          nodeData["folder"] = true;
          break;
        case Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR:
          nodeData["separator"] = true;
          break;
        case Ci.nsINavHistoryResultNode.RESULT_TYPE_URI:
        case Ci.nsINavHistoryResultNode.RESULT_TYPE_VISIT:
        case Ci.nsINavHistoryResultNode.RESULT_TYPE_FULL_VISIT:
          nodeData["link"] = true;
          uri = NetUtil.newURI(node.uri);
          if (PlacesUtils.nodeIsBookmark(node)) {
            nodeData["bookmark"] = true;
            PlacesUtils.nodeIsTagQuery(node.parent)
            var parentNode = node.parent;
            if (parentNode) {
              if (PlacesUtils.nodeIsTagQuery(parentNode))
                nodeData["tagChild"] = true;
              else if (this.hasCachedLivemarkInfo(parentNode))
                nodeData["livemarkChild"] = true;
            }
          }
          break;
      }
      if (uri) {
        let names = PlacesUtils.annotations.getPageAnnotationNames(uri);
        for (let j = 0; j < names.length; ++j)
          nodeData[names[j]] = true;
      }
      if (node.itemId != -1) {
        let names = PlacesUtils.annotations
                               .getItemAnnotationNames(node.itemId);
        for (let j = 0; j < names.length; ++j)
          nodeData[names[j]] = true;
      }
      metadata.push(nodeData);
    }
    return metadata;
  }
function PC__buildSelectionMetadata ( ) { var metadata = [ ] ; var root = this . _view . result . root ; var nodes = this . _view . selectedNodes ; if ( nodes . length == 0 ) nodes . push ( root ) ; for ( var i = 0 ; i < nodes . length ; i ++ ) { var nodeData = { } ; var node = nodes [ i ] ; var nodeType = node . type ; var uri = null ; switch ( nodeType ) { case Ci . nsINavHistoryResultNode . RESULT_TYPE_QUERY : nodeData [ "query" ] = true ; if ( node . parent ) { switch ( PlacesUtils . asQuery ( node . parent ) . queryOptions . resultType ) { case Ci . nsINavHistoryQueryOptions . RESULTS_AS_SITE_QUERY : nodeData [ "host" ] = true ; break ; case Ci . nsINavHistoryQueryOptions . RESULTS_AS_DATE_SITE_QUERY : case Ci . nsINavHistoryQueryOptions . RESULTS_AS_DATE_QUERY : nodeData [ "day" ] = true ; break ; } } break ; case Ci . nsINavHistoryResultNode . RESULT_TYPE_FOLDER : case Ci . nsINavHistoryResultNode . RESULT_TYPE_FOLDER_SHORTCUT : nodeData [ "folder" ] = true ; break ; case Ci . nsINavHistoryResultNode . RESULT_TYPE_SEPARATOR : nodeData [ "separator" ] = true ; break ; case Ci . nsINavHistoryResultNode . RESULT_TYPE_URI : case Ci . nsINavHistoryResultNode . RESULT_TYPE_VISIT : case Ci . nsINavHistoryResultNode . RESULT_TYPE_FULL_VISIT : nodeData [ "link" ] = true ; uri = NetUtil . newURI ( node . uri ) ; if ( PlacesUtils . nodeIsBookmark ( node ) ) { nodeData [ "bookmark" ] = true ; PlacesUtils . nodeIsTagQuery ( node . parent ) var parentNode = node . parent ; if ( parentNode ) { if ( PlacesUtils . nodeIsTagQuery ( parentNode ) ) nodeData [ "tagChild" ] = true ; else if ( this . hasCachedLivemarkInfo ( parentNode ) ) nodeData [ "livemarkChild" ] = true ; } } break ; } if ( uri ) { let names = PlacesUtils . annotations . getPageAnnotationNames ( uri ) ; for ( let j = 0 ; j < names . length ; ++ j ) nodeData [ names [ j ] ] = true ; } if ( node . itemId != - 1 ) { let names = PlacesUtils . annotations . getItemAnnotationNames ( node . itemId ) ; for ( let j = 0 ; j < names . length ; ++ j ) nodeData [ names [ j ] ] = true ; } metadata . push ( nodeData ) ; } return metadata ; }
Gathers information about the selected nodes according to the following
 rules:
    "link"              node is a URI
    "bookmark"          node is a bookamrk
    "livemarkChild"     node is a child of a livemark
    "tagChild"          node is a child of a tag
    "folder"            node is a folder
    "query"             node is a query
    "separator"         node is a separator line
    "host"              node is a host
Gathers information about the selected nodes according to the following rules : " link " node is a URI " bookmark " node is a bookamrk " livemarkChild " node is a child of a livemark " tagChild " node is a child of a tag " folder " node is a folder " query " node is a query " separator " node is a separator line " host " node is a host
// See the second note above // We don't use the nodeIs* methods here to avoid going through the type // property way too often // annotations // For items also include the item-specific annotations