Skip to content

Commit 16aad72

Browse files
committed
[css-sizing-4] First draft of c-i-s:auto. #5668
1 parent a8ba11f commit 16aad72

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

css-sizing-4/Overview.bs

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties</h3>
487487

488488
<pre class=propdef>
489489
Name: contain-intrinsic-width, contain-intrinsic-height, contain-intrinsic-block-size, contain-intrinsic-inline-size
490-
Value: none | <<length>>
490+
Value: none | <<length>> | auto <<length>>
491491
Initial: none
492492
Inherited: no
493493
Applies to: elements with [=size containment=]
@@ -517,6 +517,12 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties</h3>
517517

518518
: <dfn><<length>></dfn>
519519
:: The corresponding axis has an [=explicit intrinsic inner size=] of the specified <<length>>.
520+
521+
: <dfn>auto <<length>></dfn>
522+
:: The corresponding axis has an [=explicit intrinsic inner size=]
523+
of its [=last remembered size=].
524+
If a [=last remembered size=] does not yet exist,
525+
instead use the specified <<length>>.
520526
</dl>
521527

522528
If an element has an [=explicit intrinsic inner size=] in an axis,
@@ -544,7 +550,7 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties</h3>
544550

545551
<pre class="propdef shorthand">
546552
Name: contain-intrinsic-size
547-
Value: [ none | <<length>> ]{1,2}
553+
Value: [ none | <<length>> | auto <<length>> ]{1,2}
548554
</pre>
549555

550556
'contain-intrinsic-size' is a shorthand property
@@ -555,6 +561,53 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties</h3>
555561
If only one value is given,
556562
it applies to both properties.
557563

564+
<h4 id='last-remembered' dfn lt="last remembered size" export>
565+
Last Remembered Size</h4>
566+
567+
[=Size containment=] is very valuable for ensuring a page can render efficiently,
568+
restricting the scope of layout work that can happen
569+
as a result of an element changing its rendering.
570+
However, it's also very restrictive for the author,
571+
requiring them to correctly predict what the size of the element will be;
572+
if this guess is incorrect,
573+
even slightly,
574+
it can cause unsightly scrollbars or accidentally-hidden content.
575+
576+
The ''contain-intrinsic-size: auto'' value allows a middle-ground:
577+
it lays out the element and records its sizes
578+
<em>just before [=size containment=] begins to apply</em>,
579+
then remembers this value
580+
and uses it from then on,
581+
offering a <em>probably accurate</em> size based on an actual layout of the contents
582+
while still offering the performance benefits of [=size containment=]
583+
from then onward.
584+
585+
<div algorithm="last remembered size">
586+
The [=last remembered size=] of an element is determined by:
587+
588+
* At the time that ResizeObserver events are determined and delivered,
589+
if an element has ''contain-intrinsic-size: auto''
590+
but does not have [=size containment=],
591+
record its current inner dimensions
592+
as its [=last remembered size=].
593+
594+
* If the element is being rendered for the first time,
595+
or has just switched from not being rendered to being rendered
596+
(for example, it was previously [=skipped contents|skipped=] due to being off-screen),
597+
then, even if it has [=size containment=],
598+
it must be laid out as if it does <em>not</em> have [=size containment=],
599+
and the resulting inner dimensions
600+
must be recorded as its [=last remembered size=].
601+
602+
(It is then rendered as usual,
603+
applying [=size containment=],
604+
but also using this [=last remembered size=]
605+
due to ''contain-intrinsic-size: auto''.)
606+
607+
An element might not have a [=last remembered size=],
608+
if it has not yet been rendered.
609+
</div>
610+
558611
<h4 id='cis-scrollbars'>
559612
Interaction With ''overflow: auto''</h4>
560613

0 commit comments

Comments
 (0)