@@ -5345,6 +5345,101 @@ Appendix A: Recommended Minimum Ranges and Precision of Computed Values</h2>
53455345-->
53465346
53475347
5348+ <!-- Big Text: bools -->
5349+
5350+ <h2 id="bools">
5351+ Boolean Expressions</h2>
5352+
5353+ In several contexts, CSS allows certain boolean tests
5354+ (things that can evaluate to true or false),
5355+ and allows them to be combined with the logical operators
5356+ AND, OR, and NOT to form more complicated boolean tests.
5357+ (For example, ''@media'' or ''@supports'' rules.)
5358+
5359+ All of these locations share a common grammatical structure,
5360+ with the only difference being what "base" boolean tests
5361+ are allowed,
5362+ and whether they use simple 2-value (true/false) boolean algebra,
5363+ or 3-value (true/false/unknown) Kleene logic.
5364+
5365+ For example, in ''@media'' only <<media-condition>> s are allowed,
5366+ with Kleene logic;
5367+ in ''@supports'' only <<supports-condition>> s are allowed,
5368+ with boolean logic.
5369+
5370+ As the overall structure of these grammars is identical
5371+ across the various usages of it,
5372+ and also complex enough to be non-trivial to reproduce
5373+ (and easy to accidentally do wrong),
5374+ this specification defines <<boolean>> ,
5375+ a generic grammar for all such boolean tests.
5376+
5377+ <pre class=prod>
5378+ <dfn><boolean></dfn> = <<bool-not>> | <<bool-in-parens>> [ <<bool-and>> * | <<bool-or>> * ]
5379+ <dfn><boolean-without-or></dfn> = <<bool-not>> | <<bool-in-parens>> <<bool-and>> *
5380+ <dfn><bool-not></dfn> = not <<bool-in-parens>>
5381+ <dfn><bool-and></dfn> = and <<bool-in-parens>>
5382+ <dfn><bool-or></dfn> = or <<bool-in-parens>>
5383+ <dfn><bool-in-parens></dfn> = ( <<boolean>> ) | <<bool-test>> | <<general-enclosed>>
5384+
5385+ <dfn><general-enclosed></dfn> = [ <<function-token>> <<any-value>> ? ) ] | [ ( <<any-value>> ? ) ]
5386+ </pre>
5387+
5388+ Each specification using <<boolean>>
5389+ must define what things are valid as <dfn><bool-test></dfn> values
5390+ in that context,
5391+ and whether it uses 2-value or 3-value logic.
5392+ As well, <<bool-test>> values
5393+ <em> should</em> either be wrapped in parentheses
5394+ or be functions;
5395+ if a specification needs to express some conditions in a different way,
5396+ please contact the CSSWG for review.
5397+
5398+ : If using 2-value logic
5399+ ::
5400+ * Every <<bool-test>> must be defined to evaluate to either true or false.
5401+ * <<general-enclosed>> evaluates to false.
5402+ * <<bool-in-parens>> evaluates to the value of its contained <<boolean>> , <<bool-test>> , or <<general-enclosed>>
5403+ * <<bool-not>> evaluates to true if its contained <<bool-in-parens>> is false,
5404+ and false otherwise.
5405+ * A <<boolean>> with only a <<bool-not>> or <<bool-in-parens>> evaluates to that.
5406+ * A <<boolean>> with multiple <<bool-in-parens>> connected with ''and''
5407+ evaluates to true if all of its <<bool-in-parens>> are true,
5408+ and false otherwise.
5409+ * A <<boolean>> with multiple <<bool-in-parens>> connected with ''or''
5410+ evaluates to true if any of its <<bool-in-parens>> are true,
5411+ and false otherwise.
5412+
5413+ : If using 3-value logic
5414+ ::
5415+ * Every <<bool-test>> must be defined to evaluate to either true, false, or unknown.
5416+ * <<general-enclosed>> evaluates to unknown.
5417+ * <<bool-in-parens>> evaluates to the value of its contained <<boolean>> , <<bool-test>> , or <<general-enclosed>>
5418+ * <<bool-not>> evaluates to true if its contained <<bool-in-parens>> is false,
5419+ false if it's true,
5420+ and unknown if it's unknown.
5421+ * A <<boolean>> with only a <<bool-not>> or <<bool-in-parens>> evaluates to that.
5422+ * A <<boolean>> with multiple <<bool-in-parens>> connected with ''and''
5423+ evaluates to true if all of its <<bool-in-parens>> are true,
5424+ false if any of them are false,
5425+ and unknown otherwise
5426+ (at least one unknown, but no false).
5427+ * A <<boolean>> with multiple <<bool-in-parens>> connected with ''or''
5428+ evaluates to true if any of its <<bool-in-parens>> are true,
5429+ false if all of them are false,
5430+ and unknown otherwise
5431+ (at least one unknown, but no true).
5432+ * If a "top-level" <<boolean>> is unknown,
5433+ and the containing context uses 2-value logic
5434+ (or doesn't specify otherwise),
5435+ it instead evaluates to false.
5436+
5437+ Note: That is, unknown doesn't "escape" a 3-value expression,
5438+ similar to how NaN doesn't "escape" a [=top-level calculation=] ).
5439+
5440+
5441+
5442+
53485443<!-- Big Text: lists
53495444
53505445█▌ ████ ███▌ █████▌ ███▌
0 commit comments