Skip to content

IRenderDevice has no Media Queries Level 5 user-preference features #234

Description

@lahma

IRenderDevice models the Media Queries Level 3/4 device features (viewport and device size, resolution, colour depth, grid, scan, scripting, category) but none of the Media Queries Level 5 user-preference features:

  • prefers-color-scheme: light | dark
  • prefers-reduced-motion: no-preference | reduce
  • prefers-reduced-transparency: no-preference | reduce
  • prefers-contrast: no-preference | more | less | custom
  • forced-colors: none | active
  • prefers-reduced-data: no-preference | reduce

From Level 4, hover / any-hover and pointer / any-pointer have validators but no device member to read from, and display-mode (Web App Manifest) has none.

Each of these is an unknown feature today and answers false, so @media (prefers-color-scheme: dark), by some distance the most common Level 5 query on the web, never applies in the cascade, and matchMedia("(prefers-color-scheme: dark)").matches (with #228) is always false. Neither is wrong for a device that has no preference, but a host that has one, such as a headless browser emulating a dark theme or reduced motion for a page, has no way to say so.

Suggested shape: one enum per feature, the properties on DefaultRenderDevice plus a new sub-interface (say IRenderDevicePreferences) that existing IRenderDevice implementers are not forced to implement, defaulting to "no preference" when the device does not carry it; one validator per feature registered in DefaultFeatureValidatorFactory; keywords in CssKeywords, names in FeatureNames. Happy to send a PR if the shape is agreed; the interface extension is the part that needs your call first.

Independent of the four evaluation defects filed alongside.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions