Vixen
02b45cc4
csharp
public sealed class ComputedStyleCache

Makes equal computed styles be the same object.

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

Remarks

A dictionary keyed by the style itself. Interning is what turns "these two elements resolved to the same thing" from a claim into a pointer, and it is the precondition for every cheap thing downstream: reference-compared invalidation, a sharing cache that can key on a parent style, and a layout pass that can skip a subtree by comparing one word.

Nothing is ever evicted. The set of distinct computed styles in a UI is bounded by the stylesheet rather than by the element count — that is the entire premise — so growth is bounded by the thing that would have to be reloaded anyway. Clear is what a stylesheet reload calls.

Fields and properties (2)

  • public int Count

    How many distinct styles exist.

  • public int Hits

    How many times interning found an existing style.

Methods (2)

  • public ComputedStyle Intern(ComputedStyle style)

    Returns the canonical instance equal to .

  • public void Clear()

    Forgets everything, as a stylesheet reload must.

Used by (3)

  • ComputedStyleTestsVixen.Ui.Styling.Tests
  • StyleEngineVixen.Ui.Styling
  • StyleResolverVixen.Ui.Styling