public sealed class StyleSheetLoaderTurns stylesheet text into rules the cascade can run.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
ExCSS parses; this walks what it produced and decides what each piece is. Three things it has to handle that ExCSS does not:
@layer. ExCSS 4.3.2 predates cascade layers and hands the rule back unparsed, text intact — which [the spike](../../docs/plan/spikes/vcss-excss/RESULT.md) established deliberately, before this depended on it. The prelude is read here and the body is handed straight back to ExCSS, so the gap stops at this file.
@media. A block's rules are loaded whether or not it applies, each tagged with the MediaConditions group it came from, and the verdict is a surface's rather than the rule set's — which is what lets two windows of one document answer max-width differently. It was decided at load and thrown away until then, and the cost of that was not the trade it looked like: a resize that crossed a breakpoint had to re-parse every sheet with ExCSS (42 ms for the editor's twelve), and it restarted every fade in the window while doing it.
⚠ A sheet loaded with a fixed context keeps the old behaviour, and that is not an inconsistency. StyleEngine.Load's media argument means "this sheet is about a 320-pixel surface", which is a fixed question, so it gets a fixed answer decided here and no group. A sheet that named no context is about whatever surface it is being shown on, and there is more than one of those.
⚠ Only style rules are conditional. @keyframes and @layer inside a @media load unconditionally, because both are document-global by construction — one KeyframesTable and one layer order per rule set, shared by every surface exactly as the rules are. Neither does anything on its own: a keyframes definition is inert until an animation-name names it, and that declaration is in a rule and is gated; a layer with no rules in it only fixes an order. So loading them regardless is invisible rather than merely convenient, and the alternative — a keyframes table per surface — would be a much larger change for no case anybody has.
Anything unsupported. Dropped with a diagnostic naming what was written, never approximated — the same rule the selector compiler follows and for the same reason.
Fields and properties (3)
public IReadOnlyList<SelectorDiagnostic> DiagnosticsEverything that could not be loaded, and why.
public MediaConditions ConditionsThe conditional groups this loader has registered.
public ContainerConditions ContainersThe @container groups this loader has registered.
Methods (3)
public StyleSheetLoader(StyleRuleSet rules, KeyframesTable keyframes, SelectorCompiler compiler, MediaConditions conditions, ContainerConditions containers)Creates a loader.
public void Load(string css, StyleOrigin origin, MediaContext? media)Loads a stylesheet.
public void ReadDeclarations(string css, List<InlineDeclaration> into)Reads the declaration list in a style="…" attribute.
Used by (10)
- BuildContextVixen.Ui
- ContainerQueryTestsVixen.Ui.Styling.Tests
- DrawListTestsVixen.Ui.Tests
- EmitterTestsVixen.Ui.Markup.Tests
- ForcedColorsTestsVixen.Ui.Tests
- HotReloadWatcherTestsVixen.Ui.HotReload.Tests
- StyleDiagnosticDrainTestsVixen.Ui.Tests
- StyleEngineVixen.Ui.Styling
- StyleSheetLoadingTestsVixen.Ui.Styling.Tests
- UiDocumentVixen.Ui