Re: [mediaqueries] Unintuitive evaluation in boolean context

On Aug 13, 2014 6:50 PM, "David Bokan" <bokan@google.com> wrote:
>
> Hello,
>
> I'm implementing the newly added any-hover and any-pointer media
> features in Media Queries Level 4. When it comes to evaluating these
> features in a boolean context, I find the specified behavior to be
> unintuitive.

As the reviewer of said implementation, I also found this definition of
boolean context extremely confusing when applied to sets.

> From the spec on evaluating in a boolean context (2.4.2):
>
> "If the feature would be true for the number 0, a dimension with the
> value 0, or the keyword none, the media feature evaluates to false. If
> it would be true for any values other than the above, it evaluates to
> true. Otherwise, it evaluates to false."
>
> This means if a user has a mouse and some other non-pointing input
> device (e.g. voice recognition?), '@media (any-pointer)' would
> evaluate to false. As a developer, I would expect that to evaluate to
> true if there is any pointing device available to the UA. This could
> be made intuitive by changing the order of the statements in the spec:
>
> "If it would be true for any values other than the number 0, a
> dimension with the value 0, or the keyword none, it evaluates to true.
> If the feature would be true for any of the values above, the media
> feature evaluates to false. Otherwise, it evaluates to false."
>
> Is the existing ordering intentional?
> As far as I can tell this
> wouldn't affect any other media features.

+1 to changing that definition.

I don't think that definition represents the common case of what authors
want to achieve with boolean context sets. And in the rare case that they
want that, they can do that by using "not (any-*: none)", right?

Since this hasn't shipped anywhere AFAIK (implemented behind a flag in
Blink, but I believe nowhere else), can we change that boolean context
definition so that it'd make more sense when it comes to sets?

Thanks,
Yoav
 Hello,

I'm implementing the newly added any-hover and any-pointer media
features in Media Queries Level 4. When it comes to evaluating these
features in a boolean context, I find the specified behavior to be
unintuitive. From the spec on evaluating in a boolean context (2.4.2):

"If the feature would be true for the number 0, a dimension with the
value 0, or the keyword none, the media feature evaluates to false. If
it would be true for any values other than the above, it evaluates to
true. Otherwise, it evaluates to false."

This means if a user has a mouse and some other non-pointing input
device (e.g. voice recognition?), '@media (any-pointer)' would
evaluate to false. As a developer, I would expect that to evaluate to
true if there is any pointing device available to the UA. This could
be made intuitive by changing the order of the statements in the spec:

"If it would be true for any values other than the number 0, a
dimension with the value 0, or the keyword none, it evaluates to true.
If the feature would be true for any of the values above, the media
feature evaluates to false. Otherwise, it evaluates to false."

Is the existing ordering intentional? As far as I can tell this
wouldn't affect any other media features.

Thanks,
David

Received on Tuesday, 19 August 2014 11:03:14 UTC