- From: Florian Rivoal <florianr@opera.com>
- Date: Fri, 25 May 2012 15:59:36 +0200
- To: "WWW Style" <www-style@w3.org>, "Kang-Hao (Kenny) Lu" <kennyluck@csail.mit.edu>
The spec does indeed call for B. I'd be tempted to say that we should leave it as is, as B is a relatively sane behavior given the situation, but since nobody implements it this way, maybe we should question that. I am not a huge fan of A. From an authors' point of view, I would expect that either 'only', 'and' and 'not' are all valid names for media types that happens to never match, or the three of them are invalid. The only reason to justification for A is ease of implementation, and that's likely to go way over most authors's head, so they'll never remember what's valid and what's not. - Florian On Tue, 22 May 2012 22:47:31 +0200, Kang-Hao (Kenny) Lu <kennyluck@csail.mit.edu> wrote: > My reading of the current grammar > > # media_query > # : [ONLY | NOT]? S* media_type S* [ AND S* expression ]* > # | expression [ AND S* expression ]* > # ; > # media_type > # : IDENT > # ; > > suggests that "not", "only" and "and" can be used as media_type and > therefore the following are all valid: "not and (width)", "not not", > "not and and (width)". However, no browser implements this. Here are > some options: > > A. Change the spec: "not" and "only" as media_type cannot be valid > unless it's preceded by "not" or "only". > > == valid == > and [ and (expr) ]* > [ not | only ] [ not | only | and ] [ and (expr) ]* > > == invalid == > [ not | only ] [ and (expr) ]* > > Firefox12 and IE9 implement this. I probably support this. If we had > started writing this section using a state machine-based instead of a > rule-based approach, we would have been closer to this, I think. > > I think I support this. The concrete proposal is to change > > # media_query > # : [ONLY | NOT]? S* media_type S* [ AND S* expression ]* > # | expression [ AND S* expression ]* > # ; > # media_type > # : IDENT > # ; > > to > > | media_query > | : [ONLY | NOT] S* media_type S* [ AND S* expression ]* > | | media_type_no_keywords S* [ AND S* expression ]* > | | expression [ AND S* expression ]* > | ; > | media_type > | : IDENT > | ; > | /* > | * There is a constraint on it that it must not be {O}{N}{L}{Y} or > | * {N}{O}{T} > | */ > | media_type_no_keywords > | : IDENT > | ; > > B. Don't change the spec (besides perhaps add some test cases to the > test suite) > > == valid == > and [ and (expr) ]* > [ not | only ] [ not | only | and ] [ and (expr) ]* > [ not | only ] [ and (expr) ]* > > == invalid == > > This is actually implementable (I have a patch for Gecko[1], though the > code is admittedly quite crappy.). > > > C. Change the spec: "not", "only" and "and" cannot be media_type. > > == valid == > > == invalid == > and [ and (expr) ]* > [ not | only ] [ not | only | and ] [ and (expr) ]* > [ not | only ] [ and (expr) ]* > > Chromium nightly and Opera12alpha implement this. I am slightly opposed > to this because, for the majority of normal cases, an extra check to see > if it's "and" is required. > > > I should note that while some of these are only observable via CSSOM, > the ones starting with "not" can be observed without scripts, say: > > data:text/html,<style>@media not not {:root{background: green;}}</style> > > data:text/html,<style>@media not and and (width) {:root{background: > green;}}</style> > > [1] https://bugzilla.mozilla.org/show_bug.cgi?id=757554#c3 > > > Cheers, > Kenny
Received on Friday, 25 May 2012 14:22:36 UTC