@@ -77,6 +77,17 @@ Value Definition Syntax</h2>
7777
7878 See [[css-values-4#value-defs]] .
7979
80+ Additionally,
81+
82+ <ol>
83+ <li value=5> Boolean combinations of a conditional notation.
84+ These are written using the <<boolean [ <test> ]>> notation,
85+ and represent recursive expressions of boolean logic
86+ using keywords and parentheses,
87+ applied to the type specified in brackets,
88+ e.g. <<boolean [ ( <media-feature> ) ]>> to express [=media queries=] .
89+ </ol>
90+
8091<h3 id=component-functions>
8192Functional Notation Definitions</h3>
8293
@@ -201,6 +212,62 @@ Commas in Function Arguments</h4>
201212 Other contexts <em> may</em> define that they use [=non-strict comma-containing productions=] ,
202213 but it <em> should</em> be avoided unless necessary.
203214
215+ <h3 id=boolean>
216+ Boolean Expression Multiplier <<boolean>></h3>
217+
218+ Several contexts
219+ (such as ''@media'' , ''@supports'' , ''if()'' , ...)
220+ specify conditions,
221+ and allow combining those conditions with boolean logic (and/or/not/grouping).
222+ Because they use the same non-trivial recursive syntax structure,
223+ the special <dfn><<boolean>></dfn> production represents this pattern generically.
224+
225+ The <<boolean>> notation wraps another value type in the square brackets within it,
226+ e.g. <boolean [ <test> ] >,
227+ and represents that value alone as well as
228+ boolean combinations of those values
229+ using the ''not'' , ''and'' , and ''or'' keywords
230+ and grouping parenthesis.
231+ It is formally equivalent to:
232+
233+ <xmp class=prod>
234+ <boolean [ <test> ]> = not <boolean-group> | <boolean-group>
235+ [ [ and <boolean-group> ] *
236+ | [ or <boolean-group> ] * ]
237+
238+ <boolean-group> = <test> | ( <boolean> ) | <general-enclosed>
239+ </xmp>
240+
241+ The <<boolean>> production represents a true, false, or unknown value,
242+ with top-level unknown values
243+ (those not directly nested inside the grammar of another <<boolean>> )
244+ resolving to false unless otherwise specified.
245+ Its value is resolved using 3-value Kleene logic;
246+ see [[#boolean-logic]] for details.
247+
248+ <div class=example>
249+ For example, the ''@container'' rule allows a wide variety of tests:
250+ including size queries, style queries, and scroll-state queries.
251+ All of these are arbitrarily combinable with boolean logic.
252+ Using <<boolean>> , the grammar for an ''@container'' query is:
253+
254+ <xmp class=prod>
255+ <container-query> = <boolean [ <cq-test> ]>
256+ <cq-test> = (<size-query> ) | style( <style-query> ) | scroll-state( <scroll-state-query> )
257+ <size-query> = <boolean [ ( <size-feature> ) ]> | <size-feature>
258+ <style-query> = <boolean [ ( <style-feature> ) ]> | <style-feature>
259+ <scroll-state-query> = <boolean [ ( <scroll-state-feature> ) ]> | <scroll-state-feature>
260+ </xmp>
261+ </div>
262+
263+ The <<general-enclosed>> branch of the logic allows for future compatibility--
264+ unless otherwise specified new expressions in an older UA
265+ will be parsed and considered “unknown”,
266+ rather than invalidating the production.
267+ For consistency with that allowance,
268+ the <css> <test></css> term in a <<boolean>>
269+ should be defined to match <<general-enclosed>> .
270+
204271<h3 id=css-syntax>
205272Specifying CSS Syntax in CSS: the <<syntax>> type</h3>
206273
@@ -3070,6 +3137,48 @@ Safely Handling Overly-Long Substitution</h3>
30703137 and the fact that it can be done without any of the pieces
30713138 <em> seeming</em> to be too large on first inspection.
30723139
3140+ <h2 id="boolean-logic">
3141+ Appendix B: Boolean Logic</h2>
3142+
3143+ In order to accommodate future extensions of CSS,
3144+ <<boolean>> productions generally interpret their <<general-enclosed>> grammar branch as unknown,
3145+ and their boolean logic is resolved using 3-value Kleene logic.
3146+ In some cases (such as ''@supports'' ),
3147+ <<general-enclosed>> is instead defined as false;
3148+ in which case the logic devolves to standard boolean algebra.
3149+
3150+ 3-value boolean logic is applied recursively
3151+ to a boolean condition |test| as follows:
3152+
3153+ * A leaf-level |test| resolves to
3154+ true, false, or unknown,
3155+ as defined by the relevant specification.
3156+
3157+ * ''not |test|'' evaluates to
3158+ true if its contained |test| is false,
3159+ false if it's true,
3160+ and unknown if it's unknown.
3161+
3162+ * Multiple |test|s connected with ''and'' evaluate to
3163+ true if <em> all</em> of those |test|s are true,
3164+ false if <em> any</em> of them are false,
3165+ and unknown otherwise (i.e. if at least one unknown, but no false).
3166+
3167+ * Multiple |test|s connected with ''or'' evaluate to
3168+ true if <em> any</em> of those |test|s are true,
3169+ false if <em> all</em> of them are false,
3170+ and unknown otherwise (i.e. at least one unknown, but no true).
3171+
3172+ If a “top-level” <<boolean>> is unknown,
3173+ and the containing context doesn't otherwise define
3174+ how to handle unknown conditions,
3175+ it evaluates to false.
3176+
3177+ Note: That is, unknown doesn't “escape” a 3-value boolean expression
3178+ unless explicitly handled,
3179+ similar to how <code> NaN</code> doesn't “escape” a [=top-level calculation=] ).
3180+
3181+
30733182<!-- Big Text: etc
30743183
30753184█████▌ █████▌ ███▌
0 commit comments