Vixen
dd8b0a81
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 (2)

  • public static readonly LayoutStyle CssInitial

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

  • public IReadOnlyList<SelectorDiagnostic> Diagnostics

    What this bridge could not read, and why.

Methods (5)

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

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

  • public void ClearDiagnostics()

    Forgets every refusal recorded so far.

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

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

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

    Builds the layout style for one element.

  • public void ApplyVariableLength(ComputedStyle style, LayoutTree tree, LayoutNodeId node)

    Applies the style properties whose values are lists rather than fixed-size fields.

Used by (4)

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