Skip to content

Commit 6bc6c7b

Browse files
authored
Merge pull request w3c#4190 from frivoal/fix4189
[css-contain] Be more rigorous about box vs element
2 parents 6fc80b8 + d3711f6 commit 6bc6c7b

File tree

1 file changed

+60
-53
lines changed

1 file changed

+60
-53
lines changed

css-contain-1/Overview.bs

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Strong Containment: the 'contain' property</h2>
144144
<dt><dfn>size</dfn>
145145
<dd>
146146
The value turns on <a>size containment</a> for the element.
147-
This ensures that the containing element can be laid out
147+
This ensures that the containing box can be laid out
148148
without needing to examine its descendants.
149149

150150
<wpt>
@@ -208,7 +208,7 @@ Strong Containment: the 'contain' property</h2>
208208
<dt><dfn>layout</dfn>
209209
<dd>
210210
This value turns on <a>layout containment</a> for the element.
211-
This ensures that the containing element is <em>totally opaque</em> for layout purposes;
211+
This ensures that the containing box is <em>totally opaque</em> for layout purposes;
212212
nothing outside can affect its internal layout,
213213
and vice versa.
214214

@@ -262,7 +262,7 @@ Strong Containment: the 'contain' property</h2>
262262
This value turns on <a>style containment</a> for the element.
263263
This ensures that,
264264
for properties which can have effects on more than just an element and its descendants,
265-
those effects don't escape the containing element.
265+
those effects don't escape the element.
266266

267267
<wpt>
268268
contain-style-baseline-001.html
@@ -289,7 +289,7 @@ Strong Containment: the 'contain' property</h2>
289289
<dt><dfn>paint</dfn>
290290
<dd>
291291
This value turns on <a>paint containment</a> for the element.
292-
This ensures that the descendants of the containing element don't display outside its bounds,
292+
This ensures that the descendants of the containing box don't display outside its bounds,
293293
so if an element is off-screen or otherwise not visible,
294294
its descendants are also guaranteed to be not visible.
295295

@@ -402,12 +402,14 @@ Types of Containment</h2>
402402
Size Containment</h3>
403403

404404
If the element does not generate a <a>principal box</a> (as is the case with ''display: contents'' or ''display: none''),
405-
or if the element is a ''display/table'',
406-
or if the element is an <a spec="css-display-3">internal table element</a>,
407-
or if the element is an <a spec="css-display-3">internal ruby element</a>,
408-
or if the element's <a>principal box</a> is a <a spec="css-display-3" lt="atomic inline">non-atomic</a> <a spec="css-display-3">inline-level</a> box,
405+
or its [=inner display type=] is ''display/table'',
406+
or its principal box is an <a spec="css-display-3">internal table box</a>,
407+
or an <a spec="css-display-3">internal ruby box</a>,
408+
or a <a spec="css-display-3" lt="atomic inline">non-atomic</a> <a spec="css-display-3">inline-level</a> box,
409409
size containment has no effect.
410-
Otherwise, giving an element <dfn export>size containment</dfn> has the following effects:
410+
Otherwise, giving an element <dfn export>size containment</dfn>
411+
makes its [=principal box=] a <dfn for=size-containment>containing box</dfn> for [=size containment=]
412+
and has the following effects:
411413

412414
<wpt>
413415
contain-size-001.html
@@ -425,11 +427,11 @@ Size Containment</h3>
425427
contain-size-052.html
426428
</wpt>
427429

428-
Note: Internal table elements,
430+
Note: Internal table boxes,
429431
which do not include table captions,
430432
are excluded,
431433
because the table layout algorithm
432-
does not allow elements to become smaller than their inflow content.
434+
does not allow boxes to become smaller than their inflow content.
433435
Sizing a table cell as if it was empty and then layout out its content inside without changing the size
434436
is effectively an undefined operation.
435437
Manually setting the 'width' or 'height' properties to ''0''
@@ -443,7 +445,7 @@ Size Containment</h3>
443445
contain-size-056.html
444446
</wpt>
445447

446-
1. When calculating the size of the containing element,
448+
1. When calculating the size of the [=size-containment/containing box=],
447449
it must be treated as having no contents.
448450

449451
<wpt>
@@ -482,7 +484,7 @@ Size Containment</h3>
482484
</wpt>
483485

484486
Then,
485-
its contents must then be laid out into the containing element's resolved size.
487+
its contents must then be laid out into the [=size-containment/containing box=]'s resolved size.
486488

487489
Note: [=size containment=] does not suppress baseline alignment.
488490
See [=layout containment=] for that.
@@ -506,44 +508,46 @@ Size Containment</h3>
506508
contain-size-replaced-005.html
507509
contain-size-replaced-006.html
508510
</wpt>
509-
2. Elements with <a>size containment</a> are <a spec=css-break-3>monolithic</a> (See [[CSS-BREAK-3#possible-breaks]]).
511+
2. [=size-containment/Containing boxes=] for <a>size containment</a> are <a spec=css-break-3>monolithic</a> (See [[CSS-BREAK-3#possible-breaks]]).
510512

511513
<wpt>
512514
contain-size-breaks-001.html
513515
contain-size-monolithic-001.html
514516
</wpt>
515517

516518
By itself, <a>size containment</a> does not offer much optimization opportunity.
517-
Its primary benefit on its own is that tools which want to lay out the containing element's contents
518-
based on the containing element's size
519+
Its primary benefit on its own is that tools which want to lay out the containing box's contents
520+
based on the containing box's size
519521
(such as a JS library implementing the "container query" concept)
520522
can do so without fear of "infinite loops",
521-
where having a child's size respond to the size of the containing element
522-
causes the containing element's size to change as well,
523+
where having a child's size respond to the size of the containing box
524+
causes the containing box's size to change as well,
523525
possibly triggering <em>further</em> changes in how the child sizes itself
524-
and possibly thus more changes to the containing element's size,
526+
and possibly thus more changes to the containing box's size,
525527
ad infinitum.
526528

527529
When paired with <a>layout containment</a>, though,
528530
possible optimizations that can be enabled include (but are not limited to):
529531

530-
1. When the style or contents of a descendant of the containing element is changed,
532+
1. When the style or contents of a descendant of the containing box is changed,
531533
calculating what part of the DOM tree is "dirtied" and might need to be re-laid out
532-
can stop at the containing element.
534+
can stop at the containing box.
533535

534536
2. When laying out the page,
535-
if the containing element is off-screen or obscured,
537+
if the containing box is off-screen or obscured,
536538
the layout of its contents can be delayed or done at a lower priority.
537539

538540
<h3 id='containment-layout'>
539541
Layout Containment</h3>
540542

541543
If the element does not generate a <a>principal box</a> (as is the case with 'display' values of ''display/contents'' or ''display/none''),
542-
or if the element is an <a spec="css-display-3">internal table element</a> other than ''display/table-cell'',
543-
or if the element is an <a spec="css-display-3">internal ruby element</a>,
544-
or if the element's <a>principal box</a> is a <a spec="css-display-3" lt="atomic inline">non-atomic</a> <a spec="css-display-3">inline-level</a> box,
544+
or its [=principal box=] is an <a spec="css-display-3">internal table box</a> other than ''display/table-cell'',
545+
or an <a spec="css-display-3">internal ruby box</a>,
546+
or a <a spec="css-display-3" lt="atomic inline">non-atomic</a> <a spec="css-display-3">inline-level</a> box,
545547
layout containment has no effect.
546-
Otherwise, giving an element <dfn export>layout containment</dfn> has the following effects:
548+
Otherwise, giving an element <dfn export>layout containment</dfn>
549+
makes its [=principal box=] a <dfn for=layout-containment>containing box</dfn> for [=layout containment=]
550+
and has the following effects:
547551

548552
<wpt>
549553
contain-layout-001.html
@@ -560,7 +564,7 @@ Layout Containment</h3>
560564
contain-layout-independent-formatting-context-003.html
561565
</wpt>
562566

563-
1. The element [=establishes an independent formatting context=].
567+
1. The [=layout-containment/containing box=] [=establishes an independent formatting context=].
564568

565569
<wpt>
566570
contain-layout-ifc-022.html
@@ -570,10 +574,10 @@ Layout Containment</h3>
570574
</wpt>
571575

572576
2. If at least one [=fragmentation container=] of a [=fragmentation context=] has [=layout containment=],
573-
or if at least one [=fragmentation container=] of a [=fragmentation context=] is a descendant of an element with layout containment
577+
or if at least one [=fragmentation container=] of a [=fragmentation context=] is a descendant of [=layout-containment/containing box=] for layout containment
574578
<strong>and</strong> at least one subsequent [=fragmentation container=] of the same [=fragmentation context=]
575579
is not a descendant of that same element with layout containment,
576-
then the first element with [=layout containment=]
580+
then the first [=layout-containment/containing box=] for [=layout containment=]
577581
which is either a [=fragmentation container=] itself
578582
or is an ancestor of a [=fragmentation container=]
579583
must “trap” the remainder of the [=fragmented flow=]:
@@ -626,7 +630,7 @@ Layout Containment</h3>
626630
In this [[CSS-REGIONS-1]] example,
627631
content can flow from <code>#a</code> to <code>#b</code>,
628632
from <code>#b</code> to <code>#c</code>.
629-
However as <code>#c</code> is the last fragment container in the first layout-contained element,
633+
However as <code>#c</code> is the last fragment container in the first containing box for layout containment,
630634
it traps all the remaining content,
631635
and nothing gets flowed into <code>#d</code>, <code>#e</code>, or <code>#f</code>.
632636
</div>
@@ -646,7 +650,7 @@ Layout Containment</h3>
646650
contain-layout-ink-overflow-020.html
647651
</wpt>
648652

649-
4. The element acts as a containing block for absolutely positioned and fixed positioned descendants.
653+
4. The [=layout-containment/containing box=] acts as a containing block for absolutely positioned and fixed positioned descendants.
650654

651655
<wpt>
652656
contain-layout-006.html
@@ -655,15 +659,15 @@ Layout Containment</h3>
655659
contain-layout-cell-002.html
656660
</wpt>
657661

658-
5. The element creates a <a>stacking context</a>.
662+
5. The [=layout-containment/containing box=] creates a <a>stacking context</a>.
659663

660664
<wpt>
661665
contain-layout-016.html
662666
contain-layout-017.html
663667
contain-layout-018.html
664668
</wpt>
665669

666-
6. [=Forced breaks=] are allowed within elements with [=layout containment=],
670+
6. [=Forced breaks=] are allowed within [=layout-containment/containing boxes=] for [=layout containment=],
667671
but do not propagate to the parent as otherwise described in [[CSS-BREAK-3#break-between]].
668672

669673
<wpt>
@@ -676,9 +680,9 @@ Layout Containment</h3>
676680

677681
7. For the purpose of the 'vertical-align' property,
678682
or any other property whose effects
679-
need to relate the position of the containing element's baseline
683+
need to relate the position of the [=layout-containment/containing box=]'s baseline
680684
to something other than its descendants,
681-
the containing element is treated as having no baseline.
685+
the [=layout-containment/containing box=] is treated as having no baseline.
682686

683687
<wpt>
684688
contain-layout-baseline-001.html
@@ -694,16 +698,16 @@ Layout Containment</h3>
694698
Possible optimizations that can be enabled by <a>layout containment</a> include (but are not limited to):
695699

696700
1. When laying out the page,
697-
the contents of separate containing elements
701+
the contents of separate containing boxes
698702
can be laid out in parallel,
699703
as they're guaranteed not to affect each other.
700704

701705
2. When laying out the page,
702-
if the containing element is off-screen or obscured
703-
and the layout of the visible parts of the screen do not depend on the size of the containing element
704-
(for example, if the containing element is near the end of a block container,
706+
if the containing box is off-screen or obscured
707+
and the layout of the visible parts of the screen do not depend on the size of the containing box
708+
(for example, if the containing box is near the end of a block container,
705709
and you're viewing the beginning of the block container),
706-
the layout of the containing elements' contents can be delayed or done at a lower priority.
710+
the layout of the containing box' contents can be delayed or done at a lower priority.
707711

708712
(When paired with <a>size containment</a>,
709713
this optimization can be applied more liberally.)
@@ -713,7 +717,8 @@ Style Containment</h3>
713717

714718
Note: Style Containment is at-risk.
715719

716-
Giving an element <dfn export>style containment</dfn> has the following effects:
720+
Giving an element <dfn export>style containment</dfn>
721+
and has the following effects:
717722

718723
1. The 'counter-increment' and 'counter-set' properties
719724
must be <a for=property>scoped to the element's sub-tree</a>
@@ -804,19 +809,21 @@ Style Containment</h3>
804809

805810
Possible optimizations that can be enabled by <a>style containment</a> include (but are not limited to):
806811

807-
1. Whenever a property is changed on a descendant of the containing element,
812+
1. Whenever a property is changed on a descendant of an element with [=style containment=],
808813
calculating what part of the DOM tree is "dirtied" and might need to have its style recalculated
809-
can stop at the containing element.
814+
can stop at the containing box.
810815

811816
<h3 id='containment-paint'>
812817
Paint Containment</h3>
813818

814819
If the element does not generate a <a>principal box</a> (as is the case with 'display' values of ''display/contents'' or ''display/none''),
815-
or if the element is an <a spec="css-display-3">internal table element</a> other than ''display/table-cell'',
816-
or if the element is an <a spec="css-display-3">internal ruby element</a>,
817-
or if the element's <a>principal box</a> is a <a spec="css-display-3" lt="atomic inline">non-atomic</a> <a spec="css-display-3">inline-level</a> box,
820+
or its [=principal box=] is an <a spec="css-display-3">internal table box</a> other than ''display/table-cell'',
821+
or an <a spec="css-display-3">internal ruby box</a>,
822+
or a <a spec="css-display-3" lt="atomic inline">non-atomic</a> <a spec="css-display-3">inline-level</a> box,
818823
paint containment has no effect.
819-
Otherwise, giving an element <dfn export>paint containment</dfn> has the following effects:
824+
Otherwise, giving an element <dfn export>paint containment</dfn>
825+
makes its [=principal box=] a <dfn for=paint-containment>containing box</dfn> for [=paint containment=]
826+
and has the following effects:
820827

821828
<wpt>
822829
contain-paint-002.html
@@ -837,7 +844,7 @@ Paint Containment</h3>
837844

838845
1. The contents of the element
839846
including both the paint of the descendants and their geometry
840-
must be clipped to the <a>padding edge</a> of the element's <a>principal box</a>,
847+
must be clipped to the <a>padding edge</a> of the [=paint-containment/containing box=],
841848
taking <a>corner clipping</a> into account.
842849
This does not include the creation of any mechanism
843850
to access or indicate the presence of the clipped content;
@@ -864,7 +871,7 @@ Paint Containment</h3>
864871
contain-paint-table-001.html
865872
contain-paint-table-002.html
866873
</wpt>
867-
2. The element acts as a containing block for absolutely positioned and fixed positioned descendants.
874+
2. The [=paint-containment/containing box=] acts as a containing block for absolutely positioned and fixed positioned descendants.
868875

869876
<wpt>
870877
contain-paint-009.html
@@ -873,15 +880,15 @@ Paint Containment</h3>
873880
contain-paint-023.html
874881
contain-paint-024.html
875882
</wpt>
876-
3. The element creates a <a>stacking context</a>.
883+
3. The [=paint-containment/containing box=] creates a <a>stacking context</a>.
877884

878885
<wpt>
879886
contain-paint-020.html
880887
contain-paint-021.html
881888
contain-paint-025.html
882889
contain-subgrid-001.html
883890
</wpt>
884-
4. The element [=establishes an independent formatting context=].
891+
4. The [=paint-containment/containing box=] [=establishes an independent formatting context=].
885892

886893
<wpt>
887894
contain-paint-ifc-011.html
@@ -896,13 +903,13 @@ Paint Containment</h3>
896903
<div class=informative>
897904
Possible optimizations that can be enabled by <a>paint containment</a> include (but are not limited to):
898905

899-
1. If the containing element is off-screen or obscured,
906+
1. If the containing box is off-screen or obscured,
900907
the UA can directly skip trying to paint its contents,
901908
as they're guaranteed to be off-screen/obscured as well.
902909

903910
2. Unless the clipped content is made accessible via a separate mechanism
904911
such as the 'overflow', 'resize', or 'text-overflow' properties,
905-
the UA can reserve "canvas" space for the element exactly the element's size.
912+
the UA can reserve "canvas" space for the box exactly the box's size.
906913
(In similar, scrollable, situations, like ''overflow: hidden'',
907914
it's possible to scroll to the currently-clipped content,
908915
so UAs often predictively overpaint somewhat

0 commit comments

Comments
 (0)