Vixen
02b45cc4
csharp
public readonly record struct CascadePrecedence

Everything about a declaration that decides whether it wins, in comparable form.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The cascade is four nested tie-breaks, and writing them as four nested ifs is how a subtle one gets left out. As one comparable key it is a >, and every rule about who beats whom lives in the one place that builds it.

Read in order: origin and importance, then layer, then specificity, then source order. Specificity is third, not first — which is the thing most people who write CSS have backwards, and the reason a utility layer works.

Fields and properties (5)

  • public int OriginRank

    Origin and importance, folded into one rank.

  • public int LayerRank

    Where its layer sorts, in the direction its importance implies.

  • public Specificity Specificity

    How specific the selector that brought it here is.

  • public int Order

    Its position in source order.

  • public static readonly CascadePrecedence None

    The precedence nothing loses to.

Methods (7)

  • public CascadePrecedence(int OriginRank, int LayerRank, Specificity Specificity, int Order)

    Everything about a declaration that decides whether it wins, in comparable form.

  • public int CompareTo(CascadePrecedence other)

    Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

  • public static bool operator <(CascadePrecedence left, CascadePrecedence right)

    Compares two precedences.

  • public static bool operator >(CascadePrecedence left, CascadePrecedence right)

    Compares two precedences.

  • public static bool operator <=(CascadePrecedence left, CascadePrecedence right)

    Compares two precedences.

  • public static bool operator >=(CascadePrecedence left, CascadePrecedence right)

    Compares two precedences.

  • public override string ToString()

    Returns the fully qualified type name of this instance.

Used by (2)

  • StyleResolverVixen.Ui.Styling
  • WinnerVixen.Ui.Styling