-
Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathOverview.bs
894 lines (734 loc) · 32.1 KB
/
Overview.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
<pre class='metadata'>
Title: CSS Exclusions Module Level 1
Status: ED
Work Status: Exploring
Shortname: css-exclusions
Level: 1
Group: csswg
ED: https://drafts.csswg.org/css-exclusions/
TR: https://www.w3.org/TR/css3-exclusions/
Previous Version: https://www.w3.org/TR/2015/WD-css3-exclusions-20150115/
Previous Version: https://www.w3.org/TR/2013/WD-css3-exclusions-20130528/
Editor: Rossen Atanassov, Microsoft, ratan@microsoft.com, w3cid 49885
Editor: Vincent Hardy, Adobe, vhardy@adobe.com
Editor: Alan Stearns, Adobe, astearns@adobe.com, w3cid 46659
!Issues list: <a href="https://www.w3.org/Bugs/Public/buglist.cgi?query_format=advanced&product=CSS&component=Exclusions&resolution=---&cmdtype=doit">in Bugzilla</a>
!Test Suite: <a href="http://test.csswg.org/suites/css3-exclusions/nightly-unstable/">http://test.csswg.org/suites/css3-exclusions/nightly-unstable/</a>
Abstract: CSS Exclusions define arbitrary areas around which inline content ([[!CSS21]]) can flow. CSS Exclusions can be defined on any CSS block-level elements. CSS Exclusions extend the notion of content wrapping previously limited to floats.
Ignored Terms: div, dl, dfn
</pre>
<pre class=link-defaults>
spec:css-position-3; type:value; text:fixed
</pre>
<style type="text/css">
.singleImgExample {
display: block;
margin: auto;
}
.example-table {
table-layout: fixed;
width: 100%;
}
.example-table tr td img {
width: 90%;
}
</style>
<h2 id="intro">
Introduction</h2>
<em>This section is not normative.</em>
This specification defines features that allow inline flow
content to wrap around outside the <span>exclusion area</span> of elements.
<h3 id="values">
Value Definitions</h3>
This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
Value types not defined in this specification are defined in CSS Values & Units [[!CSS-VALUES-3]].
Combination with other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification
also accept the <a>CSS-wide keywords</a> as their property value.
For readability they have not been repeated explicitly.
<h2 id="terms">
Terminology</h2>
<dl>
<dt><dfn>Exclusion box</dfn>
<dd>
A <a href="https://www.w3.org/TR/css3-box/">box</a> ([[!CSS3BOX]]) that defines
an <span>exclusion area</span> for other boxes. The 'wrap-flow' property is
used to make an element's generated box an exclusion box. An exclusion box
contributes its <span>exclusion area</span> to its <a href="https://www.w3.org/TR/CSS2/visudet.html#containing-block-details">containing block's</a>
<span>wrapping context</span>. An element with a ''float'' computed value other
than ''float/none'' does not become an exclusion.
<dt><dfn>Exclusion area</dfn>
<dd>
The area used for excluding inline flow content around an exclusion box. The
<span>exclusion area</span> is equivalent to the
<a>border box</a>
for an exclusion box.
<p class="note">
If a user agent implements both CSS Exclusions and CSS Shapes, the
shape-outside property defines the exclusion area instead of the border box.
<dt><dfn>Exclusion element</dfn>
<dd>
An <span>exclusion element</span> is a block-level element which is not a float
and generates an <span>exclusion box</span>. An element generates an exclusion
box when its ''wrap-flow'' property's computed value is not ''auto''.
<dt><dfn>Wrapping context</dfn>
<dd>
The <span>wrapping context</span> of a box is a collection of <span>exclusion
areas</span> contributed by its associated <span>exclusion boxes</span>.
During layout, a box wraps its inline flow content in the <code>wrapping area</code>
that corresponds to the subtraction of its <span>wrapping context</span> from
its own <span>content area</span>.
A box inherits its <a href="https://www.w3.org/TR/CSS2/visudet.html#containing-block-details">containing block's</a> <span>wrapping context</span> unless it specifically
resets it using the 'wrap-through' property.
<dt><dfn>Content area</dfn>
<dd>
The <a>content area</a> is normally used for layout of the inline flow content of a box.
<dt><dfn>Wrapping area</dfn>
<dd>
The area used for layout of inline flow content of a box affected by a
<span>wrapping context</span>, defined by subtracting the <span>wrapping
context</span> from its <span>content area</span>.
<dt><dfn>Outside</dfn> and <dfn>inside</dfn>
<dd>
In this specification, <a>outside</a> refers to DOM content that is not a descendant
of an element while <a>inside</a> refers to the element's descendants.
</dl>
<h2 id="exclusions">
Exclusions</h2>
Exclusion elements define <span>exclusion areas</span> that contribute to their
containing block's <span>wrapping context</span>. As a consequence, exclusions
impact the layout of their containing block's descendants.
Elements lay out their inline content in their <span>content area</span> and wrap
around the <span>exclusion areas</span> in their associated <span>wrapping
context</span>. If the element is itself an exclusion, it does not wrap around
its own exclusion area and the impact of other exclusions on other exclusions
is controlled by the 'z-index' property as explained in the
'exclusions order' section.
<h3 id="declaring-exclusions">
Declaring exclusions</h3>
An element becomes an exclusion when its 'wrap-flow' property has a computed
value other than ''auto''.
<h4 id="wrap-flow-property">
The 'wrap-flow' property</h4>
<pre class="propdef">
Name: wrap-flow
Value: auto | both | start | end | minimum | maximum | clear
Initial: auto
Applies to: block-level elements.
Inherited: no
Percentages: N/A
Computed value: as specified except for element's whose 'float' computed value is not ''float/none'', in which case the computed value is ''auto''.
</pre>
The values of this property have the following meanings:
<dl dfn-for="wrap-flow" dfn-type=value>
<dt><dfn>auto</dfn>
<dd>
No exclusion is created. Inline flow content interacts with the element
as usual. In particular, if the element is a
<a href="https://www.w3.org/TR/CSS2/visuren.html#floats">float</a>
(see [[!CSS21]]), the behavior is unchanged.
<dt><dfn>both</dfn>
<dd>
Inline flow content can flow on all sides of the exclusion.
<dt><dfn>start</dfn>
<dd>
Inline flow content can flow around the start edge of the <span>exclusion
area</span> but must leave the area next to the end edge of the exclusion
empty.
<dt><dfn>end</dfn>
<dd>
Inline flow content can flow around the end edge of the
<span>exclusion area</span> but must leave the area next to the start edge
of the exclusion empty.
<dt><dfn>minimum</dfn>
<dd>
Inline flow content can flow around the edge of the exclusion with the
smallest available space within the flow content's containing block, and
must leave the other edge of the exclusion empty.
<dt><dfn>maximum</dfn>
<dd>
Inline flow content can flow around the edge of the exclusion with the
largest available space within the flow content's containing block, and
must leave the other edge of the exclusion empty.
<dt><dfn>clear</dfn>
<dd>
Inline flow content can only flow before and after the exclusion in the
flow content's block direction and must leave the areas next to the start
and end edges of the exclusion empty.
</dl>
If the property's computed value is ''auto'', the element does not become an
<span>exclusion</span>.
Otherwise, a computed 'wrap-flow' property value of ''both'', ''start'', ''end'',
''minimum'', ''maximum'' or ''clear'' on an element makes that element an
<a>exclusion element</a>. It's <a>exclusion area</a> is contributed
to its containing block's <a>wrapping context</a>, causing the containing
block's descendants to wrap around its <a>exclusion area</a>.
<figure>
<img alt="LTR text wrapping on left edge, RTL text wrapping on right edge, and vertical text wrapping on top edge." src="images/exclusion-writing-modes.png" style="width: 70%" />
<figcaption>Exclusion with 'wrap-flow': ''start'' interacting with various
writing modes.</figcaption>
</figure>
Determining the relevant edges of the exclusion depends on the
<a href="https://www.w3.org/TR/css3-writing-modes/#text-flow">writing mode</a> [[!CSS3-WRITING-MODES]] of the content wrapping around the 'exclusion area'.
An <a>exclusion element</a> establishes a new <a href="">block formatting
context</a> (see [[!CSS21]]) for its content.
<figure>
<img alt="General illustration showing how exclusions combine" src="images/exclusions-illustration.png" style="width: 70%" />
<figcaption>Combining exclusions</figcaption>
</figure>
The above figure illustrates how exclusions are combined. The outermost box
represents an element's content box. The A, B, C and D darker gray boxes
represent exclusions in the element's <a>wrapping context</a>.
A, B, C and D have their respective 'wrap-flow' computed to ''both'', ''start'',
''end'' and ''clear'' respectively. The lighter gray areas show the additional areas
that are excluded for inline layout as a result of the 'wrap-flow' value.
For example, the area to the right of B cannot be used for inline layout
of left-to-right writing mode content because the 'wrap-flow' for B is ''start''.
The background blue area shows what areas are available for a left-to-right
writing mode element's inline content layout.
All areas represented with a light or dark shade of gray are not available for
(left-to-right writing mode) inline content layout.
<div class="example">
The 'wrap-flow' property values applied to exclusions as grid items.
<pre>
<div id="grid">
<div id="top-right" class="exclusion"></div>
<div id="bottom-left" class="exclusion"></div>
<div id="content">Lorem ipsum…</div>
</div>
<style type="text/css">
#grid {
width: 30em;
height: 30em;
display: grid;
grid-columns: 25% 25% 25% 25%;
grid-rows: 25% 25% 25% 25%;
#top-right {
grid-column: 3;
grid-row: 2;
}
#bottom-left {
grid-column: 2;
grid-row: 3;
}
.exclusion {
wrap-flow: <see below>
}
#content {
grid-row: 1;
grid-row-span: 4;
grid-column: 1;
grid-column-span: 4;
}
</style>
</pre>
The following figures illustrate the visual rendering for different values
of the 'wrap-flow' property. The gray grid lines are marking the grid cells
and the blue area is the exclusion box (positioned by the grid).
<table class="example-table">
<tr>
<td><code class="html">.exclusion{ wrap-flow: auto; }</code></td>
<td><code class="html">.exclusion{ wrap-flow: both; }</code></td>
</tr>
<tr>
<td><img src="images/exclusion_wrap_side_auto.png" alt="Example rendering for wrap-side: auto" /></td>
<td><img src="images/exclusion_wrap_side_both.png" alt="Example rendering for wrap-side: both" /></td>
</tr>
<tr>
<td><code class="html">.exclusion{ wrap-flow: start; }</code></td>
<td><code class="html">.exclusion{ wrap-flow: end; }</code></td>
</tr>
<tr>
<td><img src="images/exclusion_wrap_side_left.png" alt="Example rendering for wrap-side: start" /></td>
<td><img src="images/exclusion_wrap_side_right.png" alt="Example rendering for wrap-side: end" /></td>
</tr>
<tr>
<td><code class="html">.exclusion{ wrap-flow: minimum; }</code></td>
<td><code class="html">.exclusion{ wrap-flow: maximum; }</code></td>
</tr>
<tr>
<td><img src="images/exclusion_wrap_side_minimum.png" alt="Example rendering for wrap-side: minimum" /></td>
<td><img src="images/exclusion_wrap_side_maximum.png" alt="Example rendering for wrap-side: maximum" /></td>
</tr>
<tr>
<td><code class="html">.exclusion{ wrap-flow: clear; }</code></td>
<td></td>
</tr>
<tr>
<td><img src="images/exclusion_wrap_side_clear.png" alt="Example rendering for wrap-side: clear" /></td>
<td></td>
</tr>
</table>
</div>
<!-- End section "wrap-flow Property" -->
<!-- End section "Declaring Exclusions" -->
<h3 id="scope-and-effect-of-exclusions">
Scope and effect of exclusions</h3>
An <span>exclusion</span> affects the inline flow content descended from the
exclusion's containing block (defined in <a href="https://www.w3.org/TR/CSS2/visudet.html#containing-block-details">CSS 2.1 10.1</a>) and that of all descendant
elements of the same containing block. All inline flow content inside the
containing block of the exclusions is affected. To stop the effect of exclusions
defined outside an element, the 'wrap-through' property can be used
(see the <a href="#propagation-of-exclusions">propagation of exclusions</a>
section below).
As a reminder, for exclusions with 'position':''fixed'', the containing block
is established by the root element.
<!-- End section "Scope and Effect of Exclusions" -->
<h3 id="propagation-of-exclusions">
Propagation of Exclusions</h3>
By default, an element inherits its parent <a>wrapping context</a>. In other
words it is subject to the exclusions defined <a>outside</a>
the element.
Setting the 'wrap-through' property to ''wrap-through/none'' prevents an
element from inheriting its parent <a>wrapping context</a>. In other words,
exclusions defined ''outside'' the element, have not effect on the element's
children layout.
<p class="note">
Exclusions defined by an element's descendants still contribute to their
containing block's <a>wrapping context</a>. If that containing block is a
child of an element with 'wrap-through' computes to ''wrap-through/none'',
or the element itself, then exclusion still have an effect on the children
of that containing block element.
</p>
<h4 id="wrap-through-property">
The 'wrap-through' Property</h4>
<pre class="propdef">
Name: wrap-through
Value: wrap | none
Initial: wrap
Applies to: block-level elements
Inherited: no
Percentages: N/A
Computed value: as specified
</pre>
The values of this property have the following meanings:
<dl dfn-for="wrap-through" dfn-type=value>
<dt><dfn>wrap</dfn></dt>
<dd>
The element inherits its parent node's <a>wrapping context</a>. Its descendant
inline content wraps around exclusions defined <a>outside</a>
the element.
<dt><dfn>none</dfn></dt>
<dd>
The element does not inherit its parent node's <a>wrapping context</a>. Its
descendants are only subject to exclusion areas defined <a>inside</a>
the element.
</dl>
<div class="example">
Using the 'wrap-through' property to control the effect of exclusions.
<pre><code class="html">
<style type="text/css">
#grid {
display: grid;
grid-columns: 25% 50% 25%;
grid-rows: 25% 25% 25% 25%;
}
#exclusion {
grid-row: 2;
grid-row-span: 2;
grid-column: 2;
wrap-flow: <see below>
}
#rowA, #rowB {
grid-row-span: 2;
grid-column: 1;
grid-column-span: 3;
}
#rowA {
grid-row: 1;
}
#rowB {
grid-row: 3;
}
</style>
<style type="text/css">
.exclusion {
wrap-flow: both;
position: absolute;
left: 20%;
top: 20%;
width: 50%;
height: 50%;
background-color: rgba(220, 230, 242, 0.5);
}
</style>
<div id="grid">
<div class=”exclusion”></div>
<div id="rowA" style=”wrap-through: wrap;”> Lorem ipsum dolor sit amet...</div>
<div id="rowB" style=”wrap-through: none;”> Lorem ipsum dolor sit amet...</div>
</div>
</code></pre>
<img class="singleImgExample" src="images/exclusion_wrap_through.png" alt="Example rendering of wrap-through: wrap | none" style="max-width:40%"/>
</div>
<!-- End section "wrap-through property" -->
<!-- End section "Propagation of Exclusions" -->
<h3 id="exclusions-order">
Exclusions order</h3>
Exclusions follow the painting order (See [[!CSS21]] Appendix E). Exclusions are
applied in reverse to the document order in which they are defined. The last exclusion
appears on top of all other exclusion, thus it affects the inline flow content of
all other preceding exclusions or elements descendant of the same containing block.
The 'z-index' property can be used to change the ordering of
<a href="https://www.w3.org/TR/CSS2/visuren.html#choose-position">positioned</a> exclusion
boxes (see [[!CSS21]]). Statically positioned exclusions are not affected by the
'z-index' property and thus follow the painting order.
<div class="example">
Ordering of exclusions.
<pre><code class="html">
<style type="text/css">
.exclusion {
wrap-flow: both;
position: absolute;
width: 200px;
}
.topleft {
top: 10px;
left: 10px;
background-color: lightblue;
}
.middle {
top: 90px;
left: 90px;
background-color: lightgreen;
}
.bottomright {
top: 170px;
left: 170px;
background-color: pink;
}
</style>
<div class="exclusion topleft">
The top left div...
</div>
<div class="exclusion middle">
The middle div...
</div>
<div class="exclusion bottomright">
The bottom right div...
</div>
</code></pre>
<table class="example-table">
<tr>
<td style="width:50%"><code class="html">.middle { z-index: auto; }</code></td>
<td style="width:50%"><code class="html">.middle { z-index: 1; }</code></td>
</tr>
<tr>
<td><img class="singleImgExample" src="images/exclusion_ordering.png" alt="Example rendering of default exclusion ordering." /></td>
<td><img class="singleImgExample" src="images/exclusion_ordering_z_order.png" alt="Example rendering of default exclusion ordering." /></td>
</tr>
</table>
</div>
<!-- End section "Order of Exclusions" -->
<div class="issue-marker wrapper">
<div class="issue-marker">
<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=15183">Issue-15183</a>
<div class="issue-details">
<p class="short-desc">Is the CSS exclusions processing model incorrect?</p>
</div>
</div>
</div>
<div class="issue">
The current draft provides a model for exclusions
without a collision-avoidance model.
The existing exclusion model in CSS uses floats,
which have both exclusion and collision-avoidance behavior.
Concerns have been raised that allowing exclusions
without collision avoidance could be harmful,
particularly with absolutely-positioned elements.
Three options should be considered:
<ol>
<li>Allow exclusions in positioning schemes
with no collision avoidance.</li>
<li>Disallow exclusions in positioning schemes
with no collision avoidance.</li>
<li>Define collision-avoidance behavior
for positioning schemes without it,
and use this behavior by default with exclusions.</li>
</ol>
</div>
<h3 id="exclusions-processing-model">
Processing model</h3>
<h4 id="exclusions-processing-model-description">
Description</h4>
Applying exclusions is a two-step process:
<ul>
<li><strong>Step 1</strong>: resolve exclusion boxes belonging to each
<a>wrapping context</a>
<li><strong>Step 2</strong>: resolve each <a>wrapping context</a> and lay out
each containing block in turn:
<ul>
<li><strong>Step 2-A</strong>: resolve the position and size of exclusion
boxes
<li><strong>Step 2-B</strong>: lay out containing block, wrapping around
each <a>exclusion area</a>
</ul>
</ul>
<h4 id="step-1">
Step 1: resolve exclusion boxes belonging to each <a>wrapping context</a></h4>
In this step, the user agent determines which <a href="https://www.w3.org/TR/CSS2/visudet.html#containing-block-details">containing block</a> each <a>exclusion area</a>
belongs to. This is a simple step, based on the definition of containing
blocks and elements with a computed value for 'wrap-flow' that is not
<code class="css">auto</code>.
<h4 id="step-2">
Step 2: resolve wrapping contexts and lay out containing blocks</h4>
In this step, starting from the top of the <a href="https://www.w3.org/TR/CSS2/visuren.html#z-index">rendering tree</a> (see [[!CSS21]]), the agent processes each
containing block in two sub-steps.
<h4 id="step-2-A">
Step 2-A: resolve the position and size of exclusion boxes</h4>
Resolving the position and size of <a>exclusion boxes</a> in the <a>wrapping
context</a> may or may not require a layout. For example, if an <a>exclusion
box</a> is absolutely positioned and sized, a layout may not be needed to
resolve its position and size. In other situations, laying out the containing
block's content is required.
When a layout is required, it is carried out without applying any <a>exclusion
area</a>. In other words, the containing block is laid out without a
<a>wrapping context</a>.
Step 2-A yields a position and size for all <a>exclusion boxes</a> in the
<a>wrapping context</a>. Each exclusion box is processed in turn, starting from
the top-most, and each <a>exclusion area</a> is computed and contributed to the
<a href="https://www.w3.org/TR/CSS2/visudet.html#containing-block-details">containing
block's</a> <a>wrapping context</a>.
Scrolling is ignored in this step when resolving the position and size of
'position': ''fixed'' <a>exclusion boxes</a>.
Once the <a href="https://www.w3.org/TR/CSS2/visudet.html#containing-block-details">containing block's</a> <a>wrapping context</a> is computed, all <a>exclusion boxes</a> in
that <a>wrapping context</a> are removed from the normal flow.
<h4 id="step-2-B">
Step 2-B: lay out containing block applying wrapping</h4>
Finally, the content of the containing block is laid out, with the inline content
wrapping around the <a>wrapping context</a>'s <a>exclusion area</a>.
When the containing block itself is an <a>exclusion box</a>, then rules on
<a href="#exclusions-order">exclusions order</a> define which exclusions affect
the inline and descendant content of the box.
<h4 id="processing-model-example">
Processing Model Example</h4>
This section illustrates the exclusions processing model with an example.
It is meant to be simple. Yet, it contains enough complexity to address the
issues of layout dependencies and re-layout.
The code snippet in the following example has two exclusions affecting the
document's inline content.
<div class="example">
<pre class="html"><html>
<style>
#d1 {
position:relative;
height: auto;
color: #46A4E9;
border: 1px solid gray;
}
#e1 {
wrap-flow: both;
position: absolute;
left: 50%;
top: 50%;
width: 40%;
height: 40%;
border: 1px solid red;
margin-left: -20%;
margin-top: -20%;
}
#d2 {
position: static;
width: 100%;
height: auto;
color: #808080;
}
#e2 {
wrap-flow: both;
position: absolute;
right: 5ex;
top: 1em;
width: 12ex;
height: 10em;
border: 1px solid lime;
}
</style>
<body>
<div id="d1">
Lorem ipsusm ...
<p id="e1"></p>
</div>
<div id="d2">
Lorem ipsusm ...
<p id="e2" ></p>
</div>
</body>
</html></pre>
</div>
The following figures illustrate:
<ul>
<li>the document's DOM tree
<li>the layout tree of generated block boxes
</ul>
<figure>
<img src="images/processing-model-example-dom.svg" width="200" alt="DOM tree nodes"/>
<figcaption>DOM tree</figcaption>
</figure>
<figure>
<img src="images/processing-model-example-layout-tree.svg" width="350" alt="Layout tree boxes"/>
<figcaption>Layout tree of generated block boxes</figcaption>
</figure>
<h5 id="example-step-1">
Step 1: resolve exclusion boxes belonging to each <a>wrapping context</a></h5>
The figures illustrate how the boxes corresponding to the element sometimes
have a different containment hierarchy in the layout tree than in the DOM tree.
For example, the box generated by <code class="idl">e1</code> is positioned in
its containing block's box, which is the <code class="idl">d1-box</code>, because
<code class="idl">e1</code> is absolutely positioned and <code class="idl">d1</code>
is relatively positioned. However, while <code class="idl">e2</code> is also absolutely
positioned, its containing block is the initial containing block (ICB). See the
section 10.1 of the CSS 2.1 specification ([[!CSS21]]) for details.
As a result of the computation of containing blocks for the tree, the boxes
belonging to the <a>wrapping context</a>s of all the elements can be determined:
<ul>
<li>The <a>wrapping context</a> for the html element contains the
<code class="idl">e2</code> box: WC-1 (Wrapping Context 1)
<li>The <a>wrapping context</a> for the body element inherits the html
element's <a>wrapping context</a>: WC-1
<li>The <a>wrapping context</a> for <code class="idl">d1</code> inherits the
body element's <a>wrapping context</a> and adds the <code class="idl">e1-box</code>
to it. So the wrapping context is made of both the
<code class="idl">e1-box</code> and the <code class="idl">e2-box</code>:
WC-2</li>
<li>The <a>wrapping context</a> for <code class="idl">d2</code> inherits the
body element's <a>wrapping context</a>: WC-1
</ul>
<h5 id="example-step-2">
Step 2: resolve wrapping contexts and lay out containing blocks</h5>
In this step, each containing block is processed in turn. For each containing
block, we (conceptually) go through two phases:
<ol>
<li>resolve the <a>wrapping context</a>: resolve the position and size of its
exclusions
<li>lay out the containing block
</ol>
In our example, this breaks down to:
<ol>
<li>resolve the position and size of the exclusions belonging to WC-1:
RWC-1 (Resolved Wrapping Context 1).
<li>lay out the initial containing block (i.e., lay out its content):
<ol>
<li>resolve the html element's <a>wrapping context</a>: RWC-1
<li>lay out the html element:
<ol>
<li>resolve the body element's <a>wrapping context</a>: RWC-1
<li>lay out the body element:
<ol>
<li>resolve the <code class="idl">d1</code> element's <a>wrapping
context</a>: RWC-2
<li>lay out the <code class="idl">d1</code> element
<li>resolve the <code class="idl">d2</code> element's <a>wrapping
context</a>: RWC-1
<li>lay out the <code class="idl">d2</code> element
</ol>
</li>
</ol>
</li>
</ol>
</li>
</ol>
<h6 id="example-resolving-rwc-1">
Resolving RWC-1</h6>
The top-most <a>wrapping context</a> in the layout tree contains the
<code class="idl">e2</code> exclusion. Its position and size needs to be
resolved. In general, computing an exclusion's position and size may or may
not require laying out other content. In this example, no content needs to be
laid out to resolve the <code class="idl">e2</code> exclusion's position
because it is absolutely positioned and its size can be resolved without
layout either. At this point, RWC-1 is resolved and can be used when laying
inline content out.</p>
<h6 id="example-resolving-rwc-2">
Resolving RWC-2</h6>
The process is similar: the position of the <code class="idl">e1</code>
exclusion needs to be resolved. Again, resolving the exclusion's position and
size may require processing the containing block (d1 here). It is the case here
because the size and position of <code class="idl">e1</code> depend on
resolving the percentage lengths. The percentages are relative to the size of
<code class="idl">d1</code>'s box. As a result, in order to resolve a size for
<code class="idl">d1</code>'s box, a first layout of <code class="idl">d1</code>
is done without any <a>wrapping context</a> (i.e., no exclusions applied).
The layout yields a position and size for <code class="idl">e1</code>'s box.
At this point, RWC-2 is resolved because the position and size of both e1 and
e2 are resolved.
<p class="note">The important aspect of the above processing example is that
once an element's <a>wrapping context</a> is resolved (by resolving its
exclusions' position and size), the position and size of the exclusions are
not re-processed if the element's size changes between the layout that may be
done without considering any <a>wrapping context</a> (as for RWC-2) and the
layout done with the resolved <a>wrapping context</a>. This is what breaks the
possible circular dependency between the resolution of <a>wrapping context</a>s
and the layout of containing blocks.</p>
<h3 id="floats-and-exclusions">
Floats and exclusions</h3>
<h4 id="floats-and-exclusions-similarities">
Similarities</h4>
There are similarities between floats and exclusions in that inline content
wraps around floats and also wraps around <span>exclusion areas</span>. However,
there are very significant differences.
<h4 id="floats-and-exclusions-differences">
Differences</h4>
<ul>
<li><strong>scope</strong>. While floats apply to content that follows in the
document, exclusions apply to content in their containing block.
<li><strong>positioning</strong>. Floats are part of the inline flow and
'float' on the line box. Authors can control how the floats move on the line
box, to the right or to the left. By contrast, exclusions can be positioned
using any positioning scheme such as grid layout ([[CSS3-GRID-LAYOUT]]),
flexible box ([[CSS3-FLEXBOX]]) or any other CSS positioning scheme.
<li><strong>separation of concerns</strong>. Making an element a float
determines both its positioning scheme and its effect on inline content.
Making an element an exclusion only determines its impact on inline content
and does not impose constraints on its positioning method.
</ul>
<h4 id="floats-interop">
Interoperability</h4>
<h5 id="effect-of-floats-on-exclusions">
Effect of floats on exclusions</h5>
Floats have an effect on the positioning of exclusions and the layout of their
inline content. For example, if an exclusion is an inline-box which happens to
be on the same line as a float, its position, as computed in
<a href="#step-2-A">Step 2-A</a> will be impacted by the float, as is any other
inline content.
<h5 id="effect-of-exclusions-on-floats">
Effect of exclusions on floats</h5>
Exclusions have an effect on the positioning of floats as they have an effect
on inline content. Therefore, in <a href="#step-2-B">Step 2-B</a>, floats will
avoid <a>exclusion areas</a>.
<h2 class="no-num" id="acks">
Acknowledgments</h2>
This specification is made possible by input from
Andrei Bucur,
Alexandru Chiculita,
Arron Eicholz,
Daniel Glazman,
Arno Gourdol,
Chris Jones,
Bem Jones-Bey,
Marcus Mielke,
Alex Mogilevsky,
Hans Muller,
Mihnea Ovidenie,
Virgil Palanciuc,
Florian Rivoal,
Peter Sorotokin,
Bear Travis,
Eugene Veselov,
Stephen Zilles
and the CSS Working Group members.
<h2 class="no-num" id="changes">Changes</h2>
<h3 class="no-num" id="recent-changes">
Changes from the <a href="https://www.w3.org/TR/2015/WD-css3-exclusions-20150115/">15 January 2015 Working Draft</a></h3>
<h3 class="no-num" id="changes-2013">
Changes from the <a href="https://www.w3.org/TR/2013/WD-css3-exclusions-20130528/">28 May 2013 Working Draft</a></h3>
<ul>
<li>Editorial fixes.
</ul>
<h3 class="no-num" id="changes-2012">
Changes from the <a href="https://www.w3.org/TR/2012/WD-css3-exclusions-20120503/">3 May 2012 Working Draft</a></h3>
<ul>
<li>Split Exclusions from Shapes.
<li>Improved exclusion order example.
<li>Editorial and markup fixes.
<li>See also the Changes section of <a href="https://www.w3.org/TR/css-shapes/#20120503">CSS Shapes</a>.
</ul>