cssRuleStructuralHash function

int cssRuleStructuralHash(
  1. CSSRule rule
)

Implementation

int cssRuleStructuralHash(CSSRule rule) {
  if (rule is CSSStyleRule) {
    return Object.hash(
      rule.type,
      rule.selectorGroup.structuralHashCode,
      Object.hashAll(rule.layerPath),
      rule.declaration.structuralHashCode,
    );
  }

  if (rule is CSSLayerStatementRule) {
    return Object.hash(
      rule.type,
      Object.hashAll(rule.layerNamePaths.map((path) => Object.hashAll(path))),
    );
  }

  if (rule is CSSLayerBlockRule) {
    return Object.hash(
      rule.type,
      rule.name,
      Object.hashAll(rule.layerNamePath),
      cssRuleListStructuralHash(rule.cssRules),
    );
  }

  if (rule is CSSImportRule) {
    return Object.hash(rule.type, rule.href, rule.media);
  }

  if (rule is CSSKeyframesRule) {
    return Object.hash(
      rule.type,
      rule.name,
      Object.hashAll(rule.keyframes.map((keyframe) => Object.hash(
            keyframe.property,
            keyframe.value,
            keyframe.offset,
            keyframe.easing,
          ))),
    );
  }

  if (rule is CSSFontFaceRule) {
    return Object.hash(rule.type, rule.declarations.structuralHashCode);
  }

  if (rule is CSSMediaDirective) {
    return Object.hash(
      rule.type,
      _mediaQueryStructuralHash(rule.cssMediaQuery),
      cssRuleListStructuralHash(rule.rules ?? const <CSSRule>[]),
    );
  }

  return Object.hash(rule.type, rule.cssText);
}