Vixen
dd8b0a81
csharp
public sealed class InheritedProperties

Which properties a child gets from its parent without asking.

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

Remarks

Inheritance is not a convenience, it is what makes a stylesheet finite. Setting color on a panel and having every label inside it follow is the difference between a theme and a per-element assignment for every element.

The list is CSS's, and it is short for a reason worth knowing: a property inherits when inheriting it is nearly always what someone wants. Text properties inherit; box properties do not, because a panel with padding: 8px whose every descendant also got 8px would be unusable. Getting this list wrong in either direction produces a UI that looks broken in a way that reads as a layout bug.

Custom properties (--x) always inherit and are not in the list — they are recognised by their name, since there is no finite set of them.

⚠ This cascade inherits specified values; CSS inherits computed ones, and the difference is not cosmetic. A child inheriting font-size: 1.5em as text would resolve that em against its own parent a second time, so a size meant to be applied once compounds at every level — a two-deep tree comes out at 2.25× where CSS says 1.5×, and the error grows with depth. CSS avoids it by computing font-size to an absolute length before anyone inherits it.

font-size is therefore removed from this list and inherited in computed form by Vixen.Ui instead, which is the same thing CSS does and in the same place — an element that declares none simply keeps its parent's resolved pixel size. Nothing else needs the specified string, and UiElement.FontSize is the value every consumer actually wants.

line-height and letter-spacing have since joined it, computed and inherited by Vixen.Ui for the same reason and by the same mechanism. Both take relative units, and both are read by the text layout, so the bounded one-level error they used to carry was one the renderer could see.

⚠ line-height is the one where computing is not simply resolving. A unitless 1.5 inherits as the number and is multiplied by each descendant's own font size, where 1.5em inherits as the length the ancestor resolved. That distinction is the whole reason the unitless form exists, so the computed value carries which of the two it is rather than collapsing both to pixels.

⚠ That gap is now closed, and closing it was a removal from this list rather than an addition to it. text-indent left the sentence when LineWrapper learned a first-line width, and word-spacing left it when TextRun learned which characters CSS separates words with. Neither joined this list on gaining a reader: both take relative units, so both are computed and inherited beside line-height and letter-spacing for the reason the note below gives. word-spacing had been in this list all along, which was the more interesting half — see the note there.

Methods (5)

  • public InheritedProperties(NameTable properties)

    Interns the inherited property names into a table.

  • public bool Inherits(int property)

    Whether a property inherits.

  • public bool InheritedPortionDiffers(ComputedStyle before, ComputedStyle after)

    Whether two styles differ in any property a child would have inherited.

  • public ComputedStyle Descend(ComputedStyle parentCascaded, ComputedStyle parentDisplayed, ComputedStyle cascaded, ComputedStyle displayed)

    Hands a descendant the value its ancestor is displaying for an inherited property.

  • public static bool IsCustomProperty(string name)

    Whether a property name is a custom property.

Used by (3)

  • StyleResolverVixen.Ui.Styling
  • StyleUpdaterVixen.Ui.Styling
  • UiDocumentVixen.Ui