Skip to content

Add the pointer/hover media features - #391

Merged
nicoburns merged 1 commit into
servo:mainfrom
nicoburns:media-hover
Jun 15, 2026
Merged

nicoburns merged 1 commit into
servo:mainfrom
nicoburns:media-hover

Conversation

@nicoburns

@nicoburns nicoburns commented Jun 13, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #390

This feature is quite impactful as it is required for Tailwind's hover styles to work.

Servo PR: servo/servo#45681

@UMCEKO

UMCEKO commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Lifesaver, I had some issues on some projects which depends on this package, unblocked thanks to you.

Comment thread style/servo/media_features.rs Resolved
@nicoburns
nicoburns added this pull request to the merge queue Jun 15, 2026
Merged via the queue into servo:main with commit 49e912c Jun 15, 2026
5 checks passed
@nicoburns
nicoburns deleted the media-hover branch June 15, 2026 11:57
raptor4mc pushed a commit to RingTail-foundation/RingTail that referenced this pull request Jun 15, 2026
Implements the `pointer`, `any-pointer`,`hover`, and `any-hover` media
features.

Actually detecting pointer capabilities from the system is left as a
follow-up (this is tricky as Winit doesn't expose this information).
This PR just configures Stylo with sensible defaults (mouse-like pointer
on desktop platforms, touch-like pointer on mobile platforms).

- ~Builds on: servo#44978 This has been
reordered - this PR is now first.
- Stylo PR: servo/stylo#391

Testing: WPT tests
Part of: servo#39068

Signed-off-by: Nico Burns <[email protected]>
}
}

bitflags! {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could have been shared with Gecko

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. We should probably do that as a follow-up.

}
}

impl Default for PointerCapabilities {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about having a random default here, seems like it should be up to Servo to decide to pass the correct thing or lie.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's convenient to have it here rather than in Servo because otherwise it needs to be duplicated into things like tests. But perhaps we could make it an explicitly named method (PointerCapabilities::guess_from_os() or similar) rather than using the Default trait for this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think unit tests can just pass an empty bitflags, since they don't have pointer capabilities?

Comment thread style/device/servo.rs
/// Note that this does not update any associated `Stylist`. For this you must call
/// `Stylist::media_features_change_changed_style` and
/// `Stylist::force_stylesheet_origins_dirty`.
pub fn set_primary_pointer_capabilities(&mut self, capabilities: PointerCapabilities) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but the other "device data" properties seem to have getters/setters

TG199 pushed a commit to TG199/servo that referenced this pull request Jun 21, 2026
Implements the `pointer`, `any-pointer`,`hover`, and `any-hover` media
features.

Actually detecting pointer capabilities from the system is left as a
follow-up (this is tricky as Winit doesn't expose this information).
This PR just configures Stylo with sensible defaults (mouse-like pointer
on desktop platforms, touch-like pointer on mobile platforms).

- ~Builds on: servo#44978 This has been
reordered - this PR is now first.
- Stylo PR: servo/stylo#391

Testing: WPT tests
Part of: servo#39068

Signed-off-by: Nico Burns <[email protected]>
Loirooriol pushed a commit that referenced this pull request Jul 1, 2026
Fixes #390

This feature is quite impactful as it is required for Tailwind's hover
styles to work.

Servo PR: servo/servo#45681

Signed-off-by: Nico Burns <[email protected]>
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Jul 7, 2026
…x-style-system-reviewers,emilio

We were previously using a mix of f32 and f64. Then it could happen that
we would first check that `a < b` in f64, but when converting to f32,
they might become equal due to the precision loss. Thus this could break
invariants in the logic, making a `debug_unreachable!()` reachable.

Imports servo/stylo#391

Differential Revision: https://phabricator.services.mozilla.com/D310915
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Jul 7, 2026
…x-style-system-reviewers,emilio

This feature is quite impactful as it is required for Tailwind's hover
styles to work.

Imports servo/stylo#391

Differential Revision: https://phabricator.services.mozilla.com/D310916
github-actions Bot pushed a commit to longvatrong111/stylo that referenced this pull request Jul 8, 2026
…x-style-system-reviewers,emilio

We were previously using a mix of f32 and f64. Then it could happen that
we would first check that `a < b` in f64, but when converting to f32,
they might become equal due to the precision loss. Thus this could break
invariants in the logic, making a `debug_unreachable!()` reachable.

Imports servo#391

Differential Revision: https://phabricator.services.mozilla.com/D310915
github-actions Bot pushed a commit to longvatrong111/stylo that referenced this pull request Jul 8, 2026
…x-style-system-reviewers,emilio

This feature is quite impactful as it is required for Tailwind's hover
styles to work.

Imports servo#391

Differential Revision: https://phabricator.services.mozilla.com/D310916
zerox80 pushed a commit to zerox80/firefox that referenced this pull request Oct 16, 2026
…x-style-system-reviewers,emilio

We were previously using a mix of f32 and f64. Then it could happen that
we would first check that `a < b` in f64, but when converting to f32,
they might become equal due to the precision loss. Thus this could break
invariants in the logic, making a `debug_unreachable!()` reachable.

Imports servo/stylo#391

Differential Revision: https://phabricator.services.mozilla.com/D310915
zerox80 pushed a commit to zerox80/firefox that referenced this pull request Oct 16, 2026
…x-style-system-reviewers,emilio

This feature is quite impactful as it is required for Tailwind's hover
styles to work.

Imports servo/stylo#391

Differential Revision: https://phabricator.services.mozilla.com/D310916
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.

Implement the pointer/hover interaction media features for the servo backend

4 participants