Vixen
02b45cc4
csharp
public sealed class ComputedStyle

Everything the cascade decided about one element, frozen.

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

Remarks

Immutable, interned, and compared by reference. The three go together: because it never changes it is safe to share, because it is shared two elements that look alike hold the same object, and because of that ReferenceEquals is a complete answer to "did this element's style change" — one pointer comparison instead of walking a property table.

[Doc 09](../../docs/plan/09-ui-framework.md) makes that the load-bearing property of the whole styling system: layout marks itself dirty only when the reference changed and a layout-affecting property differs, and a DataGrid with ten thousand identical cells computes one of these. It is the reason browsers can render large tables and the reason Vixen can.

Properties are kept sorted by id in parallel arrays. Lookup is a binary search over integers with no indirection, and — the part that matters more — equality is a memcmp of two Int32 spans, which is what makes interning cheap enough to do on every element of every restyle.

Fields and properties (5)

  • public static readonly ComputedStyle Empty

    The style of an element no rule matched and which inherits nothing.

  • public ComputedStyle? Parent

    The style this one inherited from, if any.

  • public int Count

    How many properties it holds.

  • public ReadOnlySpan<int> Properties

    The property ids it holds, ascending.

  • public ReadOnlySpan<int> Values

    The value ids it holds, in the same order.

Methods (6)

  • public bool TryGet(int property, out int value)

    Looks a property up.

  • public static ComputedStyle Create(List<KeyValuePair<int, int>> pairs, ComputedStyle? inheritedFrom = null)

    Builds a style from property/value pairs, which need not be sorted.

  • public bool Equals(ComputedStyle? other)
  • public override bool Equals(object? obj)

    Determines whether the specified object is equal to the current object.

  • public override int GetHashCode()

    Serves as the default hash function.

  • public override string ToString()

    Returns a string that represents the current object.

Used by (30)

  • AnimationTestsVixen.Ui.Styling.Tests
  • AnimatorVixen.Ui.Styling
  • BridgeFixtureVixen.Ui.Tests
  • CascadeFixtureVixen.Ui.Styling.Tests
  • CascadeOrderTestsVixen.Ui.Styling.Tests
  • CodeEditorVixen.Ui.Controls.Advanced
  • CompactionTestsVixen.Ui.Styling.Tests
  • CompositionTestsVixen.Ui.Tests
  • ComputedStyleCacheVixen.Ui.Styling
  • ComputedStyleTestsVixen.Ui.Styling.Tests
  • DrawListBuilderVixen.Ui
  • IncrementalDocumentTestsVixen.Ui.Tests
  • IncrementalRestyleOracleTestsVixen.Ui.Styling.Tests
  • InheritedPropertiesVixen.Ui.Styling
  • LayoutStyleBuilderVixen.Ui
  • MultipleAnimationTestsVixen.Ui.Styling.Tests
  • NodeCanvasVixen.Ui.Controls.Advanced
  • ShorthandExpansionTestsVixen.Ui.Styling.Tests
  • StyleEngineVixen.Ui.Styling
  • StyleResolverVixen.Ui.Styling
  • StyleSharingOracleTestsVixen.Ui.Styling.Tests
  • StyleSheetLoadingTestsVixen.Ui.Styling.Tests
  • StyleUpdaterVixen.Ui.Styling
  • ThemeAndScannerTestsVixen.Ui.Styling.Utilities.Tests
  • TransitionTestsVixen.Ui.Styling.Tests
  • UiDocumentVixen.Ui
  • UiElementVixen.Ui
  • UiTestVixen.Ui.Testing
  • UtilityFixtureVixen.Ui.Styling.Utilities.Tests
  • UtilityGenerationTestsVixen.Ui.Styling.Utilities.Tests