Skip to content

Commit

Permalink
[css-values-5] Replace <boolean[]> with <boolean-expr[]> #10457
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasai committed Nov 11, 2024
1 parent e4e057c commit 487ba2b
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions css-values-5/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ Value Definition Syntax</h2>

<ol>
<li value=5>Boolean combinations of a conditional notation.
These are written using the <<boolean[]>> notation,
These are written using the <<boolean-expr[]>> notation,
and represent recursive expressions of boolean logic
using keywords and parentheses,
applied to the grammar specified in brackets,
e.g. <<boolean[ ( &lt;media-feature&gt; ) ]>> to express [=media queries=].
e.g. <<boolean-expr[ ( &lt;media-feature&gt; ) ]>> to express [=media queries=].
</ol>

<h3 id=component-functions>
Expand Down Expand Up @@ -213,16 +213,16 @@ Commas in Function Arguments</h4>
but it <em>should</em> be avoided unless necessary.

<h3 id=boolean>
Boolean Expression Multiplier <<boolean[]>></h3>
Boolean Expression Multiplier <<boolean-expr[]>></h3>

Several contexts
(such as ''@media'', ''@supports'', ''if()'', ...)
specify conditions,
and allow combining those conditions with boolean logic (and/or/not/grouping).
Because they use the same non-trivial recursive syntax structure,
the special <dfn><<boolean[]>></dfn> production represents this pattern generically.
the special <dfn><<boolean-expr[]>></dfn> production represents this pattern generically.

The <<boolean[]>> notation wraps another value type in the square brackets within it,
The <<boolean-expr[]>> notation wraps another value type in the square brackets within it,
e.g. &lt;boolean[ &lt;test&gt; ]&gt;,
and represents that value type alone as well as
boolean combinations
Expand All @@ -231,33 +231,33 @@ Boolean Expression Multiplier <<boolean[]>></h3>
It is formally equivalent to:

<xmp class=prod>
<boolean[ <test> ]> = not <boolean-group> | <boolean-group>
[ [ and <boolean-group> ]*
| [ or <boolean-group> ]* ]
<boolean-expr[ <test> ]> = not <boolean-expr-group> | <boolean-expr-group>
[ [ and <boolean-expr-group> ]*
| [ or <boolean-expr-group> ]* ]

<boolean-group> = <test> | ( <boolean[ <test> ]> ) | <general-enclosed>
<boolean-expr-group> = <test> | ( <boolean-expr[ <test> ]> ) | <general-enclosed>
</xmp>

The <<boolean[]>> production represents a true, false, or unknown value.
The <<boolean-expr[]>> production represents a true, false, or unknown value.
Its value is resolved using 3-value Kleene logic,
with top-level unknown values
(those not directly nested inside the grammar of another <<boolean[]>>)
(those not directly nested inside the grammar of another <<boolean-expr[]>>)
resolving to false unless otherwise specified;
see [[#boolean-logic]] for details.

<div class=example>
For example, the ''@container'' rule allows a wide variety of tests:
including size queries, style queries, and scroll-state queries.
All of these are arbitrarily combinable with boolean logic.
Using <<boolean[]>>, the grammar for an ''@container'' query
Using <<boolean-expr[]>>, the grammar for an ''@container'' query
could be written as:

<xmp class=prod>
<container-query> = <boolean[ <cq-test> ]>
<container-query> = <boolean-expr[ <cq-test> ]>
<cq-test> = (<size-query>) | style( <style-query> ) | scroll-state( <scroll-state-query> )
<size-query> = <boolean[ ( <size-feature> ) ]> | <size-feature>
<style-query> = <boolean[ ( <style-feature> ) ]> | <style-feature>
<scroll-state-query> = <boolean[ ( <scroll-state-feature> ) ]> | <scroll-state-feature>
<size-query> = <boolean-expr[ ( <size-feature> ) ]> | <size-feature>
<style-query> = <boolean-expr[ ( <style-feature> ) ]> | <style-feature>
<scroll-state-query> = <boolean-expr[ ( <scroll-state-feature> ) ]> | <scroll-state-feature>
</xmp>
</div>

Expand All @@ -266,7 +266,7 @@ Boolean Expression Multiplier <<boolean[]>></h3>
will be parsed and considered “unknown”,
rather than invalidating the production.
For consistency with that allowance,
the <css>&lt;test></css> term in a <<boolean[]>>
the <css>&lt;test></css> term in a <<boolean-expr[]>>
should be defined to match <<general-enclosed>>.

<h3 id=css-syntax>
Expand Down Expand Up @@ -1342,7 +1342,7 @@ Conditional Value Selection: the ''if()'' notation</h3>
<pre class=prod>
<dfn><<if()>></dfn> = if( [ <<if-condition>> : <<declaration-value>>? ; ]*
<<if-condition>> : <<declaration-value>>? ;? )
<dfn><<if-condition>></dfn> = <<boolean[ <<if-test>> ]>> | else
<dfn><<if-condition>></dfn> = <<boolean-expr[ <<if-test>> ]>> | else
<dfn><<if-test>></dfn> =
supports( [ <<supports-condition>> | <<ident>> : <<declaration-value>> ] ) |
media( <<media-query>> ) |
Expand Down Expand Up @@ -3192,7 +3192,7 @@ Safely Handling Overly-Long Substitution</h3>
Appendix B: Boolean Logic</h2>

In order to accommodate future extensions of CSS,
<<boolean[]>> productions generally interpret their <<general-enclosed>> grammar branch as unknown,
<<boolean-expr[]>> productions generally interpret their <<general-enclosed>> grammar branch as unknown,
and their boolean logic is resolved using 3-value Kleene logic.
In some cases (such as ''@supports''),
<<general-enclosed>> is instead defined as false;
Expand Down Expand Up @@ -3220,7 +3220,7 @@ Appendix B: Boolean Logic</h2>
false if <em>all</em> of them are false,
and unknown otherwise (i.e. at least one unknown, but no true).

If a “top-level” <<boolean[]>> is unknown,
If a “top-level” <<boolean-expr[]>> is unknown,
and the containing context doesn't otherwise define
how to handle unknown conditions,
it evaluates to false.
Expand Down Expand Up @@ -3276,7 +3276,7 @@ Changes</h2>
* Changed ''*progress()'' functions to use commas for argument separation,
for consistency with ''*mix()'' and ''clamp()''.
(<a href="https://github.com/w3c/csswg-drafts/issues/10489">Issue 10489</a>)
* Defined new <<boolean[]>> multipler for the [=value definition syntax=].
* Defined new <<boolean-expr[]>> multipler for the [=value definition syntax=].
(<a href="https://github.com/w3c/csswg-drafts/issues/10457">Issue 10457</a>)
* Imported definition of [=arbitrary substitution function=] from [[css-variables-1]].
(<a href="https://github.com/w3c/csswg-drafts/issues/10679">Issue 10679</a>)
Expand Down Expand Up @@ -3307,7 +3307,7 @@ Additions Since Level 4</h3>
* Added the ''random()'' and ''random-item()'' functions.
* Added the ''sibling-count()'' and ''sibling-index()'' functions.
* Added the ''calc-size()'' function, and the related 'interpolate-size' property.
* Added the <<boolean[]>> syntax notation to the [=value definition syntax=].
* Added the <<boolean-expr[]>> syntax notation to the [=value definition syntax=].


<h2 class="no-num" id="security">
Expand Down

0 comments on commit 487ba2b

Please sign in to comment.