Vixen
dd8b0a81
csharp
public sealed class MediaScopes

The surfaces one rule set is being shown on, and what @media answers on each.

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

Remarks

One rule set, several answers. A document's surfaces share a rule set — that is what keeps one theme across a torn-off window, and it is the reason @media could not answer per window while the verdict lived in the rule set. A scope is where the verdict lives instead: one MediaContext and one MediaVerdicts per place the document is shown, and an element resolves against the scope it is in.

⚠ Ids are monotonic and never reused, for the reason UiSurface.Id is. A node carries its scope, and a scope handed out again after a window closed would give whatever had inherited the old id the new window's breakpoints. Scopes are created when a window opens, so the list grows at human speed and never being reclaimed costs a reference each.

⚠ Verdicts are re-evaluated lazily against Revision rather than eagerly on a reload. A load registers groups one at a time — a sheet with forty @media blocks bumps the revision forty times — and evaluating every scope after each would be quadratic in the number of windows for no observable difference. The cost of the laziness is one integer compare on the path that reads them, which is the cascade, and that path was already doing dictionary work per element.

Fields and properties (2)

  • public const int Document

    The scope an element outside every surface is in, and the engine's own default.

  • public int Count

    How many scopes have been created, the document's included.

Methods (6)

  • public MediaScopes(MediaConditions conditions)

    Creates a registry over a condition table, with the document's scope in it.

  • public int Create(MediaContext context)

    Adds a place the document is shown.

  • public MediaContext ContextOf(int scope)

    What a scope's surface is.

  • public bool Set(int scope, MediaContext context)

    Tells a scope what its surface is now.

  • public MediaVerdicts VerdictsOf(int scope)

    Which groups hold in a scope.

  • public bool Refresh()

    Whether any scope's verdicts have moved since they were last read.

Used by (9)

  • ContainerQueryTestsVixen.Ui.Styling.Tests
  • HasInvalidationTestsVixen.Ui.Styling.Tests
  • IncrementalRestyleOracleTestsVixen.Ui.Styling.Tests
  • PerSurfaceMediaTestsVixen.Ui.Tests
  • StyleEngineVixen.Ui.Styling
  • StyleResolverVixen.Ui.Styling
  • StyleSharingOracleTestsVixen.Ui.Styling.Tests
  • StyleTreeVixen.Ui.Styling
  • UiDocumentVixen.Ui