Vixen
02b45cc4
csharp
public sealed class LayoutStyleBuilder

Turns what the cascade decided into what the flexbox engine reads.

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

Remarks

Two finished subsystems that do not reference each other: Vixen.Ui.Styling resolves declarations without knowing what a length measures, and Vixen.Ui.Layout measures without knowing where its numbers came from. This is the wire between them, and it is the first thing Vixen.Ui owes — an element tree cannot be built until a computed style can become a layout style.

Font size is resolved first and separately, because it is the thing everything else is relative to. On font-size itself, em and % mean the parent's size; on every other property they mean the element's own. Conflating the two compounds down the tree — three nested font-size: 1.2em come out at 1.2× rather than 1.728×, and the error grows with depth, so it looks like a rendering quirk rather than an arithmetic one.

⚠ Percentages are not resolved here. A percentage measures against the containing block, which only the layout pass knows — so 50% is carried through to Percent untouched. This is the one place where doing less is the correct behaviour rather than an omission.

Fields and properties (4)

  • public static readonly LayoutStyle CssInitial

    What an element with no declarations gets, per CSS rather than per Yoga.

  • public int LetterSpacingId

    The id of letter-spacing, for the computed-value stage.

  • public int WordSpacingId

    The id of word-spacing.

  • public int TextIndentId

    The id of text-indent.

Methods (5)

  • public LayoutStyleBuilder(NameTable properties, NameTable values, NameTable keywordNames)

    Creates a builder over a style engine's name tables.

  • public float ResolveFontSize(ComputedStyle style, float parentFontSize, in LengthContext context)

    Resolves an element's font size, which everything else is measured against.

  • public bool TryTextLength(ComputedStyle style, int property, in LengthContext context, out float points)

    Resolves one absolute text length against this element's own font size.

  • public bool TryLineHeight(ComputedStyle style, in LengthContext context, out float? factor, out float points)

    Resolves line-height, keeping a bare number as a number.

  • public LayoutStyle Build(ComputedStyle style, in LengthContext context)

    Builds the layout style for one element.

Used by (3)

  • BridgeFixtureVixen.Ui.Tests
  • LayoutStyleBridgeTestsVixen.Ui.Tests
  • UiDocumentVixen.Ui