Skip to content

Commit db3e423

Browse files
tursunovatabatkins
andauthored
[css-conditional-5] Define a range syntax for style container queries (#12401)
* [css-conditional-5] Define a range syntax for style container queries * Apply sembr and cleanup * Update css-conditional-5/Overview.bs --------- Co-authored-by: Tab Atkins Jr. <[email protected]>
1 parent 0c5a768 commit db3e423

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

css-conditional-5/Overview.bs

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,13 @@ Container Queries: the ''@container'' rule</h3>
945945
<dfn><<style-in-parens>></dfn> = ( <<style-query>> )
946946
| ( <<style-feature>> )
947947
| <<general-enclosed>>
948+
<dfn><<style-feature>></dfn> = <<style-feature-plain>> | <<style-feature-boolean>> | <<style-range>>
949+
<dfn><<style-feature-plain>></dfn> = <<style-feature-name>> : <<style-feature-value>>
950+
<dfn><<style-feature-boolean>></dfn> = <<style-feature-name>>
951+
<dfn><<style-range>></dfn> = <<style-range-value>> <<mf-comparison>> <<style-range-value>>
952+
| <<style-range-value>> <<mf-lt>> <<style-range-value>> <<mf-lt>> <<style-range-value>>
953+
| <<style-range-value>> <<mf-gt>> <<style-range-value>> <<mf-gt>> <<style-range-value>>
954+
<dfn><<style-range-value>></dfn> = <<custom-property-name>> | <<style-feature-value>>
948955
949956
<dfn><<scroll-state-query>></dfn> = not <<scroll-state-in-parens>>
950957
| <<scroll-state-in-parens>> [ [ and <<scroll-state-in-parens>> ]* | [ or <<scroll-state-in-parens>> ]* ]
@@ -1323,21 +1330,45 @@ Orientation: the '@container/orientation' feature</h4>
13231330
<h3 id="style-container">
13241331
Style Container Features</h3>
13251332

1326-
A <dfn export>container style query</dfn>
1327-
allows querying
1333+
A <dfn export>container style query</dfn> allows querying
13281334
the [=computed values=] of the [=query container=].
1329-
It is a boolean combination of
1330-
individual <dfn>style features</dfn> (<<style-feature>>)
1331-
that each query a single, specific property of the [=query container=].
1332-
The syntax of a <dfn><<style-feature>></dfn> is either the same as for a valid [=declaration=]
1333-
[[!CSS-SYNTAX-3]], a [=supported CSS property=], or a <<custom-property-name>>.
1334-
1335-
Its query evaluates to true if the [=computed value=] of the given property on the
1336-
[=query container=] matches the given value (which is also [=computed value|computed=]
1337-
with respect to the [=query container=]), and false otherwise.
1335+
It is a boolean combination of individual <dfn>style features</dfn>
1336+
(<<style-feature>>) that each query a single, specific property of the [=query container=].
1337+
The syntax of a <<style-feature>>
1338+
is either the same as for a valid [=declaration=][[!CSS-SYNTAX-3]],
1339+
a <<style-feature-name>>
1340+
or a valid <dfn>style range</dfn>(<<style-range>>).
1341+
The <dfn><<style-feature-name>></dfn> can be either a [=supported CSS property=]
1342+
or a valid <<custom-property-name>>.
1343+
The <dfn><<style-feature-value>></dfn> production matches any valid <<declaration-value>>
1344+
as long as it doesn't contain <<mf-lt>>, <<mf-gt>> and <<mf-eq>> tokens.
1345+
1346+
A <<style-feature-plain>> evaluates to true
1347+
if the [=computed value=] of the given property
1348+
on the [=query container=] matches the given value
1349+
(which is also [=computed value|computed=] with respect to the [=query container=]),
1350+
and false otherwise.
13381351

1339-
A [=style feature=] without a value evaluates to true if the [=computed value=]
1340-
is different from the [=initial value=] for the given [=property=].
1352+
A [=style feature=] without a value (<<style-feature-boolean>>) evaluates to true
1353+
if the [=computed value=] is different
1354+
from the [=initial value=]
1355+
for the given [=property=].
1356+
1357+
<div algorithm>
1358+
To <dfn>evaluate a <<style-range>></dfn>,
1359+
the following steps needs to be performed:
1360+
1361+
1. If <<style-range-value>> is a <<custom-property-name>>,
1362+
it needs to be substituted
1363+
as if the <<custom-property-name>> was wrapped inside a ''var()''.
1364+
2. Substitute [=arbitrary substitution function=] within <<style-range-value>>.
1365+
3. Parse <<style-range-value>> to
1366+
<<number>>, <<percentage>>, <<length>>, <<angle>>, <<time>>, <<frequency>> or <<resolution>>.
1367+
If this cannot be done, evaluate to false.
1368+
4. If each <<style-range-value>> from the range have the same type,
1369+
compute each and evaluate the comparison.
1370+
5. Otherwise evaluate to false.
1371+
</div>
13411372

13421373
The boolean syntax and logic combining [=style features=] into a [=container style query|style query=]
13431374
is the same as for [=CSS feature queries=].

0 commit comments

Comments
 (0)