Skip to content

Commit 16a54c2

Browse files
committed
[css-contain] Clarify interaction of layout containment and fragmentation
Closes w3c#2840
1 parent c60bf0f commit 16a54c2

3 files changed

Lines changed: 74 additions & 16 deletions

File tree

css-contain-1/Overview.bs

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -236,26 +236,68 @@ Layout Containment</h3>
236236

237237
1. The element [=establishes an independent formatting context=].
238238

239-
2. If a <a>fragmentation context</a> participates in <a>layout containment</a>,
240-
the first element with <a>layout containment</a>
241-
affecting the <a>fragmentation context</a>
242-
must “trap” the remainder of the <a>fragmented flow</a>.
243-
<a>Fragmentation</a> must not continue past the <a>layout containment</a> boundary,
244-
and the last <a>fragmentation container</a>
245-
within the first <a>layout containment</a> boundary
246-
is treated as if it is the last <a>fragmentation container</a>
247-
in its <a>fragmentation context</a>.
248-
249-
If subsequent <a>fragmentation containers</a> in the <a>fragmentation context</a>
250-
are only generated when more content remains in the <a>fragmented flow</a>,
239+
2. If at least one [=fragmentation container=] of a [=fragmentation context=] has [=layout containment=],
240+
or if at least one [=fragmentation container=] of a [=fragmentation context=] is a descendant of an element with layout containment
241+
<strong>and</strong> at least one subsequent [=fragmentation container=] of the same [=fragmentation context=]
242+
is not a descendant of that same element with layout containment,
243+
then the first element with [=layout containment=]
244+
which is either a [=fragmentation container=] itself
245+
or is an ancestor of a [=fragmentation container=]
246+
must “trap” the remainder of the [=fragmented flow=]:
247+
[=fragmentation=] must not continue past the [=layout containment=] boundary,
248+
and the last [=fragmentation container=]
249+
within the first [=layout containment=] boundary
250+
is treated as if it is the last [=fragmentation container=]
251+
in its [=fragmentation context=].
252+
253+
If subsequent [=fragmentation containers=] in the [=fragmentation context=]
254+
are only generated when more content remains in the [=fragmented flow=],
251255
then they are not generated.
252256
If they would exist regardless,
253-
they remain part of the <a>fragmentation context</a>,
254-
but do not receive any content from the <a>fragmented flow</a>.
255-
256-
Note: [[CSS-REGIONS-1]] has details over how <a>layout containment</a> affects
257+
they remain part of the [=fragmentation context=],
258+
but do not receive any content from the [=fragmented flow=].
259+
260+
Note: At the time of writing, no stable specification is affected by this point.
261+
Only specifications that would enable some (but not all) fragmentation containers of a fragmentation context
262+
to be layout-contained (or descendants of a layout contained element)
263+
are concerned.
264+
This is not the case of [[CSS-PAGE-3]] nor of [[CSS-MULTICOL-1]].
265+
This requirement is nonetheless included because
266+
several mechanisms that would make this a possibility have been considered
267+
(e.g.: [[CSS-REGIONS-1]], ''::nth-fragment()'', a hypothetical selector for individual columns of a multicol…),
268+
and the guarantees that layout containment is intended to offer would not be realized
269+
if such mechanisms did not abide by this rule.
270+
[[CSS-REGIONS-1]] has details over how <a>layout containment</a> affects
257271
regions.
258272

273+
<div class=example>
274+
<pre><code highlight=markup>
275+
&lt;article>Lorem ipsum…&lt;/article>
276+
&lt;div id=a>&lt;/div>
277+
&lt;aside>
278+
&lt;div id=b>&lt;/div>
279+
&lt;div id=c>&lt;/div>
280+
&lt;/aside>
281+
&lt;aside>
282+
&lt;div id=d>&lt;/div>
283+
&lt;div id=e>&lt;/div>
284+
&lt;/aside>
285+
&lt;div id=f>&lt;/div>
286+
</code></pre>
287+
<pre><code highlight=css>
288+
article {flow-into: foo;}
289+
#a, #b, #c, #d, #e, #f {flow-from: foo;}
290+
aside {contain: layout}
291+
</code></pre>
292+
293+
In this [[CSS-REGIONS-1]] example,
294+
content can flow from <code>#a</code> to <code>#b</code>,
295+
from <code>#b</code> to <code>#c</code>.
296+
However as <code>#c</code> is the last fragment container in the first layout-contained element,
297+
it traps all the remaining content,
298+
and nothing gets flowed into <code>#d</code>, <code>#e</code>, or <code>#f</code>.
299+
</div>
300+
259301
3. If the contents of the element overflow the element,
260302
they must be treated as <a>ink overflow</a>.
261303

css-contain-1/issues-2018-cr.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ <h1>CSS Contain Level 1 Disposition of Comments for 2018-05-24 CR</h1>
6666
Response: <a href='https://github.com/w3c/csswg-drafts/issues/2845#issuecomment-401319909'>https://github.com/w3c/csswg-drafts/issues/2845#issuecomment-401319909</a>
6767
Closed: Accepted
6868
Resolved: Editorial</pre>
69+
<pre class='a' id='issue-5'>
70+
Issue 5. <a href='#issue-5'>#</a>
71+
Summary: Need clarification on layout containment &amp; fragmentation
72+
From: Daniel Holbert
73+
Comment: <a href='https://github.com/w3c/csswg-drafts/issues/2840'>https://github.com/w3c/csswg-drafts/issues/2840</a>
74+
Response: <a href='https://github.com/w3c/csswg-drafts/issues/2840#issuecomment-401249631'>https://github.com/w3c/csswg-drafts/issues/2840#issuecomment-401249631</a>
75+
Closed: Accepted
76+
Resolved: Editorial</pre>
6977
<script>
7078
(function () {
7179
var sheet = document.styleSheets[0];

css-contain-1/issues-2018-cr.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ Comment: https://github.com/w3c/csswg-drafts/issues/2845
3636
Response: https://github.com/w3c/csswg-drafts/issues/2845#issuecomment-401319909
3737
Closed: Accepted
3838
Resolved: Editorial
39+
----
40+
Issue 5.
41+
Summary: Need clarification on layout containment & fragmentation
42+
From: Daniel Holbert
43+
Comment: https://github.com/w3c/csswg-drafts/issues/2840
44+
Response: https://github.com/w3c/csswg-drafts/issues/2840#issuecomment-401249631
45+
Closed: Accepted
46+
Resolved: Editorial

0 commit comments

Comments
 (0)