RESOLVED FIXED 200842
Support for "not" in media queries
https://bugs.webkit.org/show_bug.cgi?id=200842
Summary Support for "not" in media queries
Dean Jackson
Reported 2019-08-16 16:38:17 PDT
Created attachment 376565 [details] test case We don't support the "not" operator in some parts of media queries. e.g. @media not (max-device-width: 10px) { .box { background-color: blue; } } That should evaluate to true on all devices which are wider than 10px. Test case attached.
Attachments
test case (426 bytes, text/html)
2019-08-16 16:38 PDT, Dean Jackson
no flags
Radar WebKit Bug Importer
Comment 1 2019-08-16 16:38:48 PDT
Dean Jackson
Comment 2 2019-08-16 16:41:45 PDT
I think we only support "not keyword" e.g. "not screen", but do not support "not" before arbitrary expressions.
Dean Jackson
Comment 3 2019-08-16 16:46:00 PDT
Yes. Looks like MediaQueryParser::readMediaType looks for MediaQuery::Not via string. I don't see any calls to MediaQueryParser::readMediaNot. We do support "not" in @supports CSSSupportsParser::consumeNegation
Dean Jackson
Comment 4 2019-08-24 20:32:48 PDT
https://drafts.csswg.org/mediaqueries-4/#mq-not The way I read this suggests that a "not" keyword requires a media type and media condition. So this might be correct behaviour.
Dean Jackson
Comment 5 2019-08-24 20:37:38 PDT
But, the syntax disagrees with this: <media-query> = <media-condition> | [ not | only ]? <media-type> [ and <media-condition-without-or> ]? <media-type> = <ident> <media-condition> = <media-not> | <media-in-parens> [ <media-and>* | <media-or>* ] <media-condition-without-or> = <media-not> | <media-in-parens> <media-and>* <media-not> = not <media-in-parens> <media-and> = and <media-in-parens> <media-or> = or <media-in-parens> <media-in-parens> = ( <media-condition> ) | <media-feature> | <general-enclosed> <media-feature> = ( [ <mf-plain> | <mf-boolean> | <mf-range> ] ) <mf-plain> = <mf-name> : <mf-value> <mf-boolean> = <mf-name> <mf-range> = <mf-name> <mf-comparison> <mf-value> | <mf-value> <mf-comparison> <mf-name> | <mf-value> <mf-lt> <mf-name> <mf-lt> <mf-value> | <mf-value> <mf-gt> <mf-name> <mf-gt> <mf-value> <mf-name> = <ident> <mf-value> = <number> | <dimension> | <ident> | <ratio> <mf-lt> = '<' '='? <mf-gt> = '>' '='? <mf-eq> = '=' <mf-comparison> = <mf-lt> | <mf-gt> | <mf-eq> <general-enclosed> = [ <function-token> <any-value> ) ] | ( <ident> <any-value> ) The <media-type> production does not include the keywords only, not, and, and or.
Ahmad Saleem
Comment 6 2022-08-20 16:11:28 PDT
I am able to reproduce this bug in Safari 15.6.1 and Safari Technology Preview 151 using attached test case and it shows "Black" rectangle. While all other browsers (Chrome Canary 106 and Firefox Nightly 105) show "Blue" rectangle. Just wanted to share updated testing results. Thanks!
Tim Nguyen (:ntim)
Comment 7 2023-02-10 17:53:36 PST
Fixed by MQ4 support.
Note You need to log in before you can comment on or make changes to this bug.