addRule method

void addRule(
  1. CSSRule rule, {
  2. required String? baseHref,
})

Implementation

void addRule(CSSRule rule, { required String? baseHref }) {
  rule.position = _lastPosition++;
  if (rule is CSSStyleRule) {
    for (final selector in rule.selectorGroup.selectors) {
      findBestRuleSetAndAdd(selector, rule);
    }
  } else if (rule is CSSKeyframesRule) {
    keyframesRules[rule.name] = rule;
  } else if (rule is CSSFontFaceRule) {
    CSSFontFace.resolveFontFaceRules(rule, ownerDocument.contextId!, baseHref);
  } else {
    assert(false, 'Unsupported rule type: ${rule.runtimeType}');
  }
}