B2G/gecko/browser/devtools/styleinspector/CssLogic.jsm
/**
 * Information about a single CSSStyleRule.
 *
 * @param {CSSSheet|null} aCssSheet the CssSheet object of the stylesheet that
 * holds the CSSStyleRule. If the rule comes from element.style, set this
 * argument to null.
 * @param {CSSStyleRule|object} aDomRule the DOM CSSStyleRule for which you want
 * to cache data. If the rule comes from element.style, then provide
 * an object of the form: {style: element.style}.
 * @param {Element} [aElement] If the rule comes from element.style, then this
 * argument must point to the element.
 * @constructor
 */
Information about a single CSSStyleRule.
Information about a single CSSStyleRule .
function CssRule(aCssSheet, aDomRule, aElement)
{
  this._cssSheet = aCssSheet;
  this._domRule = aDomRule;
  let parentRule = aDomRule.parentRule;
  if (parentRule && parentRule.type == Ci.nsIDOMCSSRule.MEDIA_RULE) {
    this.mediaText = parentRule.media.mediaText;
  }
  if (this._cssSheet) {
    this._selectors = null;
    this.line = this._cssSheet._cssLogic.domUtils.getRuleLine(this._domRule);
    this.source = this._cssSheet.shortSource + ":" + this.line;
    if (this.mediaText) {
      this.source += " @media " + this.mediaText;
    }
    this.href = this._cssSheet.href;
    this.contentRule = this._cssSheet.contentSheet;
  } else if (aElement) {
    this._selectors = [ new CssSelector(this, "@element.style") ];
    this.line = -1;
    this.source = CssLogic.l10n("rule.sourceElement");
    this.href = "#";
    this.contentRule = true;
    this.sourceElement = aElement;
  }
}
function CssRule ( aCssSheet , aDomRule , aElement ) { this . _cssSheet = aCssSheet ; this . _domRule = aDomRule ; let parentRule = aDomRule . parentRule ; if ( parentRule && parentRule . type == Ci . nsIDOMCSSRule . MEDIA_RULE ) { this . mediaText = parentRule . media . mediaText ; } if ( this . _cssSheet ) { this . _selectors = null ; this . line = this . _cssSheet . _cssLogic . domUtils . getRuleLine ( this . _domRule ) ; this . source = this . _cssSheet . shortSource + ":" + this . line ; if ( this . mediaText ) { this . source += " @media " + this . mediaText ; } this . href = this . _cssSheet . href ; this . contentRule = this . _cssSheet . contentSheet ; } else if ( aElement ) { this . _selectors = [ new CssSelector ( this , "@element.style" ) ] ; this . line = - 1 ; this . source = CssLogic . l10n ( "rule.sourceElement" ) ; this . href = "#" ; this . contentRule = true ; this . sourceElement = aElement ; } }
Information about a single CSSStyleRule.
Information about a single CSSStyleRule .
// parse _domRule.selectorText on call to this.selectors