Skip to content

Implement the pointer/hover interaction media features for servo - #389

Closed
UMCEKO wants to merge 2 commits into
servo:mainfrom
UMCEKO:feat/pointer-hover-media-features
Closed

UMCEKO wants to merge 2 commits into
servo:mainfrom
UMCEKO:feat/pointer-hover-media-features

Conversation

@UMCEKO

@UMCEKO UMCEKO commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Problem

Servo's media-feature list (style/servo/media_features.rs) implements none of the interaction media features: pointer, any-pointer, hover, any-hover. An unknown feature never matches, so any rules guarded by them are silently dropped.

This bites real stylesheets: modern CSS frameworks (e.g. Tailwind v4) wrap their :hover utilities in @media (hover: hover), so on a servo-backed engine all hover styling disappears.

Fix

Implement the four interaction features, evaluated against a new PointerCapabilities carried by the servo Device — a bitflags of COARSE / FINE / HOVER, mirroring the gecko backend's evaluator shape:

  • stylo_atoms: add the pointer / any-pointer / hover / any-hover feature-name atoms (first commit; builds standalone).
  • style/queries/values.rs: PointerCapabilities (shared feature value).
  • style/servo/media_features.rs: Pointer / Hover keyword evaluators + the four MEDIA_FEATURES entries.
  • style/device/servo.rs: a pointer_capabilities field defaulting to a desktop-class pointer (FINE | HOVER), with set_pointer_capabilities for embedders on touch-first devices to override, and {,any_}pointer_capabilities() accessors. any-* resolves to the same set, as servo models a single pointer.

Verification

Builds with --features servo. Behaviour is exercised end-to-end by integration tests in a downstream consumer (Blitz): @media (hover: hover) / (pointer: fine) / the bare and any-* forms match on the default desktop device, while (hover: none) / (pointer: coarse) do not.

UMCEKO added 2 commits June 13, 2026 16:30
The servo media-feature list had no interaction features, so
`@media (hover: hover)`, `(pointer: fine)`, and the `any-*` forms never
matched — silently dropping any rules they guard. (Modern CSS frameworks
wrap their `:hover` styles in `@media (hover: hover)`, so on servo-backed
engines all hover styling was being dropped.)

Add `pointer`, `any-pointer`, `hover`, and `any-hover`, evaluated against
a new `PointerCapabilities` carried by the servo `Device` (a `bitflags`
of COARSE/FINE/HOVER, mirroring the gecko backend). The device defaults
to a desktop-class pointer (FINE | HOVER) and exposes
`set_pointer_capabilities` so an embedder on a touch-first device can
override it. `any-*` resolves to the same capabilities, as servo models a
single pointer.
@jdm

jdm commented Jun 13, 2026

Copy link
Copy Markdown
Member

@UMCEKO Did you use AI tools to write the code or the pull request description?

@UMCEKO

UMCEKO commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@UMCEKO Did you use AI tools to write the code or the pull request description?

Yes, I reviewed the code manually, and tested it in a real working app.

@jdm

jdm commented Jun 13, 2026

Copy link
Copy Markdown
Member

@UMCEKO AI code contributions are not allowed in Servo, per our AI policy

@jdm jdm closed this Jun 13, 2026
@UMCEKO

UMCEKO commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Okay, forking it

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants