Skip to content

Commit 187a8a2

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

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

css-sizing-4/Overview.bs

Lines changed: 61 additions & 1 deletion
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
534534
Initial: none
535535
Inherited: no
536536
Logical property group: contain-intrinsic-size
@@ -573,6 +573,11 @@ 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</dfn>
578+
:: This value enables the <a>responsively-sized iframes</a>.
579+
580+
Note: The name needs further discussion.
576581
</dl>
577582

578583
If an element has an [=explicit intrinsic inner size=] in an axis,
@@ -656,6 +661,61 @@ Last Remembered Size</h4>
656661
even across changes such as going to/from ''display: none''.
657662
</div>
658663

664+
<h4 id='responsive-iframes' dfn lt="responsively-sized iframes" export>
665+
Responsively-sized iframes</h4>
666+
667+
Iframes participate in the layout of the parent document,
668+
via the style and layout of their owning <code>&lt;iframe></code> element.
669+
However, unlike other HTML elements such as <code>&lt;div></code>,
670+
iframe elements do not have the ability to support responsive layout,
671+
i.e. size themselves automatically
672+
to contain the [=natural size=] dimensions of the contents of the iframe.
673+
Instead, browsers automatically add scrollbars to iframes as necessary,
674+
so that users can access the content.
675+
676+
Responsive iframes adds responsive layout to iframes,
677+
similar to embedded SVG documents
678+
in <code>&lt;object></code> and <code>&lt;embed></code> elements.
679+
680+
To preserve privacy and security guarantees of cross-origin content,
681+
both the embedding and embedded document must opt in.
682+
The embedding document opts in by applying the ''from-element'' value to
683+
the ''contain-intrinsic-block-size'' property on the &lt;iframe> element.
684+
The embedded document opts in by adding the
685+
&lt;meta name="responsive-embedded-sizing"> tag.
686+
687+
When the meta tag is present at the time of
688+
the <code>DOMContentLoaded</code> and <code>load</code> events,
689+
the embedding document is notified
690+
with the new [=natural height=] of the embedded document.
691+
If the ''contain-intrinsic-block-size''
692+
on the box for the &lt;iframe> element is set to ''from-element'',
693+
it takes this height as the [=explicit intrinsic inner size=] of the box.
694+
Subsequent changes to content, styling or layout of the embedded document
695+
do not affect the &lt;iframe> sizing.
696+
697+
<div class='example'>
698+
When the embedded document has the following HTML:
699+
<pre highlight=html>
700+
&lt;meta name="responsive-embedded-sizing">
701+
&lt;div style="height: 500px">&lt;/div>
702+
</pre>
703+
and the embedding document has the following CSS:
704+
<pre highlight=css>
705+
iframe {
706+
border: none;
707+
contain-intrinsic-block-size: from-element;
708+
}
709+
</pre>
710+
The height of the <code>&lt;iframe></code> will be 500px.
711+
</div>
712+
713+
In addition,
714+
the embedded document can call <code>window.requestResize()</code>
715+
to notify its new [=natural height=] to the embedding document.
716+
If the meta tag is not present at the time of the call,
717+
it throws a NotAllowedError DOMException instead.
718+
659719
<h4 id='cis-scrollbars'>
660720
Interaction With ''overflow: auto''</h4>
661721

0 commit comments

Comments
 (0)