B2G/gecko/browser/components/places/content/controller.js
/**
   * Determines if a context-menu item should be shown
   * @param   aMenuItem
   *          the context menu item
   * @param   aMetaData
   *          meta data about the selection
   * @returns true if the conditions (see buildContextMenu) are satisfied
   *          and the item can be displayed, false otherwise.
   */
Determines if a context-menu item should be shown
@param   aMenuItem
the context menu item
@param   aMetaData
meta data about the selection
@returns true if the conditions  are satisfied
and the item can be displayed, false otherwise.
Determines if a context - menu item should be shown @param aMenuItem the context menu item @param aMetaData meta data about the selection @returns true if the conditions are satisfied and the item can be displayed false otherwise .
function PC__shouldShowMenuItem(aMenuItem, aMetaData) {
    var selectiontype = aMenuItem.getAttribute("selectiontype");
    if (selectiontype == "multiple" && aMetaData.length == 1)
      return false;
    if (selectiontype == "single" && aMetaData.length != 1)
      return false;
    var forceHideAttr = aMenuItem.getAttribute("forcehideselection");
    if (forceHideAttr) {
      var forceHideRules = forceHideAttr.split("|");
      for (let i = 0; i < aMetaData.length; ++i) {
        for (let j = 0; j < forceHideRules.length; ++j) {
          if (forceHideRules[j] in aMetaData[i])
            return false;
        }
      }
    }
    var selectionAttr = aMenuItem.getAttribute("selection");
    if (selectionAttr) {
      if (selectionAttr == "any")
        return true;
      var showRules = selectionAttr.split("|");
      var anyMatched = false;
      function metaDataNodeMatches(metaDataNode, rules) {
        for (var i=0; i < rules.length; i++) {
          if (rules[i] in metaDataNode)
            return true;
        }
        return false;
      }
      for (var i = 0; i < aMetaData.length; ++i) {
        if (metaDataNodeMatches(aMetaData[i], showRules))
          anyMatched = true;
        else
          return false;
      }
      return anyMatched;
    }
    return !aMenuItem.hidden;
  }
function PC__shouldShowMenuItem ( aMenuItem , aMetaData ) { var selectiontype = aMenuItem . getAttribute ( "selectiontype" ) ; if ( selectiontype == "multiple" && aMetaData . length == 1 ) return false ; if ( selectiontype == "single" && aMetaData . length != 1 ) return false ; var forceHideAttr = aMenuItem . getAttribute ( "forcehideselection" ) ; if ( forceHideAttr ) { var forceHideRules = forceHideAttr . split ( "|" ) ; for ( let i = 0 ; i < aMetaData . length ; ++ i ) { for ( let j = 0 ; j < forceHideRules . length ; ++ j ) { if ( forceHideRules [ j ] in aMetaData [ i ] ) return false ; } } } var selectionAttr = aMenuItem . getAttribute ( "selection" ) ; if ( selectionAttr ) { if ( selectionAttr == "any" ) return true ; var showRules = selectionAttr . split ( "|" ) ; var anyMatched = false ; function metaDataNodeMatches ( metaDataNode , rules ) { for ( var i = 0 ; i < rules . length ; i ++ ) { if ( rules [ i ] in metaDataNode ) return true ; } return false ; } for ( var i = 0 ; i < aMetaData . length ; ++ i ) { if ( metaDataNodeMatches ( aMetaData [ i ] , showRules ) ) anyMatched = true ; else return false ; } return anyMatched ; } return ! aMenuItem . hidden ; }
Determines if a context-menu item should be shown
 @param   aMenuItem
          the context menu item
 @param   aMetaData
          meta data about the selection
 @returns true if the conditions (see buildContextMenu) are satisfied
          and the item can be displayed, false otherwise.
Determines if a context - menu item should be shown @param aMenuItem the context menu item @param aMetaData meta data about the selection @returns true if the conditions ( see buildContextMenu ) are satisfied and the item can be displayed false otherwise .