You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Editor: Florian Rivoal, On behalf of Bloomberg, https://florian.rivoal.net/, w3cid 43241
18
18
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.
Status Text: A <a href="https://drafts.csswg.org/css-contain/issues-2019-cr.html">Disposition of Comments</a> and an <a href="https://drafts.csswg.org/css-contain/implementation-report-2019-09">Implementation Report</a> are available.
20
20
WPT Path Prefix: css/css-contain/
21
-
At risk: [=style containment=] and the ''contain: style'' value
Applies to: See <a href="#contain-applies">below</a>
@@ -108,28 +101,25 @@ Strong Containment: the 'contain' property</h2>
108
101
109
102
<dt><dfn>strict</dfn>
110
103
<dd>
111
-
This value turns on all forms of <a>containment</a><em>except</em><a>style containment</a>for the element.
104
+
This value turns on all forms of <a>containment</a> for the element.
112
105
In other words, it behaves the same as ''contain: size layout paint;''.
113
106
114
107
<wpt>
115
108
contain-strict-001.html
116
109
contain-strict-002.html
117
110
contain-strict-003.html
118
-
contain-strict-011.html
119
111
</wpt>
120
112
121
113
<dt><dfn>content</dfn>
122
114
<dd>
123
-
This value turns on all forms of <a>containment</a><em>except</em><a>size containment</a>and <a>style containment</a>for the element.
115
+
This value turns on all forms of <a>containment</a><em>except</em><a>size containment</a> for the element.
124
116
In other words, it behaves the same as ''contain: layout paint;''.
125
117
126
118
<wpt>
127
119
contain-content-001.html
128
120
contain-content-002.html
129
121
contain-content-003.html
130
122
contain-content-004.html
131
-
contain-content-011.html
132
-
133
123
</wpt>
134
124
135
125
Note: ''contain: content'' is reasonably "safe" to apply widely;
@@ -138,7 +128,7 @@ Strong Containment: the 'contain' property</h2>
138
128
However, because it doesn't apply <a>size containment</a>,
139
129
the element can still respond to the size of its contents,
140
130
which can cause layout-invalidation to percolate further up the tree than desired.
141
-
Use ''contain: strict''or ''contain: strict style''when possible,
131
+
Use ''contain: strict'' when possible,
142
132
to gain as much containment as you can.
143
133
144
134
<dt><dfn>size</dfn>
@@ -258,35 +248,6 @@ Strong Containment: the 'contain' property</h2>
258
248
contain-subgrid-001.html
259
249
</wpt>
260
250
261
-
<dt><dfn>style</dfn>
262
-
<dd>
263
-
This value turns on <a>style containment</a> for the element.
264
-
This ensures that,
265
-
for properties which can have effects on more than just an element and its descendants,
266
-
those effects don't escape the element.
267
-
268
-
<wpt>
269
-
contain-style-baseline-001.html
270
-
contain-style-breaks-001.html
271
-
contain-style-breaks-002.html
272
-
contain-style-breaks-003.html
273
-
contain-style-breaks-004.html
274
-
contain-style-breaks-005.html
275
-
contain-style-counters-001.html
276
-
contain-style-counters-002.html
277
-
contain-style-counters-003.html
278
-
contain-style-counters-004.html
279
-
counter-scoping-001.html
280
-
counter-scoping-002.html
281
-
counter-scoping-003.html
282
-
quote-scoping-001.html
283
-
quote-scoping-002.html
284
-
quote-scoping-003.html
285
-
quote-scoping-004.html
286
-
</wpt>
287
-
288
-
Note: This value is at-risk.
289
-
290
251
<dt><dfn>paint</dfn>
291
252
<dd>
292
253
This value turns on <a>paint containment</a> for the element.
@@ -714,107 +675,6 @@ Layout Containment</h3>
714
675
(When paired with <a>size containment</a>,
715
676
this optimization can be applied more liberally.)
716
677
717
-
<h3 id='containment-style'>
718
-
Style Containment</h3>
719
-
720
-
Note: Style Containment is at-risk.
721
-
722
-
Giving an element <dfn export>style containment</dfn>
723
-
and has the following effects:
724
-
725
-
1. The 'counter-increment' and 'counter-set' properties
726
-
must be <a for=property>scoped to the element's sub-tree</a>
727
-
and create a new counter.
728
-
729
-
<wpt>
730
-
contain-style-counters-001.html
731
-
contain-style-counters-002.html
732
-
contain-style-counters-003.html
733
-
contain-style-counters-004.html
734
-
</wpt>
735
-
736
-
2. The effects of the 'content' property's
737
-
''content/open-quote'', ''content/close-quote'', ''content/no-open-quote'' and ''content/no-close-quote''
738
-
must be <a for=property>scoped to the element's sub-tree</a>.
739
-
740
-
Note: This implies that the depth of quote nesting in the subtree
741
-
is unchanged and starts at the value that its context normally implies,
742
-
but that changes to the depth of quote nesting by these values inside the subtree
743
-
do not affect the depth of quote nesting outside the subtree.
744
-
745
-
<wpt>
746
-
quote-scoping-001.html
747
-
quote-scoping-002.html
748
-
quote-scoping-003.html
749
-
quote-scoping-004.html
750
-
</wpt>
751
-
752
-
<wpt>
753
-
contain-style-baseline-001.html
754
-
contain-style-breaks-001.html
755
-
contain-style-breaks-002.html
756
-
contain-style-breaks-003.html
757
-
contain-style-breaks-004.html
758
-
contain-style-breaks-005.html
759
-
</wpt>
760
-
761
-
Note: [[CSS-REGIONS-1]] has normative requirements on how <a>style containment</a> affects regions.
762
-
763
-
A <dfn export for=property lt="scoped | scoped property | scoped properties">scoped property</dfn> has its effects scoped to a particular element or subtree.
764
-
765
-
* If <dfn export for=property lt="scoped to an element | scoped to the element">scoped to an element</dfn>,
766
-
it must act as if the scoping element was the root of the document
767
-
for the purpose of evaluating the property's effects:
768
-
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,
769
-
and vice versa.
770
-
771
-
Note: “Scoping to an element” is currently unused.
772
-
It is defined as an extension point for future specifications to use.
773
-
774
-
* If <dfn export for=property lt="scoped to a sub-tree | scoped to the sub-tree | scoped to the element's sub-tree | scoped to an element's sub-tree">scoped to a sub-tree</dfn>, it's the same,
775
-
except the scoping element itself is counted as "outside" the tree,
776
-
like the rest of the document,
777
-
and the effects of the property on that element are unaffected by scoping.
778
-
When considering the effects of the scoped property on elements <em>inside</em> the subtree,
779
-
the element at the base of the subtree is treated as if it was the root of the document.
780
-
781
-
<wpt>
782
-
counter-scoping-001.html
783
-
counter-scoping-002.html
784
-
counter-scoping-003.html
785
-
</wpt>
786
-
787
-
<div class=example>
788
-
As 'counter-increment' is scoped to an element's subtree,
789
-
the first use of it within the subtree acts as if the named counter were set to 0 at the scoping element,
790
-
regardless of whether the counter had been used outside the scoping element.
791
-
Any increments made within the subtree have no effect on counters of the same name outside the scoping element.
792
-
However, the ''content/counter()'' and ''content/counters()'' value of the 'content' property is not itself scoped,
793
-
and can refer to counters established outside of the subtree.
794
-
Therefore, the following code results in <q><samp>1 1.2</samp></q> being displayed:
795
-
<pre><code highlight=markup>
796
-
<div></div>
797
-
</code></pre>
798
-
<pre><code highlight=css>
799
-
div {
800
-
contain: style;
801
-
counter-increment: n;
802
-
}
803
-
div::before, div::after {
804
-
content: counters(n, '.') " ";
805
-
}
806
-
div::after {
807
-
counter-increment: n 2;
808
-
}
809
-
</code></pre>
810
-
</div>
811
-
812
-
Possible optimizations that can be enabled by <a>style containment</a> include (but are not limited to):
813
-
814
-
1. Whenever a property is changed on a descendant of an element with [=style containment=],
815
-
calculating what part of the DOM tree is "dirtied" and might need to have its style recalculated
816
-
can stop at the containing box.
817
-
818
678
<h3 id='containment-paint'>
819
679
Paint Containment</h3>
820
680
@@ -993,12 +853,43 @@ Answers are provided below.
993
853
994
854
This appendix is <em>informative</em>.
995
855
996
-
<h3 id="2019-11-08-changes">Changes from the
856
+
<h3 id="2019-04-30-changes">Changes from the
997
857
<a href="https://www.w3.org/TR/2019/CR-css-contain-1-20190430/">Candidate Recommendation of 30 April 2019</a></h3>
998
858
999
-
<p>A full <a href="https://drafts.csswg.org/css-contain/issues-2019-cr.html">Disposition of Comments</a> is available.
859
+
<ul>
860
+
<li>
861
+
Editorial tweaks
862
+
863
+
<li>
864
+
<span id=valdef-contain-style></span>
865
+
<span id=containment-style></span>
866
+
<span id=style-containment></span>
867
+
<span id=property-scoped></span>
868
+
<span id=property-scoped-to-an-element></span>
869
+
<span id=property-scoped-to-a-sub-tree></span>
870
+
Drop the at-risk “style containment” feature from this specification, move it [[CSS-CONTAIN-2]]
1000
871
1001
-
* Editorial tweaks
872
+
<wpt>
873
+
contain-strict-011.html
874
+
contain-content-011.html
875
+
contain-style-baseline-001.html
876
+
contain-style-breaks-001.html
877
+
contain-style-breaks-002.html
878
+
contain-style-breaks-003.html
879
+
contain-style-breaks-004.html
880
+
contain-style-breaks-005.html
881
+
contain-style-counters-001.html
882
+
contain-style-counters-002.html
883
+
contain-style-counters-003.html
884
+
contain-style-counters-004.html
885
+
counter-scoping-001.html
886
+
counter-scoping-002.html
887
+
counter-scoping-003.html
888
+
quote-scoping-001.html
889
+
quote-scoping-002.html
890
+
quote-scoping-003.html
891
+
quote-scoping-004.html
892
+
</wpt>
1002
893
1003
894
<h3 id="2018-11-08-changes">Changes from the
1004
895
<a href="https://www.w3.org/TR/2018/CR-css-contain-1-20181108/">Candidate Recommendation of 08 November 2018</a></h3>
0 commit comments