w3c / device-posture

Device Posture API
https://www.w3.org/TR/device-posture/
Other
33 stars 21 forks source link

What should be @media and {not} (screen-fold-posture) behavior. #44

Closed darktears closed 3 years ago

darktears commented 3 years ago

Considering a CSS block like this :

@media all and (screen-fold-posture) {}

or

@media all and not (screen-fold-posture) {}

What the UA should return according to the following cases?

darktears commented 3 years ago

From the media query specification:

While media features normally have a syntax similar to CSS properties, they can also be written more simply as just the feature name, like (color).

When written like this, the media feature is evaluated in a boolean context. If the feature would be true for any value other than the number 0, a with the value 0, or the keyword none, the media feature evaluates to true. Otherwise, it evaluates to false.

darktears commented 3 years ago

@lilles I think we should always return true if the device support postures changes regardless of the current posture.

btw I was experimenting with display-mode and this snippet doesn't work, anything I'm doing wrong? https://jsbin.com/famajapihe/1/edit?html,css,output

Clearly the code here says otherwise https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/css/media_query_evaluator.cc;l=298?q=media%20query%20evaluator&ss=chromium I'm puzzled.

lilles commented 3 years ago

@lilles I think we should always return true if the device support postures changes regardless of the current posture.

A device not supporting posture changes is no-fold, right? That's the difference between no-fold and flat?

If I understand correctly, that means you want to change the spec to say that no-fold returns false in the boolean context?

An alternative would be to drop 'no-fold' for 'none' and let that be specified by the default handling of 'none' in the media queries spec.

Regarding the snippet:

"@media and (display-mode)" is invalid. You need to change your snippet to "@media all and (display-mode)" or simply "@media (display-mode)".

darktears commented 3 years ago

@lilles you're correct @media all and screen-fold-posture will always evaluate to true because even if the device doesn't support posture changes it will evaluate to no-fold and if the device support posture changes it will always be in one of the states (!no-fold). I'll update my CL in chromium to reflect that. I'll also clarify the spec with this example.

And for the snippet yes indeed, dumb me.