Skip to content

Commit 1d6d644

Browse files
committed
[css-sizing-4] Add responsively-sized iframes
Based on the resolutions at: #1771 (comment)
1 parent e21a6c9 commit 1d6d644

File tree

1 file changed

+66
-2
lines changed

1 file changed

+66
-2
lines changed

css-sizing-4/Overview.bs

Lines changed: 66 additions & 2 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? [ none | <<length [0,∞]>> ] | from-element <<length [0,∞]>>?
534534
Initial: none
535535
Inherited: no
536536
Logical property group: contain-intrinsic-size
@@ -573,6 +573,16 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties</h3>
573573
<wpt pathprefix="css/css-contain/">
574574
content-visibility/content-visibility-058.html
575575
</wpt>
576+
577+
: <dfn>from-element
578+
:: ''from-element'' enables the <a>responsively-sized iframes</a>.
579+
It applies only to <code>&lt;iframe></code> elements,
580+
and applies regardless of the values of the ''contain'' property.
581+
582+
The optional length specifies the [=explicit intrinsic inner size=]
583+
until the embedded document notifies the first [=natural size=],
584+
585+
Note: The name needs further discussion.
576586
</dl>
577587
578588
If an element has an [=explicit intrinsic inner size=] in an axis,
@@ -600,7 +610,7 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-*' properties</h3>
600610
601611
<pre class="propdef shorthand">
602612
Name: contain-intrinsic-size
603-
Value: [ auto? [ none | <<length>> ] ]{1,2}
613+
Value: [ auto? [ none | <<length [0,∞]>> ] ]{1,2} | from-element <<length [0,∞]>> {0,2}
604614
</pre>
605615
606616
'contain-intrinsic-size' is a shorthand property
@@ -656,6 +666,60 @@ Last Remembered Size</h4>
656666
even across changes such as going to/from ''display: none''.
657667
</div>
658668
669+
<h4 id='responsive-iframes' dfn lt="responsively-sized iframes" export>
670+
Responsively-sized iframes</h4>
671+
672+
Iframes participate in the layout of the parent document,
673+
via the style and layout of their owning <code>&lt;iframe></code> element.
674+
However, unlike other HTML elements such as <code>&lt;div></code>,
675+
iframe elements do not have the ability to support responsive layout,
676+
i.e. size themselves automatically
677+
to contain the [=natural size=] dimensions of the contents of the iframe.
678+
Instead, browsers automatically add scrollbars to iframes as necessary,
679+
so that users can access the content.
680+
681+
Responsive iframes adds responsive layout to iframes,
682+
similar to embedded SVG documents
683+
in <code>&lt;object></code> and <code>&lt;embed></code> elements.
684+
685+
To preserve privacy and security guarantees of cross-origin content,
686+
both the embedding and embedded document must opt in.
687+
The embedding document opts in by applying the ''from-element'' value to
688+
the ''contain-intrinsic-block-size'' property on the &lt;iframe> element.
689+
The embedded document opts in by adding the
690+
&lt;meta name="responsive-embedded-sizing"> tag.
691+
692+
When the meta tag is present at the time of
693+
the <code>DOMContentLoaded</code> and <code>load</code> events,
694+
the embedding document is notified
695+
with the new [=natural height=] of the embedded document.
696+
If the ''contain-intrinsic-block-size''
697+
on the box for the &lt;iframe> element is set to ''from-element'',
698+
it takes this height as the [=explicit intrinsic inner size=] of the box.
699+
Subsequent changes to content, styling or layout of the embedded document
700+
do not affect the &lt;iframe> sizing.
701+
702+
<div class='example'>
703+
When the embedded document has the following HTML:
704+
<pre highlight=html>
705+
&lt;meta name="responsive-embedded-sizing">
706+
&lt;div style="height: 500px">&lt;/div>
707+
</pre>
708+
and the embedding document has the following CSS:
709+
<pre highlight=css>
710+
iframe {
711+
contain-intrinsic-block-size: from-element;
712+
}
713+
</pre>
714+
The height of the <code>&lt;iframe></code> will be 500px.
715+
</div>
716+
717+
In addition,
718+
the embedded document can call <code>window.requestResize()</code>
719+
to notify its new [=natural height=] to the embedding document.
720+
If the meta tag is not present at the time of the call,
721+
it throws a NotAllowedError DOMException instead.
722+
659723
<h4 id='cis-scrollbars'>
660724
Interaction With ''overflow: auto''</h4>
661725

0 commit comments

Comments
 (0)