Repository navigation
Add the pointer/hover media features - #391
Conversation
|
Lifesaver, I had some issues on some projects which depends on this package, unblocked thanks to you. |
Signed-off-by: Nico Burns <[email protected]>
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! { |
There was a problem hiding this comment.
Could have been shared with Gecko
There was a problem hiding this comment.
Agreed. We should probably do that as a follow-up.
| } | ||
| } | ||
|
|
||
| impl Default for PointerCapabilities { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I think unit tests can just pass an empty bitflags, since they don't have pointer capabilities?
| /// 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) { |
There was a problem hiding this comment.
No, but the other "device data" properties seem to have getters/setters
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]>
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]>
…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
…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
…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
…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
…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
…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
Fixes #390
This feature is quite impactful as it is required for Tailwind's hover styles to work.
Servo PR: servo/servo#45681