-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.src.html
More file actions
147 lines (120 loc) · 5.7 KB
/
Overview.src.html
File metadata and controls
147 lines (120 loc) · 5.7 KB
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
<h1>CSS Containment Module Level 3</h1>
<pre class=metadata>
Level: 3
Shortname: css-containment
Status: ED
Group: csswg
ED: http://dev.w3.org/csswg/css-containment/
Editor: Tab Atkins, Google, http://xanthir.com/contact/
Abstract: This CSS module describes the 'contain' property, which indicates that the element's subtree is independent of the rest of the page. This enables heavy optimizations by user agents when used well.
Ignored Terms: scrollWidth, scrollHeight, clientWidth, clientHeight, formatting context
Link Defaults: css-lists-3 (property) counter-increment
</pre>
<h2 id='intro'>
Introduction</h2>
Efficiently rendering a website relies on the User Agent being able to detect what parts of the page are being displayed,
which parts might affect the currently-displayed section,
and what can be ignored.
There are various heuristics that can be used to guess when a given sub-tree is independent of the rest of the page in some manner,
but they're fragile,
so innocuous changes to a page may inadvertently make it flunk the heuristics and fall into a slow mode.
There are also many things that would be good to isolate which are difficult or impossible to detect in a heuristic manner.
To alleviate these problems
and allow strong, predictable isolation of a subtree from the rest of the page,
this specification defines a 'contain' property.
<h2 id='containment'>
Strong Containment: the 'contain' property</h2>
<pre class='propdef'>
Name: contain
Value: none | strict
Initial: none
Inherited: no
Applies to: all elements
Media: all
Computed value: specified value
</pre>
The 'contain' property allows an author to indicate that an element and its contents are,
as much as possible,
<em>independent</em> of the rest of the document tree.
This allows user agents to utilize much stronger optimizations when rendering a page using 'contain' properly,
and allows authors to be confident that their page won't accidentally fall into a slow code path
due to an innocuous change.
<dl dfn-type=value dfn-for=containment>
<dt><dfn>none</dfn>
<dd>
This value indicates that the property has no effect.
The element renders as normal,
with no containment effects applied.
<dt><dfn>strict</dfn>
<dd>
The ''containment/strict'' value indicates that the element is <a>strictly contained</a>,
so that its contents are guaranteed to have no effect on the rest of the page outside the element's bounds.
</dl>
<p class='issue'>
Do we want to break this apart,
so people can opt into particular forms of containment without going whole-hog,
if they really need to?
<div class='example'>
'contain' is useful when used widely on a page,
particularly when a page contains a lot of "widgets" which are all independent.
For example, assume a micropost social network had markup something like this:
<pre class='css'>
<body>
<aside class='sidebar'>...</aside>
<article class='messages'>
<section class='message'>
Lol, check out this dog: images.example.com/jsK3jkl
</section>
<section class='message'>
I had a ham sandwich today. #goodtimes
</section>
<section class='message'>
I have political opinions that you need to hear!
</section>
…
</article>
</body>
</pre>
There are probably a <em>lot</em> of messages displayed on the site,
but each is independent and won't affect anything else on the site.
As such, each can be marked with ''contain: strict'' to communicate this to the user agent,
so it can optimize the page and skip a lot of computation for messages that are off-screen.
</div>
An element that is <dfn export>strictly contained</dfn> operates under the following restrictions:
<ol>
<li>
The contents of the element must be clipped to the element's content box.
<li>
The element must not provide a scrolling user interface (such as a scrollbar),
nor be scrollable by any other means, such as dragging or script-based interaction.
<li>
The <a attribute>scrollWidth</a> and <a attribute>scrollHeight</a> attributes of the element's <code>DOM</code> must return the same values as the <a attribute>clientWidth</a> and <a attribute>clientHeight</a> attributes, respectively.
<p class='issue'>
Make sure this is the right way to define this. Also, ensure it's sane.
<li>
The element must act as a containing block for absolutely positioned and fixed positioned descendants.
<li>
The element must be a <a>formatting context</a>.
<li>
The following properties must have no effect on descendants of the element:
<ul>
<li>'break-*' (and the related aliases)
<li>'page-group'
<li>'bookmark-*'
<li>'string-set'
</ul>
<li>
The 'counter-increment', 'counter-set', 'flow-from', and 'flow-into' properties must be <a title='scoped property'>scoped</a> to the element's sub-tree.
</ol>
A <dfn export>scoped property</dfn> has its effects scoped to a particular element or subtree.
It must act as if the scoping element was the root of the document
for the purpose of evaluating the property's effects:
any uses of the property outside the scoping element must have no effect on the uses of the property on or in the scoping element,
and vice versa.
If scoped to a sub-tree, it's the same,
except the scoping element itself is counted as "outside" the tree,
like the rest of the document.
For example, if 'counter-increment' is scoped to an element,
the first use of it within the subtree acts as if the named counter were set to 0 at the scoping element,
regardless of whether the counter had been used outside the scoping element.
Any increments made within the subtree have no effect on counters of the same name outside the scoping element.