Skip to content

Commit b05a1cb

Browse files
committed
[css-conditional-values-1] Fix Bikeshed errors
1 parent ae415de commit b05a1cb

File tree

1 file changed

+50
-20
lines changed

1 file changed

+50
-20
lines changed

css-conditional-values/Overview.bs

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,57 @@ Boolean constants: ''true'' and ''false'' {#bool-constants}
5252
<dfn export>&lt;boolean-constant></dfn> = <dfn export>'true'</dfn> | <dfn export>'false'</dfn>
5353
</pre>
5454

55-
Logical comparisons: The <<condition>> type
55+
Logical comparisons: The <<condition>> type {#condition}
5656
---------------------------------------------
5757

5858
<pre class="prod def" nohighlight>
59-
<dfn export>&lt;condition></dfn> = not <<condition-in-parens>>
59+
<dfn>&lt;condition></dfn> = not <<condition-in-parens>>
6060
| <<condition-in-parens>> [ and <<condition-in-parens>> ]*
6161
| <<condition-in-parens>> [ or <<condition-in-parens>> ]*
62-
<dfn export>&lt;condition-in-parens></dfn> = ( <<condition>> ) | <<atomic-condition>>
63-
<dfn export>&lt;atomic-condition></dfn> = <<comparison-operand>> <<comparison-operator>> <<comparison-operand>> | <<boolean-constant>>
64-
<dfn export>&lt;comparison-operand></dfn> = <<dimension>> | <<number>> | <<percentage>> | <<ident>>
62+
<dfn>&lt;condition-in-parens></dfn> = ( <<condition>> ) | <<atomic-condition>>
63+
<dfn>&lt;atomic-condition></dfn> = <<comparison-operand>> <<comparison-operator>> <<comparison-operand>> | <<boolean-constant>>
64+
<dfn>&lt;comparison-operand></dfn> = <<dimension>> | <<number>> | <<percentage>> | <<ident>>
6565
<dfn>&lt;comparison-operator></dfn> = [ '=' | '>=' | '>' | '<' | '<=' ]
6666
</pre>
6767

6868
<<condition>> values are logical expressions that resolve to a <<boolean-constant>>
6969
by performing simple comparisons and following basic boolean operators.
70-
When using 'and' or 'or' operators, precedence must be enforced with parentheses.
71-
The ''not'' operator does not require this, and has higher precedence than ''and'' and ''or''.
70+
When using `and` or `or` operators, precedence must be enforced with parentheses.
71+
The `not` operator does not require this, and has higher precedence than `and` and `or`.
7272

73-
Both <<comparison-operand>> values in <<atomic-condition>> need to be of the same type. If they are not, the entire condition becomes an
74-
<dfn export>invalid condition</dfn> and evaluates as 'false'.
73+
Each of these grammar terms is associated with a boolean result,
74+
as follows:
7575

76-
Issue: Do we need a third, "invalid" state here?
76+
: <<condition>>
77+
: <<condition-in-parens>>
78+
:: The result is the result of the child subexpression.
79+
80+
: not <<condition-in-parens>>
81+
:: The result is the negation of the <<condition-in-parens>> term.
82+
The negation of unknown is unknown.
83+
84+
: <<condition-in-parens>> [ and <<condition-in-parens>> ]*
85+
::
86+
The result is true if all of the <<condition-in-parens>> child terms are true,
87+
false if at least one of the <<condition-in-parens>> is false,
88+
and unknown otherwise.
89+
90+
: <<condition-in-parens>> [ or <<condition-in-parens>> ]*
91+
::
92+
The result is false if all of the <<condition-in-parens>> child terms are false,
93+
true if at least one of the <<condition-in-parens>> is true,
94+
and unknown otherwise.
95+
96+
These rules are consistent with the way conditions are resolved in [[css-conditional-3]].
97+
98+
Issue: Together with this, there are currently 3 specs
99+
([[css-conditional-3]], [[mediaqueries-4]]) using boolean operators,
100+
and two defining how they work ([[css-conditional-3]] and this).
101+
Ideally, this should be defined in one place, and cited everywhere else.
102+
103+
Both <<comparison-operand>> values in <<atomic-condition>> need to be of the same type.
104+
If they are not, the entire condition becomes an
105+
<dfn export>invalid condition</dfn> and evaluates to unknown.
77106

78107
These operations are only defined on <a>computed values</a>.
79108
(As a result, it is not necessary to define, for example,
@@ -91,14 +120,12 @@ these relative values resolve in the same way as regular values in the declarati
91120

92121
Note: Why are we using ''='' for equality and not ':' as is established in [[css-conditional-4]] already?
93122
Because a lot of third party code (syntax highlighters etc) assumes that colons separate declarations and would break.
94-
Also, ''foo: bar'' establishes a key-value pair,
123+
Also, `foo: bar` establishes a key-value pair,
95124
whereas in equality comparisons the two operands are of equal weight,
96125
and do not establish a key-value pair.
97126

98127
Issue: Do we need a "not equals" operator or is 'not(op1 = op2)' sufficient?
99128

100-
Issue: How low level should this be? Do we need to define how logical operators work?
101-
102129
The <<condition>> is resolved at computed value time, though its calculation tree may be simplified earlier.
103130

104131
<div class=example>
@@ -112,7 +139,7 @@ The <<condition>> is resolved at computed value time, though its calculation tre
112139
Computed Value</h4>
113140

114141
The [=computed value=] of a <<condition>> value
115-
is its [=calculation tree=] [=simplified=],
142+
is its [=calculation tree=] simplified,
116143
using all the information available at [=computed value=] time.
117144
(Such as the ''em'' to ''px'' ratio,
118145
how to resolve percentages etc.)
@@ -126,16 +153,17 @@ a <<condition>> always simplifies down to a single <<boolean-constant>>.
126153

127154
Issue: Define these concepts for comparisons (currently they point to calc())
128155

129-
Inline conditionals: The ''if()'' function
156+
Inline conditionals: The ''if()'' function {#if}
130157
===========================================
131158

132-
The ''if()'' function allows authors to set a property value (or parts thereof)
159+
The <dfn>if()</dfn> function allows authors to set a property value (or parts thereof)
133160
to different values based on certain conditions.
134161

135162
<pre class="prod def">
136-
<<if()>> = if( <<condition>>, <<consequent>> [, <<antecedent>>]?)
137-
<<consequent>> = <<declaration-value>>
138-
<<antecedent>> = <<declaration-value>>
163+
164+
<<if()>> = if( <<condition>>, <<consequent>> [, <<antecedent>>]?)
165+
<dfn>&lt;consequent></dfn> = <<declaration-value>>
166+
<dfn>&lt;antecedent></dfn> = <<declaration-value>>
139167
</pre>
140168

141169
Issue: How can authors specify consequents or antecedents that include commas?
@@ -148,7 +176,7 @@ Alternative syntax that adresses this, though may be hard to read when consequen
148176
</pre>
149177

150178
<div class=example>
151-
Authors can write mini media queries by comparing viewport and absolute units:
179+
Authors can write inline media queries by comparing viewport and absolute units:
152180

153181
<pre>flex-flow: if(100vw > 500px, row, column);</pre>
154182
</div>
@@ -183,6 +211,8 @@ as the ''var()'' function, for the same reasons.
183211
Issue: How to disambiguate when used in a place where arguments are disambiguated by type?
184212
Unlike ''var()'', this cannot just be resolved at substitution,
185213
because we need to be able to interpret the values to compute the condition and perform the substitution accordingly.
214+
One way to address this would be to mandate that both <<consequent>> and <<antecedent>> need to be of the same type.
215+
How much does that limit use cases?
186216

187217
Privacy and Security Considerations {#priv-sec}
188218
===============================================

0 commit comments

Comments
 (0)