Re: [csswg-drafts] [css-conditional-5] Add ability to test for at-rule preludes (#6966)

The CSS Working Group just discussed `At-rule Prelude Tests`.

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: At-rule Prelude Tests<br>
&lt;fantasai> github: https://github.com/w3c/csswg-drafts/issues/6966<br>
&lt;fantasai> TabAtkins: earlier we defined testing for at-rules and descriptors, which we can do generically by throwing it at a parser<br>
&lt;fantasai> TabAtkins: we don't have ability to check if prelude of atr-ule is valid or not<br>
&lt;fantasai> TabAtkins: this should follow the same "throw at parser and see", but not possible atm<br>
&lt;fantasai> TabAtkins: especially important for at-rules that don't have blocks, e.g. @layer statement form<br>
&lt;fantasai> TabAtkins: you can test @layer at all, but not specifically for @rule statements<br>
&lt;fantasai> TabAtkins: suggest we take the first form of the at-rule syntax and allow it to take more<br>
&lt;fantasai> TabAtkins: parse all of that as the prelude<br>
&lt;miriam> q+<br>
&lt;fantasai> TabAtkins: as long as it passes your parser check, it's OK<br>
&lt;heycam> q+<br>
&lt;fantasai> miriam: I think this is also required for testing whether style queries are supported<br>
&lt;astearns> ack heycam<br>
&lt;fantasai> heycam: I'm wondering if there's any benefit from having this called "rule" rather than "at-rule", can we match any kind of rule not just at-rules?<br>
&lt;fantasai> TabAtkins: unless you know the context you're parsing in, there's only one type of rule and it's style rule<br>
&lt;fantasai> heycam: for those rules you can rely on selectors and individual properties<br>
&lt;heycam> fantasai: to summarize, three parsing forms for at-rule function<br>
&lt;heycam> ... one just takes the name<br>
&lt;heycam> ... one takes the entirety of the rule, and if anything is dropped, then it returns false<br>
&lt;fantasai> https://github.com/w3c/csswg-drafts/issues/6966<br>
&lt;heycam> ... and the third is the existing descriptor, `@foo; descriptor:value`<br>
&lt;TabAtkins> at-rule(@foo bar {baz: qux}),<br>
&lt;fantasai> fantasai: That would let you do complicated nesting structures as well<br>
&lt;fantasai> TabAtkins: If feed into parser, is the top-level rule kept or not. Ignoring inside things.<br>
&lt;heycam> fantasai: I think that would not be hepful<br>
&lt;fantasai> TabAtkins: more specific, would require more specific plumbing in browsers<br>
&lt;fantasai> TabAtkins: to report pass or failure<br>
&lt;fantasai> TabAtkins: and also it's more powerful than you necessarily wanted<br>
&lt;heycam> fantasai: I think if we want to add a full whole thing kind of syntax, then we should be parsing everything in there and if anything is dropped, you fail<br>
&lt;heycam> ... if you want it more limited<br>
&lt;heycam> ... if you want to check statement vs block, then add curly quotes<br>
&lt;heycam> ... as soon as you put something in there, authors will expect it's testing everything in there<br>
&lt;heycam> ... if we allow dropped things, authors will be confused, and we won't have an extension mechanism in the future<br>
&lt;heycam> fantasai: authors are going to expect that when you put a test in @supports it's everything you put in there that you're checking<br>
&lt;florian> q+<br>
&lt;heycam> fantasai: fine to add more specific syntaxes, but authors are going to expect if you add in @supports, it's checking the full thing is understood<br>
&lt;heycam> miriam: I agree<br>
&lt;heycam> emilio: yes<br>
&lt;fantasai> TabAtkins: That is something that was specifically called out, that bubling up invalidity is problematic<br>
&lt;chris> s/emilio/chris/<br>
&lt;heycam> TabAtkins: that was specifically called out as problematic in an earlier discussion<br>
&lt;heycam> fantasai: so limit the syntax<br>
&lt;heycam> fantasai: that's fine, if you want to do nested structures, do it properly<br>
&lt;astearns> ack florian<br>
&lt;fantasai> ^TabAtkins: then do nested structures<br>
&lt;fantasai> florian: We don't want @supports to be smart. Want to use the actual parser<br>
&lt;fantasai> florian: if we start to maintain some degree of logic, then that logic can get out of sync with reality<br>
&lt;fantasai> s/do nested/don't do nested/<br>
&lt;fantasai> s/don't/can't/<br>
&lt;fantasai> florian: usefulness of at-supports will decrease if we try to be smart about it, because will be less reliable<br>
&lt;heycam> fantasai: I think it's more important that anyything we allow in @supports ,the author can rely it's testing the whole thing<br>
&lt;heycam> ... I think that's more important than the concern that it might get out of sync<br>
&lt;heycam> TabAtkins: I disagree. author confusion is substantially better than UA lying.<br>
&lt;heycam> fantasai: the UA is effectively lying from the perspective of the author<br>
&lt;emilio> q+<br>
&lt;fantasai> fantasai: if you let it ignore stuff that is inside @supports check<br>
&lt;fantasai> astearns: This is an issue about preludes, so how about we just add preludes and not address nesting<br>
&lt;fantasai> TabAtkins: so we would just take the prelude, not semicolon<br>
&lt;astearns> ack emilio<br>
&lt;fantasai> emilio: I agree with TabAtkins, it's weird to suddenly pass e.g. @font-face rule, and you read the descriptors and the ones you care about you keep and the others you ignore<br>
&lt;TabAtkins> Authors being confused means the author can fix this, by doing it right. UAs lying means the author can't fix this; they're just screwed. UA lying is *meaningfully different* from author confusion.<br>
&lt;fantasai> emilio: it would require this special mode, then you have to find the places<br>
&lt;heycam> fantasai: I'm not arguing with you on this point<br>
&lt;heycam> ... if you're going to allow the syntax in @supports, then you must check all of it<br>
&lt;heycam> ... if you don't want that, don't allow it in the syntax<br>
&lt;fantasai> astearns: So proposed resolution is allow @rule preludes in the syntax, and check them for validity<br>
&lt;fantasai> fremy: You have at-rule in the prelude, what if at-rule is only valid inside another at-rule?<br>
&lt;fantasai> TabAtkins: This should still be fine, you won't be able to do any parent-child checking<br>
&lt;fantasai> TabAtkins: but this sub-atrule gets parsed somehow<br>
&lt;fantasai> TabAtkins: only problem is if you have two different at-rules that have different children with different names<br>
&lt;TabAtkins> s/different name/same names/<br>
&lt;astearns> ack fantasai<br>
&lt;heycam> fantasai: if I say @at-rule(@media foo), will that parse as supporting querying against foo?<br>
&lt;heycam> ... that's not going to cause the media rule to be invalidate, I'm asking whether you support that media rule<br>
&lt;florian> q+<br>
&lt;heycam> ... if it's going to return true for anything that appears after @media, that's not useful<br>
&lt;heycam> TabAtkins: [missed]<br>
&lt;fantasai> s/useful/useful, and it is confusing and unexpected to the author/<br>
&lt;fantasai> emilio: We have custom parsing for unforgiving selectors, right?<br>
&lt;fantasai> TabAtkins: Still, I suspect that this is a distinctly different thing because switching between selector lists isn't straightforward<br>
&lt;fantasai> emilio: but there is some amount of precedent, not that I love it<br>
&lt;fantasai> florian: for fantasai's example about media queries, it's undecideable<br>
&lt;fantasai> florian: because, telling the difference between whether you support querying whether running on 3D printer vs asking, you can't distinguish as an author<br>
&lt;heycam> fantasai: let's take a better example<br>
&lt;fantasai> florian: you'll get a "no", which is the correct answer<br>
&lt;fantasai> fantasai: consider the touchscreen MQ<br>
&lt;heycam> ... if the author asks do you support querying whether this is a touchscreen, and you say sure, I support every media query ever<br>
&lt;heycam> ... then the author will assume you support the media query<br>
&lt;heycam> TabAtkins: they'll get a no when they actually use the MQ<br>
&lt;heycam> fantasai: maybe they want to figure out some other heuristics?<br>
&lt;heycam> ... maybe I'll change my layout if you don't support this MQ, and cannot know from the MQ whether you support a touchscreen<br>
&lt;heycam> ... but you don't have the ability to check that<br>
&lt;heycam> ... not saying you necessarily don't need this feature, I am saying if you put it in an @supports query, the author will reasonably expect the browser will check if it understands that MQ, and we should not violate that expectation<br>
&lt;fantasai> TabAtkins: Anything that requires custom parsing<br>
&lt;fantasai> fantasai: then don't allow it<br>
&lt;fantasai> TabAtkins: either you can never test for preludes, or for some extremely forgiving syntaxes, this query is not going to be maximally useful<br>
&lt;fantasai> TabAtkins: and we can introduce a new query later<br>
&lt;fantasai> TabAtkins: either we don't allow preludes at all, or we accept that @media is confusing<br>
&lt;TabAtkins> TabAtkins: And we fix it in the future with a `media-feature()` query<br>
&lt;fantasai> astearns: Is that going to be acceptable, to allow testing for preludes with this possibly workaroundable thing?<br>
&lt;fantasai> fantasai: depends what other people think? I'm only one member of this WG<br>
&lt;fantasai> miriam: I agree with both of you.<br>
&lt;fantasai> miriam: so that's helpful!<br>
&lt;fantasai> florian: I'm lost about the overall discussion, but I think @supports testing of media queries is not useful given current form of media query<br>
&lt;heycam> fantasai: how forgiving is parsing on CQs?<br>
&lt;fantasai> miriam: So the problem is specific to media queries, we don't have the problem with container queries right?<br>
&lt;fantasai> emilio: it's same<br>
&lt;fantasai> emilio: also have same problem with @supports itself<br>
&lt;fantasai> florian: well people won't use @supports @supports<br>
&lt;fantasai> florian: nobody will do that one so it doesn't matter<br>
&lt;TabAtkins> Anything with `&lt;general-enclosed>` in the grammar is forgiving in this way, and won't be good to test.<br>
&lt;fantasai> miriam: People do wwant to know whether @supports of selectors works<br>
&lt;fantasai> TabAtkins, yeah, but authors can't figure that out<br>
&lt;fantasai> TabAtkins, it's totally opaque to them<br>
&lt;TabAtkins> yeah, i'm just answering the question<br>
&lt;fantasai> miriam: SO what's the solution that gets us there?<br>
&lt;fantasai> florian: MQ was designed to work around the problem. When browser doesn't know how to answer it doesn't know how<br>
&lt;fantasai> florian: [...]<br>
&lt;fantasai> fremy: You can design the query so you get the support you want<br>
&lt;fantasai> florian: if you want a third design where you don't know whether your design can over, this is tricky<br>
&lt;fantasai> TabAtkins: we can let author ssolve that with custom MQ<br>
&lt;fantasai> TabAtkins: because that's what they do today<br>
&lt;fantasai> miriam: Does @else help? Means you can just attach a negation to the query itself<br>
&lt;florian> s/design can over/design can hover/<br>
&lt;fantasai> TabAtkins: top-level query is alwasy true or false, unknown is not a response<br>
&lt;fantasai> emilio: For @media, can't you do that? Ask for a logical combination of your query and not your query<br>
&lt;fantasai> emilio: e.g. @media hover and not hover, and that should be true on all browsers that support hover and not on ones that don't<br>
&lt;fantasai> emilio: I mean 'or'<br>
&lt;fantasai> emilio: so can do that with CSS already, though not beautiful<br>
&lt;TabAtkins> (true or false) is true, (unknown or unknown) is unknown (and thus false)<br>
&lt;TabAtkins> so yeah that works<br>
&lt;fantasai> florian: for media features yes, but not media types<br>
&lt;fantasai> TabAtkins: I think we have multiple ways to address the media being restrictive<br>
&lt;fantasai> TabAtkins: I would be very sad if, though we have ways to address it, we lost ability to do anything else that doesn't have forgiving this nature<br>
&lt;fantasai> TabAtkins: fantasai, can you let us do this as specified, if other feautres can let you figure out media queries<br>
&lt;heycam> fantasai: I can live with it, but I really do want to hear from others in the room<br>
&lt;fantasai> astearns: Proposed resolution is to allow testing of at-rule preludes in supports, using the prelud syntax and no nesting as yet<br>
&lt;fantasai> florian: I suggest we include a note that things that have forgiving parsing will say yes, and it doesn't mean that they are support<br>
&lt;heycam> fantasai: I think it will confuse a lot of people, but I understand we do want to do this for other things for which it does make sense<br>
&lt;heycam> ... my concern for CQs is that if we have to invent a new function for say state queries, they'll ask if that's supported, and we'll say yes<br>
&lt;fantasai> miriam: This doesn't work for the things I want it to work for<br>
&lt;emeyer> q+<br>
&lt;fantasai> miriam: and I agree it'll confuse people<br>
&lt;florian> q-<br>
&lt;astearns> ack florian<br>
&lt;fantasai> miriam: I wonder if we can restrict it to just the things that it's useful for?<br>
&lt;fantasai> TabAtkins: we could maybe do that, say it doesn't do anything on @media/@supports/@container<br>
&lt;astearns> ack emeyer<br>
&lt;fantasai> emeyer: I think Tab addressed my concern.<br>
&lt;fantasai> emeyer: I'm concerned we're starting to cross into territory.... I agree with Elika's point that this will be confusing in these cases<br>
&lt;fantasai> emeyer: if we restrict from those cases, then it's ok with me<br>
&lt;fantasai> emeyer: @supports is already a bit confusing, e.g. @supports (text-decoration: blink)<br>
&lt;fantasai> emeyer: I was concerned that we would introduce a class of problems that authors would be *much* more confused about<br>
&lt;fantasai> emeyer: but I believe the syntax restrictions would address my concerns<br>
&lt;fantasai> astearns: what would it address?<br>
&lt;heycam> fantasai: anything with forgiving syntax<br>
&lt;fantasai> TabAtkins: we have 27 at-rules ...<br>
&lt;fantasai> florian: Anything with &lt;general-enclosed><br>
&lt;TabAtkins> s/27/20-something/<br>
&lt;fantasai> florian: Alternative is if you hit &lt;general-enclosed>, return false<br>
&lt;fantasai> TabAtkins: that's specialized parsing<br>
&lt;fantasai> heycam: so it's that the condition, if you use an at-rule(@media ...) it's not invalid, it's just false?<br>
&lt;fantasai> florian: would prefer invalid, so if we figure out how to solve we can make it work<br>
&lt;fantasai> astearns: I've lost state of proposed resolution<br>
&lt;TabAtkins> Proposed resolution: allow testing at-rule preludes. Exclude @media, @supports, and @container from this form fo the test; they're invalid to use.<br>
&lt;TabAtkins> (Generally, anything using &lt;general-enclosed>, but for now it's those three.)<br>
&lt;fantasai> florian: Can you clarify, they're invalid, does that mean they return false or they fail to parse?<br>
&lt;fantasai> TabAtkins: they make the rule invalid<br>
&lt;fantasai> florian: what do you mean by "the rule"<br>
&lt;heycam> fantasai: it's as if you wrote foobar() instead of at-rule()<br>
&lt;heycam> TabAtkins: foobar() is a false query<br>
&lt;fantasai> astearns: We will work out what the remaining proposal is in the future for specific syntax and behavior in a summary ocomment form TabAtkins<br>
&lt;fantasai> TabAtkins: I gave the proposed resolution, ignoring that bit about clarifying invalid<br>
&lt;fantasai> astearns: Let's get it written out, and then come back to it<br>
&lt;fantasai> astearns: because I've had several ppl ask that we get to Toggles!<br>
&lt;florian> "@support at-rule(@media foo) or (display:block) { :root{ color: blue ) }" What does that do, blue or not blue?<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6966#issuecomment-1249825224 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 16 September 2022 21:18:16 UTC