-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview.bs
543 lines (460 loc) · 22.2 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
<h1>CSS Overflow Module Level 3</h1>
<pre class="metadata">
Status: ED
Work Status: Exploring
ED: https://drafts.csswg.org/css-overflow/
Shortname: css-overflow
Group: csswg
Level: 3
TR: https://www.w3.org/TR/css-overflow-3/
Previous version: https://www.w3.org/TR/2013/WD-css-overflow-3-20130418/
Editor: L. David Baron, Mozilla, http://dbaron.org/
Editor: Florian Rivoal, On behalf of Bloomberg, florian@rivoal.net, http://florian.rivoal.net/
Abstract: This module contains the features of CSS relating to scrollable overflow handling in visual media.
!Change Log: <a href="https://hg.csswg.org/drafts/log/tip/css-overflow/Overview.bs">from 27 January 2015 to the present</a>
!Change Log: <a href="https://hg.csswg.org/drafts/log/tip/css-overflow/Overview.src.html">from 28 March 2013 to 27 January 2015</a>
!Change Log: <a href="https://hg.csswg.org/drafts/log/tip/css3-overflow/Overview.src.html">from 31 July 2012 to 27 March 2013</a>
Ignored Vars: B, P
Ignored Terms: padding edge
</pre>
<!-- FIXME: Regressions from bikeshed conversion: -->
<!-- - Value lines in propdef tables no longer link to #values. -->
<!-- - no longer says "Test suite: none yet" -->
<!-- - Abstract has the most introductory sentence last -->
<!-- FIXME: other bikeshed issues -->
<pre class="link-defaults">
spec:css-transforms-1; type:property; text:transform-style
type: dfn; spec:css-multicol-1; text:overflow column
</pre>
<!-- FIXME: the break-* link doesn't actually work! -->
<pre class="anchors">
url: https://www.w3.org/TR/2008/CR-css3-marquee-20081205/#the-overflow-style; type: property; text: overflow-style;
</pre>
<h2 id="intro">
Introduction</h2>
In CSS Level 1 [[CSS1]], placing more content than would fit
inside an element with a specified size
was generally an authoring error.
Doing so caused the content to extend
outside the bounds of the element,
which would likely cause
that content to overlap with other elements.
CSS Level 2 [[CSS21]] introduced the 'overflow' property,
which allows authors to have overflow be handled by scrolling,
which means it is no longer an authoring error.
It also allows authors to specify
that overflow is handled by clipping,
which makes sense when the author's intent
is that the content not be shown.
This specification introduces the long-standing de-facto 'overflow-x' and 'overflow-y' properties,
and defines overflow handling more fully.
[Something something 'max-lines'.]
<!--
████████ ██ ██ ████████ ████████ ██████
██ ██ ██ ██ ██ ██ ██ ██
██ ████ ██ ██ ██ ██
██ ██ ████████ ██████ ██████
██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██
██ ██ ██ ████████ ██████
-->
<h2 id="overflow-concepts">
Types of overflow</h2>
CSS uses the term <dfn export>overflow</dfn> to describe
the contents of a box
that extend outside one of that box's edges
(i.e., its <i>content edge</i>, <i>padding edge</i>,
<i>border edge</i>, or <i>margin edge</i>).
The term might be interpreted as
elements or features that cause this overflow,
the non-rectangular region occupied by these features,
or, more commonly,
the minimal rectangle that bounds that region.
A box's overflow is computed based on the layout and styling of the box itself
and of all descendants whose <a>containing block chain</a>
includes the box.
In most cases, <a>overflow</a>
can be computed for any box
from the bounds and properties of that box itself,
plus the <a>overflow</a>
of each of its children.
However, this is not always the case; for example,
when ''transform-style: preserve-3d'' [[CSS3-TRANSFORMS]] is used on
some of the children, any of their descendants with
''transform-style: preserve-3d'' must also be examined.
There are three different types of overflow,
which are used for different purposes by the UA:
<ul>
<li><a>ink overflow</a>
<li><a>scrollable overflow</a>
<li><a>border-box overflow</a>
</ul>
<h3 id="ink">Ink overflow</h3>
The <dfn export>ink overflow</dfn> of a box
is the part of that box and its contents that
creates a visual effect outside of
the box's border box.
Ink overflow is the overflow of painting effects defined to not affect layout
or otherwise extend the <a>scrollable overflow region</a>,
such as <a href="https://www.w3.org/TR/css-backgrounds/#box-shadow">box shadows</a>,
<a href="">border images</a>,
<a href="https://www.w3.org/TR/css-text-decor-3/">text decoration</a>,
overhanging glyphs (with negative side bearings,
or with ascenders/descenders extending outside the em box),
<a href="https://www.w3.org/TR/CSS2/ui.html#dynamic-outlines">outlines</a>,
etc.
Issue: What about 'hanging-punctuation'?
Since some effects in CSS (for example, the blurs in
'text-shadow' [[CSS3TEXT]] and 'box-shadow' [[CSS3BG]])
do not define what visual extent they cover, the extent
of the <a>ink overflow</a> is undefined.
The <dfn export>ink overflow region</dfn> is the non-rectangular area
occupied by the <a>ink overflow</a>, and the
<dfn export>ink overflow rectangle</dfn> is
the minimal rectangle whose axis is aligned to the box's axes
and contains the <a>ink overflow region</a>.
Note that the <a>ink overflow rectangle</a> is a rectangle
in the box's coordinate system, but might be non-rectangular
in other coordinate systems due to transforms [[CSS3-TRANSFORMS]].
<h3 id="scrollable">
Scrollable overflow</h3>
The <dfn export>scrollable overflow</dfn> of a box is the
set of things extending outside of that box's padding edge
for which a scrolling mechanism needs to be provided.
The <dfn export>scrollable overflow region</dfn> is the non-rectangular region
occupied by the <a>scrollable overflow</a>, and the
<dfn export>scrollable overflow rectangle</dfn> is
the minimal rectangle whose axis is aligned to the box's axes
and contains the <a>scrollable overflow region</a>.
The <a>scrollable overflow region</a> is the union of:
<ul>
<li>the box’s own content and padding areas
<li>all line boxes directly contained by the box
<li>the margin boxes <em>unioned with</em> the border boxes
of all boxes for which it is the containing block
(accounting for transforms as described below).
Issue: Only Blink (and presumably WebKit) use the margin box for abspos; other browsers use the border box.
Can we convince everyone else to change? Because using the border box is kindof hostile.
<!-- testcase: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cstyle%3E%0A%20%20div%20%7B%20height%3A%2050px%3B%20overflow%3A%20scroll%3B%20border%3A%20solid%3B%20position%3A%20relative%3B%7D%0A%20%20p%20%7B%20margin%3A%2025px%3B%20background%3A%20red%3B%20%7D%0A%20%20q%20%7B%20position%3A%20absolute%3B%20background%3A%20blue%3B%20top%3A%2025px%3B%20margin%3A%2025px%3B%20%7D%0A%3C%2Fstyle%3E%0A%3Cdiv%3E%0A%20%20%3Cp%3ETest%20%3Cq%3ETest2%0A%3C%2Fdiv%3E -->
<li>the <a>scrollable overflow regions</a> of all of the above boxes
(accounting for transforms as described below),
provided they themselves have ''overflow: visible''
(i.e. do not themselves trap the overflow)
and that overflow is not already clipped
by the 'clip' or 'clip-path' properties.
Issue: What about masking?
</ul>
<p class="issue">
The following definition should be rewritten to use
the concept of <a href="https://drafts.csswg.org/css-transforms/#3d-rendering-context">3D rendering context</a> [[!CSS3-TRANSFORMS]]
and related terms,
particularly once those concepts stabilize following changes
proposed in the CSS WG meeting on the morning of 2014-01-28.
Given the following definitions
<span class="issue">which belong in [[CSS3-TRANSFORMS]]</span>:
<dl>
<dt><dfn>3d-preserving child</dfn>
<dd>
A child box <var>B</var> of a containing block <var>C</var>
is a 3d-preserving child
if it has ''transform-style: preserve-3d''
and the user-agent is not required to flatten it
based on the <a href="https://www.w3.org/TR/css3-transforms/#transform-style-property">requirements</a> in [[!CSS3-TRANSFORMS]].
<dt><dfn>non-3d-preserving child</dfn>
<dd>
A child <var>C</var> of a box <var>P</var> is a non-3d-preserving-child
if it is not a <a>3d-preserving child</a>.
<dt><dfn>3d-preserving descendant</dfn>
<dd>
Box <var>D</var> is a 3d-preserving descendant of box <var>A</var>
if <var>A</var> is an ancestor of D,
and <var>D</var> and all of the boxes (if any)
in the <a>containing block chain</a> from <var>D</var> to <var>A</var>
are <a>3d-preserving child</a> boxes.
</dl>
The <a>scrollable overflow</a> of a box is the union of the following things,
all adjusted for transforms <span class="issue">undefined concept!</span> into the box's coordinate space:
<ul>
<li>
for the box and all of its <a>3d-preserving descendant</a> boxes:
<ul>
<li>the box's own padding edge (for the box itself) or border edge (for <a>3d-preserving descendant</a> boxes)</li>
<li>the bounds <span class="issue">undefined term!</span> of any text directly in the box</li>
<li><span class="issue">MORE HERE!</span>
</ul>
<li>
for all the <a>non-3d-preserving child</a> boxes of the
box and its <a>3d-preserving descendant</a> boxes,
the scrollable overflow of the box
</li>
</ul>
<p class="issue">
I wrote this definition off the top of my head,
so it can't possibly be right.
It's missing tons of pieces!
<p class="issue">
The handling of preserve-3d subtrees here is probably wrong;
the elements should probably count
only towards the overflow of the element that flattens them.
Note that the <a>scrollable overflow rectangle</a> is a always rectangle
in the box's own coordinate system, but might be non-rectangular
in other coordinate systems due to transforms [[CSS3-TRANSFORMS]].
Issue: Browsers seem to agree on using axis-aligned rectangles (in the element's own coord space)
to determine overflow.
This means scrollbars can appear when not actually necessary.
See <a href="http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cdiv%20class%3Dparent%3E%3Cdiv%20class%3Dchild%3E%3Cdiv%20class%3D%27grandchild%27%3E%3C%2Fdiv%3E%3C%2Fdiv%3E%3C%2Fdiv%3E%0A%3Cstyle%3E%0Adiv%20{%20padding%3A%2030px%3B%20min-width%3A%2030px%3B%20float%3A%20left%3B%20border%3A%20thin%20dotted%3B%20background%3A%20rgba%280%2C0%2C0%2C.2%29%3B}%0A.parent%20{%20overflow%3A%20auto%3B%20background%3A%20rgba%28255%2C0%2C0%2C.2%29%3B%20}%0A.child%20{%20transform%3A%20rotate%28-45deg%29%3B%20padding%3A%203px%3B%20background%3A%20rgba%280%2C255%2C0%2C.2%29%3B%20}%0A.grandchild%20{%20transform%3A%20rotate%2845deg%29%20scale%28.9%29%3B%20background%3A%20rgba%280%2C0%2C255%2C.2%29%3B%20}">testcase</a>
(adjust the ''scale(.9)'' to ''scale(.7)'' to see the scrollbars disappear,
as the blue grandchild is no longer growing the bounds of the green child).
Is this behavior we want to spec,
or is it something browsers would like to fix someday?
<h3 id="border-box">
Border box overflow</h3>
<p class="issue">
This concept has been proposed for some uses, such as for
determining what the 'outline' property goes around, and
as the basis of a coordinate system for specifying clips and masks,
but it's not clear if it's needed.
The <dfn>border-box overflow</dfn> of a box is the
union of the box's border edge and the border edges of
the box's descendants.
<p class="issue">
If needed, define more formally, as for scrollable overflow above.
(Maybe even share the definitions in an appropriate way!)
The <dfn>border-box overflow region</dfn> is the non-rectangular region
occupied by the <a>border-box overflow</a>, and the
<dfn>border-box overflow rectangle</dfn> is
the minimal rectangle whose axis is aligned to the box's axes
and contains the <a>border-box overflow region</a>.
Note that the <a>border-box overflow rectangle</a> is a rectangle
in the box's coordinate system, but might be non-rectangular
in other coordinate systems due to transforms [[CSS3-TRANSFORMS]].
<!--
███████ ██ ██ ████████ ████████ ████████ ██ ███████ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██████ ████████ ██████ ██ ██ ██ ██ ██ ██ ███████ █████████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ███ ████████ ██ ██ ██ ████████ ███████ ███ ███
-->
<h2 id="overflow-properties">
Scrollable Overflow: the 'overflow-x', 'overflow-y', and 'overflow' properties</h2>
These properties specify whether a box’s content
(including any <a>ink overflow</a>)
is clipped to its padding edge,
and if so,
whether it is a <dfn export>scrollable box</dfn>
that allows the user to scroll clipped parts of its <a>scrollable overflow region</a>
into view.
<pre class=propdef>
Name: overflow-x, overflow-y
Value: ''visible'' | ''hidden'' | ''clip'' | ''scroll'' | ''auto''
Initial: ''visible''
Applies to: block containers [[!CSS21]], flex containers [[!CSS3-FLEXBOX]], and grid containers [[!CSS3-GRID-LAYOUT]]
Inherited: no
Percentages: N/A
Media: visual
Computed value: see below
Animatable: no
</pre>
The 'overflow-x' property specifies
the handling of <a>overflow</a> in the horizontal direction
(i.e., overflow from the left and right sides of the box),
and the 'overflow-y' property specifies the handling
of <a>overflow</a> in the vertical direction
(i.e., overflow from the top and bottom sides of the box).
<pre class=propdef>
Name: overflow
Value: ''visible'' | ''hidden'' | ''clip'' | ''scroll'' | ''auto''
Initial: see individual properties
Applies to: block containers [[!CSS21]], flex containers [[!CSS3-FLEXBOX]], and grid containers [[!CSS3-GRID-LAYOUT]]
Inherited: no
Percentages: N/A
Media: visual
Computed value: see individual properties
Animatable: no
Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
</pre>
The 'overflow' property is a shorthand property
that sets the specified values of both 'overflow-x' and 'overflow-y'
to the value specified for 'overflow'.
Values have the following meanings:
<dl dfn-for="overflow, overflow-x, overflow-y" dfn-type="value">
<dt><dfn>visible</dfn>
<dd>
There is no special handling of overflow, that is, it
may be rendered outside the box.
The box is not a <a>scrollable box</a>.
<dt><dfn>hidden</dfn>
<dd>
This value indicates that
the box’s content is clipped to its padding box
and that no scrolling user interface should be provided by the UA
to view the content outside the clipping region.
However, the content may still be scrolled programatically,
for example using the mechanisms defined in [[CSSOM-VIEW]],
and the box is therefore still a <a>scrollable box</a>.
<dt><dfn>clip</dfn>
<dd>
Like ''hidden'',
this value indicates that
the box’s content is clipped to its padding box
and that no scrolling user interface should be provided by the UA
to view the content outside the clipping region.
In addition, unlike ''overflow: hidden''
which still allows programmatic scrolling,
''overflow: clip'' forbids scrolling entirely,
through any mechanism,
and therefore the box is not a <a>scrollable box</a>.
Issue: Mozilla implements -moz-hidden-unscrollable,
which is similar to ''clip'',
except that it does not cause the element to establish a BFC.
Should we match that?
<dt><dfn>scroll</dfn>
<dd>
This value indicates that
the content is clipped to the padding box,
but can be scrolled into view
(and therefore the box is a <a>scrollable box</a>).
Furthermore, if the user agent uses a scrolling mechanism
that is visible on the screen (such as a scroll bar or a panner),
that mechanism should be displayed
whether or not any of its content is clipped.
This avoids any problem with scrollbars appearing
and disappearing in a dynamic environment.
When this value is specified and the target medium is ''print'',
overflowing content may be printed.
<dt><dfn>auto</dfn>
<dd>
This value indicates that
the box’s content is clipped to the padding box,
but can be scrolled into view
(and therefore the box is a <a>scrollable box</a>).
However, if the user agent uses a scrolling mechanism
that is visible on the screen (such as a scroll bar or a panner),
that mechanism should only be displayed
if there is overflow.
</dl>
If the computed value of 'overflow' on a <a>block box</a> is not ''overflow/visible'',
it creates a new <a>block formatting context</a> for its content.
<h3 id="overflow-computed-values">
Overflow Value Computation and Propagation</h3>
<p>The computed values of 'overflow-x' and 'overflow-y'
are determined from the <a>specified values</a> [[!CSS3CASCADE]]
based on the following rules:
<ol>
<li>
If one <a>specified value</a> is ''overflow/visible''
and the other is not,
then computed values are the <a>specified values</a>
with ''overflow/visible'' changed to ''overflow/auto''.
</li>
<li>
Otherwise, if both <a>specified values</a> are ''overflow/visible''
and the computed value of 'contain' is
one that activates <a>paint containment</a>
(e.g. ''contain:strict''
or ''contain: paint''
or ''contain: layout paint''…),
then the computed values of both 'overflow-x' and 'overflow-y'
are changed to ''overflow/clip''.</li>
<li>
Otherwise, the computed values are as specified.
</li>
</ol>
</div>
UAs must apply the 'overflow' property
set on the root element to the viewport.
For HTML UAs,
if this would result in the viewport having ''visible'' overflow,
the UA must instead apply the 'overflow' property
set on the <{body}> element to the viewport.
In either case,
the used value of 'overflow' for the element from which the value is propagated
must evaluate to ''visible''.
If this application would result in the viewport having ''visible'' overflow,
the UA must instead treat the viewport as having ''overflow/auto'' overflow.
<h3 id="scrollbar-layout">
Scrollbars and Layout</h3>
In the case of a scrollbar being placed on an edge of the element's box,
it should be inserted between the inner border edge
and the outer padding edge.
Any space taken up by the scrollbars should be
taken out of (subtracted from the dimensions of)
the containing block formed by the element with the scrollbars.
Issue: import examples from [[CSS3-BOX]].
<h3 id="scrolling-direction">
Scrolling Origin, Direction, and Restriction</h3>
The <dfn export>initial scroll position</dfn>,
that is, the initial position of
the box’s <a>scrollable overflow region</a>
with respect to its border box,
prior to any user or programmatic scrolling that changes it,
is dependent on the box’s <a>writing mode</a>,
and is by default the <a>block-start</a>/</a>inline-start</a> edge
of the box’s <a>padding edge</a>.
However, the 'align-content' and 'justify-content' properties [[!CSS-ALIGN-3]]
can be used to change this.
Due to Web-compatibility constraints
(caused by authors exploiting legacy bugs to surreptitiously hide content from visual readers but not search engines and/or speech output),
UAs must clip the <a>scrollable overflow region</a>
of <a>scrollable boxes</a>
on the <a>block-start</a> and </a>inline-start</a> sides of the box
(thereby behaving as if they had no <a>scrollable overflow</a> on that side).
The viewport uses the <a>principal writing mode</a> for these calculations.
<p class="issue">
[[CSS3-MARQUEE]] describes an 'overflow-style' property,
but it has not picked up implementation experience
that the working group is aware of.
Should this document treat 'overflow-style' as a defunct proposal,
or should this document describe the 'overflow-style' property
and attempt to revive it,
despite that implementations have implemented
'overflow-x' and 'overflow-y' instead?
<h2 id="max-lines">
Limiting Number of Visible Text Lines: the 'max-lines' property</h2>
<pre class=propdef>
Name: max-lines
Value: none | <<integer>>
Initial: none
Applies to: all non-inline elements
Inherited: no
Animatable: as integer
Percentages: N/A
Media: visual
Computed value: specified value
</pre>
Issue: Add back 'max-lines', so we can kill the unspecified WebKit feature that does this poorly.
<h2 id="static-media">
Overflow in static media</h2>
<p class="issue">
This specification should define useful behavior
for all values of 'overflow'
in static media (such as print).
Current implementation behavior is quite poor and
produces unexpected results when authors have not considered
what will happen when
the content they produce for interactive media
is printed.
Privacy and Security Considerations {#priv-sec}
===============================================
This specification introduces no new privacy or security concerns.
<h2 class=no-num id="acknowledgments">
Acknowledgments</h2>
<p>
Thanks especially to the feedback from
Rossen Atanassov,
Bert Bos,
Tantek Çelik,
John Daggett,
fantasai,
Daniel Glazman,
Vincent Hardy,
Håkon Wium Lie,
Peter Linss,
Robert O'Callahan,
Florian Rivoal,
Alan Stearns,
Steve Zilles,
and all the rest of the
<a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.