Skip to content

Commit d3711f6

Browse files
committed
[css-contain] Be more rigorous about box vs element
Closes w3c#4189
1 parent 47e2a69 commit d3711f6

1 file changed

Lines changed: 60 additions & 53 deletions

File tree

css-contain-1/Overview.bs

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

148148
<wpt>
@@ -197,7 +197,7 @@ Strong Containment: the 'contain' property</h2>
197197
<dt><dfn>layout</dfn>
198198
<dd>
199199
This value turns on <a>layout containment</a> for the element.
200-
This ensures that the containing element is <em>totally opaque</em> for layout purposes;
200+
This ensures that the containing box is <em>totally opaque</em> for layout purposes;
201201
nothing outside can affect its internal layout,
202202
and vice versa.
203203

@@ -250,7 +250,7 @@ Strong Containment: the 'contain' property</h2>
250250
This value turns on <a>style containment</a> for the element.
251251
This ensures that,
252252
for properties which can have effects on more than just an element and its descendants,
253-
those effects don't escape the containing element.
253+
those effects don't escape the element.
254254

255255
<wpt>
256256
contain-style-baseline-001.html
@@ -277,7 +277,7 @@ Strong Containment: the 'contain' property</h2>
277277
<dt><dfn>paint</dfn>
278278
<dd>
279279
This value turns on <a>paint containment</a> for the element.
280-
This ensures that the descendants of the containing element don't display outside its bounds,
280+
This ensures that the descendants of the containing box don't display outside its bounds,
281281
so if an element is off-screen or otherwise not visible,
282282
its descendants are also guaranteed to be not visible.
283283

@@ -387,12 +387,14 @@ Types of Containment</h2>
387387
Size Containment</h3>
388388

389389
If the element does not generate a <a>principal box</a> (as is the case with ''display: contents'' or ''display: none''),
390-
or if the element is a ''display/table'',
391-
or if the element is an <a spec="css-display-3">internal table element</a>,
392-
or if the element is an <a spec="css-display-3">internal ruby element</a>,
393-
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,
390+
or its [=inner display type=] is ''display/table'',
391+
or its principal box is an <a spec="css-display-3">internal table box</a>,
392+
or an <a spec="css-display-3">internal ruby box</a>,
393+
or a <a spec="css-display-3" lt="atomic inline">non-atomic</a> <a spec="css-display-3">inline-level</a> box,
394394
size containment has no effect.
395-
Otherwise, giving an element <dfn export>size containment</dfn> has the following effects:
395+
Otherwise, giving an element <dfn export>size containment</dfn>
396+
makes its [=principal box=] a <dfn for=size-containment>containing box</dfn> for [=size containment=]
397+
and has the following effects:
396398

397399
<wpt>
398400
contain-size-001.html
@@ -410,11 +412,11 @@ Size Containment</h3>
410412
contain-size-052.html
411413
</wpt>
412414

413-
Note: Internal table elements,
415+
Note: Internal table boxes,
414416
which do not include table captions,
415417
are excluded,
416418
because the table layout algorithm
417-
does not allow elements to become smaller than their inflow content.
419+
does not allow boxes to become smaller than their inflow content.
418420
Sizing a table cell as if it was empty and then layout out its content inside without changing the size
419421
is effectively an undefined operation.
420422
Manually setting the 'width' or 'height' properties to ''0''
@@ -428,7 +430,7 @@ Size Containment</h3>
428430
contain-size-056.html
429431
</wpt>
430432

431-
1. When calculating the size of the containing element,
433+
1. When calculating the size of the [=size-containment/containing box=],
432434
it must be treated as having no contents.
433435

434436
<wpt>
@@ -464,7 +466,7 @@ Size Containment</h3>
464466
</wpt>
465467

466468
Then,
467-
its contents must then be laid out into the containing element's resolved size.
469+
its contents must then be laid out into the [=size-containment/containing box=]'s resolved size.
468470

469471
Note: [=size containment=] does not suppress baseline alignment.
470472
See [=layout containment=] for that.
@@ -485,44 +487,46 @@ Size Containment</h3>
485487
contain-size-replaced-003b.html
486488
contain-size-replaced-003c.html
487489
</wpt>
488-
2. Elements with <a>size containment</a> are <a spec=css-break-3>monolithic</a> (See [[CSS-BREAK-3#possible-breaks]]).
490+
2. [=size-containment/Containing boxes=] for <a>size containment</a> are <a spec=css-break-3>monolithic</a> (See [[CSS-BREAK-3#possible-breaks]]).
489491

490492
<wpt>
491493
contain-size-breaks-001.html
492494
contain-size-monolithic-001.html
493495
</wpt>
494496

495497
By itself, <a>size containment</a> does not offer much optimization opportunity.
496-
Its primary benefit on its own is that tools which want to lay out the containing element's contents
497-
based on the containing element's size
498+
Its primary benefit on its own is that tools which want to lay out the containing box's contents
499+
based on the containing box's size
498500
(such as a JS library implementing the "container query" concept)
499501
can do so without fear of "infinite loops",
500-
where having a child's size respond to the size of the containing element
501-
causes the containing element's size to change as well,
502+
where having a child's size respond to the size of the containing box
503+
causes the containing box's size to change as well,
502504
possibly triggering <em>further</em> changes in how the child sizes itself
503-
and possibly thus more changes to the containing element's size,
505+
and possibly thus more changes to the containing box's size,
504506
ad infinitum.
505507

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

509-
1. When the style or contents of a descendant of the containing element is changed,
511+
1. When the style or contents of a descendant of the containing box is changed,
510512
calculating what part of the DOM tree is "dirtied" and might need to be re-laid out
511-
can stop at the containing element.
513+
can stop at the containing box.
512514

513515
2. When laying out the page,
514-
if the containing element is off-screen or obscured,
516+
if the containing box is off-screen or obscured,
515517
the layout of its contents can be delayed or done at a lower priority.
516518

517519
<h3 id='containment-layout'>
518520
Layout Containment</h3>
519521

520522
If the element does not generate a <a>principal box</a> (as is the case with 'display' values of ''display/contents'' or ''display/none''),
521-
or if the element is an <a spec="css-display-3">internal table element</a> other than ''display/table-cell'',
522-
or if the element is an <a spec="css-display-3">internal ruby element</a>,
523-
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,
523+
or its [=principal box=] is an <a spec="css-display-3">internal table box</a> other than ''display/table-cell'',
524+
or an <a spec="css-display-3">internal ruby box</a>,
525+
or a <a spec="css-display-3" lt="atomic inline">non-atomic</a> <a spec="css-display-3">inline-level</a> box,
524526
layout containment has no effect.
525-
Otherwise, giving an element <dfn export>layout containment</dfn> has the following effects:
527+
Otherwise, giving an element <dfn export>layout containment</dfn>
528+
makes its [=principal box=] a <dfn for=layout-containment>containing box</dfn> for [=layout containment=]
529+
and has the following effects:
526530

527531
<wpt>
528532
contain-layout-001.html
@@ -539,7 +543,7 @@ Layout Containment</h3>
539543
contain-layout-independent-formatting-context-003.html
540544
</wpt>
541545

542-
1. The element [=establishes an independent formatting context=].
546+
1. The [=layout-containment/containing box=] [=establishes an independent formatting context=].
543547

544548
<wpt>
545549
contain-layout-ifc-022.html
@@ -548,10 +552,10 @@ Layout Containment</h3>
548552
</wpt>
549553

550554
2. If at least one [=fragmentation container=] of a [=fragmentation context=] has [=layout containment=],
551-
or if at least one [=fragmentation container=] of a [=fragmentation context=] is a descendant of an element with layout containment
555+
or if at least one [=fragmentation container=] of a [=fragmentation context=] is a descendant of [=layout-containment/containing box=] for layout containment
552556
<strong>and</strong> at least one subsequent [=fragmentation container=] of the same [=fragmentation context=]
553557
is not a descendant of that same element with layout containment,
554-
then the first element with [=layout containment=]
558+
then the first [=layout-containment/containing box=] for [=layout containment=]
555559
which is either a [=fragmentation container=] itself
556560
or is an ancestor of a [=fragmentation container=]
557561
must “trap” the remainder of the [=fragmented flow=]:
@@ -604,7 +608,7 @@ Layout Containment</h3>
604608
In this [[CSS-REGIONS-1]] example,
605609
content can flow from <code>#a</code> to <code>#b</code>,
606610
from <code>#b</code> to <code>#c</code>.
607-
However as <code>#c</code> is the last fragment container in the first layout-contained element,
611+
However as <code>#c</code> is the last fragment container in the first containing box for layout containment,
608612
it traps all the remaining content,
609613
and nothing gets flowed into <code>#d</code>, <code>#e</code>, or <code>#f</code>.
610614
</div>
@@ -624,7 +628,7 @@ Layout Containment</h3>
624628
contain-layout-ink-overflow-020.html
625629
</wpt>
626630

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

629633
<wpt>
630634
contain-layout-006.html
@@ -633,15 +637,15 @@ Layout Containment</h3>
633637
contain-layout-cell-002.html
634638
</wpt>
635639

636-
5. The element creates a <a>stacking context</a>.
640+
5. The [=layout-containment/containing box=] creates a <a>stacking context</a>.
637641

638642
<wpt>
639643
contain-layout-016.html
640644
contain-layout-017.html
641645
contain-layout-018.html
642646
</wpt>
643647

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

647651
<wpt>
@@ -654,9 +658,9 @@ Layout Containment</h3>
654658

655659
7. For the purpose of the 'vertical-align' property,
656660
or any other property whose effects
657-
need to relate the position of the containing element's baseline
661+
need to relate the position of the [=layout-containment/containing box=]'s baseline
658662
to something other than its descendants,
659-
the containing element is treated as having no baseline.
663+
the [=layout-containment/containing box=] is treated as having no baseline.
660664

661665
<wpt>
662666
contain-layout-baseline-001.html
@@ -672,16 +676,16 @@ Layout Containment</h3>
672676
Possible optimizations that can be enabled by <a>layout containment</a> include (but are not limited to):
673677

674678
1. When laying out the page,
675-
the contents of separate containing elements
679+
the contents of separate containing boxes
676680
can be laid out in parallel,
677681
as they're guaranteed not to affect each other.
678682

679683
2. When laying out the page,
680-
if the containing element is off-screen or obscured
681-
and the layout of the visible parts of the screen do not depend on the size of the containing element
682-
(for example, if the containing element is near the end of a block container,
684+
if the containing box is off-screen or obscured
685+
and the layout of the visible parts of the screen do not depend on the size of the containing box
686+
(for example, if the containing box is near the end of a block container,
683687
and you're viewing the beginning of the block container),
684-
the layout of the containing elements' contents can be delayed or done at a lower priority.
688+
the layout of the containing box' contents can be delayed or done at a lower priority.
685689

686690
(When paired with <a>size containment</a>,
687691
this optimization can be applied more liberally.)
@@ -691,7 +695,8 @@ Style Containment</h3>
691695

692696
Note: Style Containment is at-risk.
693697

694-
Giving an element <dfn export>style containment</dfn> has the following effects:
698+
Giving an element <dfn export>style containment</dfn>
699+
and has the following effects:
695700

696701
1. The 'counter-increment' and 'counter-set' properties
697702
must be <a for=property>scoped to the element's sub-tree</a>
@@ -782,19 +787,21 @@ Style Containment</h3>
782787

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

785-
1. Whenever a property is changed on a descendant of the containing element,
790+
1. Whenever a property is changed on a descendant of an element with [=style containment=],
786791
calculating what part of the DOM tree is "dirtied" and might need to have its style recalculated
787-
can stop at the containing element.
792+
can stop at the containing box.
788793

789794
<h3 id='containment-paint'>
790795
Paint Containment</h3>
791796

792797
If the element does not generate a <a>principal box</a> (as is the case with 'display' values of ''display/contents'' or ''display/none''),
793-
or if the element is an <a spec="css-display-3">internal table element</a> other than ''display/table-cell'',
794-
or if the element is an <a spec="css-display-3">internal ruby element</a>,
795-
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,
798+
or its [=principal box=] is an <a spec="css-display-3">internal table box</a> other than ''display/table-cell'',
799+
or an <a spec="css-display-3">internal ruby box</a>,
800+
or a <a spec="css-display-3" lt="atomic inline">non-atomic</a> <a spec="css-display-3">inline-level</a> box,
796801
paint containment has no effect.
797-
Otherwise, giving an element <dfn export>paint containment</dfn> has the following effects:
802+
Otherwise, giving an element <dfn export>paint containment</dfn>
803+
makes its [=principal box=] a <dfn for=paint-containment>containing box</dfn> for [=paint containment=]
804+
and has the following effects:
798805

799806
<wpt>
800807
contain-paint-002.html
@@ -815,7 +822,7 @@ Paint Containment</h3>
815822

816823
1. The contents of the element
817824
including both the paint of the descendants and their geometry
818-
must be clipped to the <a>padding edge</a> of the element's <a>principal box</a>,
825+
must be clipped to the <a>padding edge</a> of the [=paint-containment/containing box=],
819826
taking <a>corner clipping</a> into account.
820827
This does not include the creation of any mechanism
821828
to access or indicate the presence of the clipped content;
@@ -840,7 +847,7 @@ Paint Containment</h3>
840847
contain-paint-clip-018.html
841848
contain-paint-clip-019.html
842849
</wpt>
843-
2. The element acts as a containing block for absolutely positioned and fixed positioned descendants.
850+
2. The [=paint-containment/containing box=] acts as a containing block for absolutely positioned and fixed positioned descendants.
844851

845852
<wpt>
846853
contain-paint-009.html
@@ -849,14 +856,14 @@ Paint Containment</h3>
849856
contain-paint-023.html
850857
contain-paint-024.html
851858
</wpt>
852-
3. The element creates a <a>stacking context</a>.
859+
3. The [=paint-containment/containing box=] creates a <a>stacking context</a>.
853860

854861
<wpt>
855862
contain-paint-020.html
856863
contain-paint-021.html
857864
contain-paint-025.html
858865
</wpt>
859-
4. The element [=establishes an independent formatting context=].
866+
4. The [=paint-containment/containing box=] [=establishes an independent formatting context=].
860867

861868
<wpt>
862869
contain-paint-ifc-011.html
@@ -871,13 +878,13 @@ Paint Containment</h3>
871878
<div class=informative>
872879
Possible optimizations that can be enabled by <a>paint containment</a> include (but are not limited to):
873880

874-
1. If the containing element is off-screen or obscured,
881+
1. If the containing box is off-screen or obscured,
875882
the UA can directly skip trying to paint its contents,
876883
as they're guaranteed to be off-screen/obscured as well.
877884

878885
2. Unless the clipped content is made accessible via a separate mechanism
879886
such as the 'overflow', 'resize', or 'text-overflow' properties,
880-
the UA can reserve "canvas" space for the element exactly the element's size.
887+
the UA can reserve "canvas" space for the box exactly the box's size.
881888
(In similar, scrollable, situations, like ''overflow: hidden'',
882889
it's possible to scroll to the currently-clipped content,
883890
so UAs often predictively overpaint somewhat

0 commit comments

Comments
 (0)