Skip to content

Commit f209f6a

Browse files
committed
[css-contain-3] Incorporate style queries.
* Add style() function for querying computed style. * Switch size queries to use explicit size() function. * Reference @supports boolean grammar instead of @media (no commas). * Fix various grammar errors. * Rename dimensional queries to size queries (for consistency). * Improvements to spec prose (precision and organization).
1 parent 5c13022 commit f209f6a

File tree

1 file changed

+83
-36
lines changed

1 file changed

+83
-36
lines changed

css-contain-3/Overview.bs

+83-36
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,23 @@ Creating Query Containers: the 'container-type' property</h2>
189189
<dl dfn-type=value dfn-for=container-type>
190190
<dt><dfn>size</dfn>
191191
<dd>
192-
Establishes a [=query container=] for [=dimensional queries=]
192+
Establishes a [=query container=] for [=size queries=]
193193
on both the [=inline axis|inline=] and [=block axis=].
194194
Applies [=layout containment=],
195195
[=style containment=],
196196
and [=size containment=]
197197
to the [=principal box=].
198198
<dt><dfn>inline-size</dfn>
199199
<dd>
200-
Establishes a [=query container=] for [=dimensional queries=]
200+
Establishes a [=query container=] for [=size queries=]
201201
on the container’s own [=inline axis=].
202202
Applies [=layout containment=],
203203
[=style containment=],
204204
and [=inline-size containment=]
205205
to the [=principal box=].
206206
<dt><dfn>block-size</dfn>
207207
<dd>
208-
Establishes a [=query container=] for [=dimensional queries=]
208+
Establishes a [=query container=] for [=size queries=]
209209
on the container’s own [=block axis=].
210210
Applies [=layout containment=],
211211
[=style containment=],
@@ -371,41 +371,64 @@ Creating Named Containers: the 'container' shorthand</h2>
371371
Container Queries: the ''@container'' rule</h2>
372372

373373
The <dfn at-rule id="at-ruledef-container">@container</dfn> rule
374-
is a [=conditional group rule=] whose condition is a [=container query=].
374+
is a [=conditional group rule=] whose condition is
375+
a <dfn export>container query</dfn>,
376+
which is a boolean combination of [=size queries=] and/or [=style queries=].
377+
Style declarations within the <<stylesheet>> block of an ''@container'' rule
378+
are [[css-cascade-4#filtering|filtered]] by its condition
379+
to only match when the [=container query=]
380+
is true for their element’s [=query container=].
381+
375382

376383
The syntax of the ''@container'' rule is:
377384

378385
<pre class="prod def">
379-
@container <<container-name>> | [ name(<<container-name>>) || type(<<container-type>>+) ]? <<container-query-list>> {
380-
<<stylesheet>>
386+
@container
387+
[ <<container-name>> | [ name(<<container-name>>) || type(<<container-type>>+) ] ]?
388+
<<container-query>> {
389+
<<stylesheet>>
381390
}
382391
</pre>
383392

384-
The <dfn>&lt;container-query-list></dfn> represents the <dfn export>container query</dfn>
385-
and has the same syntax, parsing, and boolean interpretation as
386-
<<media-condition>> in [[MEDIAQUERIES-4]],
387-
but with [=container features=] instead of [=media features=].
393+
where:
394+
395+
<pre class="prod def">
396+
<dfn><<container-condition>></dfn> = not <<container-query>>
397+
| <<container-query>> [ and <<container-query>> ]*
398+
| <<container-query>> [ or <<container-query>> ]*
399+
<dfn><<container-query>></dfn> = ( <<container-condition>> )
400+
| size( <<size-query>> )
401+
| style( <<style-query>> )
402+
403+
<dfn><<size-query>></dfn> = <<size-feature>> | <<size-condition>>
404+
<dfn><<size-condition>></dfn> = not ( <<size-query>> )
405+
| ( <<size-query>> ) [ and ( <<size-query>> ) ]*
406+
| ( <<size-query>> ) [ or ( <<size-query>> ) ]*
407+
408+
<dfn><<style-query>></dfn> = <<style-feature>> | <<style-condition>>
409+
<dfn><<style-condition>></dfn> = not ( <<style-query>> )
410+
| ( <<style-query>> ) [ and ( <<style-query>> ) ]*
411+
| ( <<style-query>> ) [ or ( <<style-query>> ) ]*
412+
</pre>
388413

389-
Styles in the <<stylesheet>> block of the ''@container'' rule
390-
are [[css-cascade-4#filtering|filtered]] by its condition
391-
to only match when the [=container query=]
392-
is true for the element’s [=query container=].
393414

394415
For each element,
395416
the [=query container=] to be queried
396-
is selected from the element’s ancestor [=query containers=].
417+
is selected from among the element’s ancestor [=query containers=].
397418
The optional <dfn><<container-name>></dfn>
398419
filters the set of [=query containers=] considered
399420
to just those with a matching [=query container name=],
400421
and the optional <dfn><<container-type>></dfn>
401-
filters the set to just those with matching 'container-type's.
422+
filters the set to just those with a matching 'container-type'.
402423
The nearest remaining [=query container=] ancestor is selected.
403424

404-
Note: A [=query container=] with a 'container-type' of ''container-type/size''
405-
is a match for both ''container-type/inline-size'' and ''container-type/block-size''
406-
<<container-type>>s.
425+
ISSUE: Should the UA automatically filter to the nearest compatible query container
426+
if no specific type is provided?
427+
428+
ISSUE(6393): Do we like this syntax for querying specific container types?
407429

408-
Issue(6393): Provide a syntax to query a specific container-type
430+
A [=query container=] with a 'container-type' of ''container-type/size''
431+
is a match for both ''container-type/inline-size'' and ''container-type/block-size''.
409432

410433
Once an eligible [=query container=] has been selected for an element,
411434
each [=container feature=] in the <<container-query-list>>
@@ -431,33 +454,41 @@ Container Queries: the ''@container'' rule</h2>
431454
</div>
432455

433456
Style rules defined on an element inside multiple nested [=container queries=]
434-
apply when all of the wrapping [=container queries=] are ''true'' for that element.
457+
apply when all of the wrapping [=container queries=] are true for that element.
435458

436-
Note: Nested [=container queries=] may evaluate in relation to different containers,
437-
so it is not possible to merge the individual <<container-query-list>>s
459+
Note: Nested [=container queries=] can evaluate in relation to different containers,
460+
so it is not always possible to merge the individual <<container-query-list>>s
438461
into a single query.
439462

440463
<h2 id="container-features">
441464
Container Features</h2>
442465

443466
A <dfn export>container feature</dfn>
444467
queries a specific aspect of a [=query container=].
445-
Its syntax is the same as for a [=media feature=]:
446-
a feature name, a comparator, and a value, all wrapped in parentheses.
447-
[[mediaqueries-5]]
448468

449469
Issue(5989): What container features can be queried?
450470

451-
<h3 id="dimensional-container">
452-
Dimensional Container Features</h3>
471+
<h3 id="size-container">
472+
Size Container Features</h3>
453473

454-
<dfn export>Dimensional queries</dfn> allow querying
474+
A <dfn export>size query</dfn>
475+
(syntactically represented as <<size-query>>)
476+
allows querying
455477
the size of the [=query container=]’s [=principal box=].
478+
It is a boolean combination of
479+
individual <dfn>size features</dfn> (<<size-feature>>)
480+
that each query a single, specific dimensional feature of the [=query container=].
481+
The syntax of a <dfn><<size-feature>></dfn> is the same as for a [=media feature=]:
482+
a feature name, a comparator, and a value.
483+
[[mediaqueries-5]]
484+
The boolean syntax and logic combining [=size features=] into a <<size-query>>
485+
is the same as for [=feature queries=].
486+
(See ''@supports''. [[!CSS-CONDITIONAL-3]])
456487

457488
If the [=query container=] does not have a [=principal box=],
458489
or the principal box is not a [=layout containment box=],
459-
or the [=query container=] does not support [=dimensional queries=] on the relevant axes,
460-
then the result of evaluating any dimensional container feature is ''unknown''.
490+
or the [=query container=] does not support [=size queries=] on the relevant axes,
491+
then the result of evaluating the [=size feature=] is unknown.
461492

462493
[=Relative length=] units in [=container query=] conditions
463494
are evaluated based on the the [=computed values=] of the [=query container=].
@@ -591,10 +622,26 @@ Orientation: the '@container/orientation' feature</h4>
591622
<h3 id="style-container">
592623
Style Container Features</h3>
593624

594-
<dfn export>Style queries</dfn> allow querying
625+
A <dfn export>style queries</dfn>
626+
(syntactically represented by <<style-query>>)
627+
allows querying
595628
the [=computed values=] of the [=query container=].
596-
597-
Issue(6396): Define a syntax for style-based container queries
629+
It is a boolean combination of
630+
individual <dfn>style features</dfn> (<<style-feature>>)
631+
that each query a single, specific property of the [=query container=].
632+
The syntax of a <dfn><<style-feature>></dfn> is the same as for a [=declaration=]
633+
[[!CSS-SYNTAX-3]],
634+
and its query is true if
635+
the [=computed value=] of the given property on the [=query container=]
636+
matches the given value
637+
(which is also [=computed value|computed=] with respect to the [=query container=]),
638+
unknown if the property or its value is unsupported,
639+
and false otherwise.
640+
The boolean syntax and logic combining [=style features=] into a <<style-query>>
641+
is the same as for [=feature queries=].
642+
(See ''@supports''. [[!CSS-CONDITIONAL-3]])
643+
644+
Issue(6396): Do we like this proposed syntax for style queries?
598645

599646
<h3 id="state-container">
600647
State Container Features</h3>
@@ -639,11 +686,11 @@ Container Relative Lengths: the ''qw'', ''qh'', ''qi'', ''qb'', ''qmin'', ''qmax
639686

640687
For each element,
641688
[=query length=] units are evaluated
642-
as [=dimensional queries=] on the relevant axis (or axes)
689+
as [=size queries=] on the relevant axis (or axes)
643690
described by the unit.
644691
The [=query container=] for each axis
645692
is the nearest ancestor container
646-
that accepts [=dimensional queries=] on that axis.
693+
that accepts [=size queries=] on that axis.
647694
If no eligible [=query container=] is available,
648695
then use the [=small viewport size=] for that axis.
649696

0 commit comments

Comments
 (0)