B2G/gecko/browser/devtools/styleinspector/CssLogic.jsm
/**
   * Retrieve a CssSheet object for a given a CSSStyleSheet object. If the
   * stylesheet is already cached, you get the existing CssSheet object,
   * otherwise the new CSSStyleSheet object is cached.
   *
   * @param {CSSStyleSheet} aDomSheet the CSSStyleSheet object you want.
   * @param {number} aIndex the index, within the document, of the stylesheet.
   *
   * @return {CssSheet} the CssSheet object for the given CSSStyleSheet object.
   */
Retrieve a CssSheet object for a given a CSSStyleSheet object. If the
stylesheet is already cached, you get the existing CssSheet object,
otherwise the new CSSStyleSheet object is cached.



@return {CssSheet} the CssSheet object for the given CSSStyleSheet object.
Retrieve a CssSheet object for a given a CSSStyleSheet object . If the stylesheet is already cached you get the existing CssSheet object otherwise the new CSSStyleSheet object is cached . @return { CssSheet } the CssSheet object for the given CSSStyleSheet object .
function CL_getSheet(aDomSheet, aIndex)
  {
    let cacheId = "";
    if (aDomSheet.href) {
      cacheId = aDomSheet.href;
    } else if (aDomSheet.ownerNode && aDomSheet.ownerNode.ownerDocument) {
      cacheId = aDomSheet.ownerNode.ownerDocument.location;
    }
    let sheet = null;
    let sheetFound = false;
    if (cacheId in this._sheets) {
      for (let i = 0, numSheets = this._sheets[cacheId].length; i < numSheets; i++) {
        sheet = this._sheets[cacheId][i];
        if (sheet.domSheet === aDomSheet) {
          if (aIndex != -1) {
            sheet.index = aIndex;
          }
          sheetFound = true;
          break;
        }
      }
    }
    if (!sheetFound) {
      if (!(cacheId in this._sheets)) {
        this._sheets[cacheId] = [];
      }
      sheet = new CssSheet(this, aDomSheet, aIndex);
      if (sheet.sheetAllowed && sheet.contentSheet) {
        this._ruleCount += sheet.ruleCount;
      }
      this._sheets[cacheId].push(sheet);
    }
    return sheet;
  }
function CL_getSheet ( aDomSheet , aIndex ) { let cacheId = "" ; if ( aDomSheet . href ) { cacheId = aDomSheet . href ; } else if ( aDomSheet . ownerNode && aDomSheet . ownerNode . ownerDocument ) { cacheId = aDomSheet . ownerNode . ownerDocument . location ; } let sheet = null ; let sheetFound = false ; if ( cacheId in this . _sheets ) { for ( let i = 0 , numSheets = this . _sheets [ cacheId ] . length ; i < numSheets ; i ++ ) { sheet = this . _sheets [ cacheId ] [ i ] ; if ( sheet . domSheet === aDomSheet ) { if ( aIndex != - 1 ) { sheet . index = aIndex ; } sheetFound = true ; break ; } } } if ( ! sheetFound ) { if ( ! ( cacheId in this . _sheets ) ) { this . _sheets [ cacheId ] = [ ] ; } sheet = new CssSheet ( this , aDomSheet , aIndex ) ; if ( sheet . sheetAllowed && sheet . contentSheet ) { this . _ruleCount += sheet . ruleCount ; } this . _sheets [ cacheId ] . push ( sheet ) ; } return sheet ; }
Retrieve a CssSheet object for a given a CSSStyleSheet object.
Retrieve a CssSheet object for a given a CSSStyleSheet object .