Vixen
dd8b0a81
csharp
public readonly struct StyleLength

A length as it was written: a number and what kind of number it is.

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

Remarks

Eight bytes, and there are around fifty of them per node, which is most of what a style costs. Keeping the unit here rather than in a parallel array is deliberate: every read of a length reads both halves, and splitting them would double the cache lines a layout pass touches for no gain.

Fields and properties (8)

  • public static readonly StyleLength Undefined

    Nothing was set.

  • public static readonly StyleLength Auto

    The algorithm decides.

  • public static readonly StyleLength Zero

    Zero points.

  • public readonly float Value

    The number. Meaningless unless Unit says otherwise.

  • public readonly LayoutUnit Unit

    What kind of length this is.

  • public bool IsDefined

    Whether anything was set.

  • public bool IsResolvable

    Whether this is a length that resolves to a number against a containing size.

  • public bool IsContentBased

    Whether this length is one of CSS Sizing § 5's three content keywords.

Methods (11)

  • public StyleLength(float value, LayoutUnit unit)

    Creates a length.

  • public static StyleLength Points(float value)

    An absolute length.

  • public static StyleLength Percent(float value)

    A fraction of the containing block.

  • public static StyleLength Keyword(LayoutUnit unit)

    A keyword length with no number of its own.

  • public float Resolve(float referenceLength)

    Resolves against a containing size, or NaN if it does not resolve.

  • public bool Equals(StyleLength other)

    Indicates whether the current object is equal to another object of the same type.

  • public override bool Equals(object? obj)

    Indicates whether this instance and a specified object are equal.

  • public override int GetHashCode()

    Returns the hash code for this instance.

  • public static bool operator ==(StyleLength left, StyleLength right)

    Compares two lengths.

  • public static bool operator !=(StyleLength left, StyleLength right)

    Compares two lengths.

  • public override string ToString()

    Returns the fully qualified type name of this instance.

Used by (70, showing 40)

  • LayoutBenchmarksVixen.Benchmarks.Ui
  • AbsoluteAutoMarginTestsVixen.Ui.Layout.Tests
  • AbsolutePositionTestsVixen.Ui.Layout.Tests
  • AlignContentTestsVixen.Ui.Layout.Tests
  • AlignItemsTestsVixen.Ui.Layout.Tests
  • AlignSelfTestsVixen.Ui.Layout.Tests
  • AndroidNewsFeedTestsVixen.Ui.Layout.Tests
  • AspectRatioTestsVixen.Ui.Layout.Tests
  • AutoTestsVixen.Ui.Layout.Tests
  • AutomaticMinimumSizeTestsVixen.Ui.Layout.Tests
  • BaselineAlignmentTestsVixen.Ui.Layout.Tests
  • BlockificationTestsVixen.Ui.Layout.Tests
  • BorderTestsVixen.Ui.Layout.Tests
  • BoxSizingTestsVixen.Ui.Layout.Tests
  • ContainmentTestsVixen.Ui.Layout.Tests
  • ContentSizingTestsVixen.Ui.Layout.Tests
  • DimensionLengthsVixen.Ui.Layout
  • DimensionTestsVixen.Ui.Layout.Tests
  • DisplayTestsVixen.Ui.Layout.Tests
  • DrawListBuilderVixen.Ui
  • EdgeLengthsVixen.Ui.Layout
  • FlexBasisFitContentTestsVixen.Ui.Layout.Tests
  • FlexDirectionTestsVixen.Ui.Layout.Tests
  • FlexTestsVixen.Ui.Layout.Tests
  • FlexWrapTestsVixen.Ui.Layout.Tests
  • FlexibleLengthResolutionTestsVixen.Ui.Layout.Tests
  • FloatBandQueryTestsVixen.Ui.Layout.Tests
  • FloatBlindSpotTestsVixen.Ui.Layout.Tests
  • GapTestsVixen.Ui.Layout.Tests
  • GridBlindSpotTestsVixen.Ui.Layout.Tests
  • GridSpecVixen.Ui.Layout.Tests
  • GridTemplateAreasTestsVixen.Ui.Layout.Tests
  • GutterLengthsVixen.Ui.Layout
  • InlineBlindSpotTestsVixen.Ui.Layout.Tests
  • InlineFloatInteractionTestsVixen.Ui.Layout.Tests
  • InlineFormattingTestsVixen.Ui.Layout.Tests
  • InlineFragmentationTestsVixen.Ui.Layout.Tests
  • InlineStrutTestsVixen.Ui.Layout.Tests
  • InlineTextAlignTestsVixen.Ui.Layout.Tests
  • IntrinsicSizeTestsVixen.Ui.Layout.Tests