Skip to content

Commit 2e767ef

Browse files
kojiishitabatkins
andauthored
[css-sizing-4] Add responsively-sized iframes (#13099)
* [css-sizing-4] Add responsively-sized iframes Based on the resolutions at: #1771 (comment) * Apply suggestion from @tabatkins * Rewrite a bit * Did an editorial rewrite of the "responsively-sized iframes" section; should be zero normative changes. * Rejiggered the syntax of the properties a little, integrating it better with the existing syntax, so that 'from-element' works the same as 'auto' (being a magic source of intrinsic size) and requiring a fallback size to be specified. --------- Co-authored-by: Tab Atkins Jr. <jackalmage@gmail.com>
1 parent fdeb545 commit 2e767ef

File tree

1 file changed

+90
-9
lines changed

1 file changed

+90
-9
lines changed

css-sizing-4/Overview.bs

Lines changed: 90 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties</h3>
530530

531531
<pre class=propdef>
532532
Name: contain-intrinsic-width, contain-intrinsic-height, contain-intrinsic-block-size, contain-intrinsic-inline-size
533-
Value: auto? [ none | <<length [0,∞]>> ]
533+
Value: [ auto | from-element ]? [ none | <<length [0,∞]>> ]
534534
Initial: none
535535
Inherited: no
536536
Logical property group: contain-intrinsic-size
@@ -554,25 +554,45 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties</h3>
554554
usually ending up with a larger content size than specified.
555555

556556
<dl dfn-type=value dfn-for="contain-intrinsic-width, contain-intrinsic-height, contain-intrinsic-block-size, contain-intrinsic-inline-size, contain-intrinsic-size">
557-
: <dfn>auto</dfn>? [ <dfn>none</dfn> | <<length>> ]
557+
: <dfn>none</dfn> | <dfn><<length>></dfn>
558+
::
559+
If no other 'contain-intrinsic-size' value
560+
(such as ''contain-intrinsic-size/auto'')
561+
is providing an [=explicit intrinsic inner size=],
562+
the corresponding axis either doesn't have an [=explicit intrinsic inner size=]
563+
(if ''contain-intrinsic-size/none'' is specified)
564+
or has an [=explicit intrinsic inner size=] of the specified <<length>>.
565+
566+
: <dfn>auto</dfn>
558567
:: If ''contain-intrinsic-size/auto'' is specified
559568
and the element has a [=last remembered size=]
560569
and is currently [=skipping its contents=],
561570
its [=explicit intrinsic inner size=] in the corresponding axis
562571
is the [=last remembered size=] in that axis.
563-
572+
564573
Note: This occurs, for example,
565574
when an element with ''content-visibility: auto''
566575
is off-screen.
567576

568-
Otherwise,
569-
the corresponding axis either doesn't have an [=explicit intrinsic inner size=]
570-
(if ''contain-intrinsic-size/none'' is specified)
571-
or has an [=explicit intrinsic inner size=] of the specified <<length>>.
572-
573577
<wpt pathprefix="css/css-contain/">
574578
content-visibility/content-visibility-058.html
575579
</wpt>
580+
581+
: <dfn>from-element</dfn>
582+
:: If ''contain-intrinsic-size/from-element'' is specified
583+
and the element is a [=replaced element=]
584+
with an [=internal layout intrinsic size=],
585+
its [=explicit intrinsic inner size=] in the corresponding axis
586+
is that size.
587+
588+
Note: Whether a [=replaced element=]
589+
has an [=internal layout intrinsic size=]
590+
is defined by the [=host language=].
591+
In HTML, only <<iframe>>s do so.
592+
593+
Issue: Should this apply even when ''contain:layout'' isn't specified?
594+
595+
Issue: The name needs further discussion.
576596
</dl>
577597

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

601621
<pre class="propdef shorthand">
602622
Name: contain-intrinsic-size
603-
Value: [ auto? [ none | <<length>> ] ]{1,2}
623+
Value: [ [ auto | from-element ]? [ none | <<length [0,∞]>> ] ]{1,2}
604624
</pre>
605625

606626
'contain-intrinsic-size' is a shorthand property
@@ -656,6 +676,67 @@ Last Remembered Size</h4>
656676
even across changes such as going to/from ''display: none''.
657677
</div>
658678

679+
<h4 id='responsive-iframes' dfn lt="responsively-sized iframe" export>
680+
Responsively-sized iframes</h4>
681+
682+
Some [=replaced elements=] can contain "normal" flowed content,
683+
such as HTML <{iframe}>s.
684+
For privacy and security reasons,
685+
these elements do not, by default,
686+
expose any information about their internal contents' sizing
687+
to the outside page,
688+
instead just using a static, predetermined intrinsic size,
689+
and making their contents scrollable.
690+
The ''contain-intrinsic-size/from-element'' value of 'contain-intrinsic-size'
691+
allows these elements to opt into exposing their actual content size,
692+
known as their <dfn export>internal layout intrinsic size</dfn>.
693+
694+
Which elements have an [=internal layout intrinsic size=],
695+
and how it's determined,
696+
are decided by the host language.
697+
In HTML, only <{iframe}> elements can have an [=internal layout intrinsic size=],
698+
and further,
699+
only when the contained document has also opted in
700+
via a <code>&lt;meta name=responsize-embedded-sizing></code> element.
701+
702+
An <{iframe}> initially doesn't have an [=internal layout intrinsic size=].
703+
When an <{iframe}>'s internal document is loaded,
704+
if the required <{meta}> element is present
705+
at the time of the <code>DOMContentLoaded</code> and <code>load</code> events,
706+
the <{iframe}>'s [=internal layout intrinsic size=]'s height
707+
is set to the [=natural height=] of the embedded document.
708+
Subsequent changes to content, styling or layout of the embedded document
709+
do not affect the [=internal layout intrinsic size=].
710+
711+
<div class='example'>
712+
When the embedded document has the following HTML:
713+
714+
<xmp highlight=html>
715+
<meta name="responsive-embedded-sizing">
716+
<div style="height: 500px"></div>
717+
</xmp>
718+
719+
and the embedding document has the following CSS:
720+
721+
<pre highlight=css>
722+
iframe {
723+
contain-intrinsic-block-size: from-element 150px;
724+
}
725+
</pre>
726+
727+
The height of the <{iframe}> will initially be ''150px'',
728+
but will be updated to ''500px'' once the iframe's document loads.
729+
</div>
730+
731+
In addition,
732+
the internal document can call {{window/requestResize()|window.requestResize()}};
733+
if the document still has the required <{meta}> element,
734+
its [=internal layout intrinsic size=]'s height
735+
is updated to its new current [=natural height=].
736+
737+
Note: If the required <{meta}> element is not present,
738+
the call throws a {{NotAllowedError}} {{DOMException}} instead.
739+
659740
<h4 id='cis-scrollbars'>
660741
Interaction With ''overflow: auto''</h4>
661742

0 commit comments

Comments
 (0)