Skip to content

Commit f98969c

Browse files
committed
[css-sizing-4] Rewrite frame-sizing details for clarity.
1 parent eb0ad72 commit f98969c

1 file changed

Lines changed: 130 additions & 32 deletions

File tree

css-sizing-4/Overview.bs

Lines changed: 130 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ spec:css2; type:property
3232
text:min-height
3333
text:max-width
3434
text:max-height
35-
spec:html; type:element; text:meta
35+
spec:html; type:element;
36+
text:meta
37+
text:head
3638
spec:css2; type:dfn; text:document language
3739
</pre>
3840

@@ -1188,9 +1190,9 @@ Responsively-sized iframes: the 'frame-sizing' property</h3>
11881190
Name: frame-sizing
11891191
Value: auto | content-width | content-height | content-block-size | content-inline-size
11901192
Initial: auto
1191-
Applies to: <{iframe}> elements
1193+
Applies to: replaced elements (but see below for details)
11921194
Inherited: no
1193-
Computed value: specified keyword
1195+
Computed value: as specified
11941196
Animation type: discrete
11951197
</pre>
11961198

@@ -1205,33 +1207,39 @@ Responsively-sized iframes: the 'frame-sizing' property</h3>
12051207
The 'frame-sizing' property
12061208
allows these elements to opt into exposing their actual content size,
12071209
known as their <dfn export>internal layout intrinsic size</dfn>.
1210+
Values have the following meaning:
12081211

1209-
Which elements have an [=internal layout intrinsic size=],
1212+
<dl dfn-type=value dfn-for=frame-sizing>
1213+
: <dfn>auto</dfn>
1214+
::
1215+
The element's [=internal layout intrinsic size=],
1216+
if any,
1217+
is ignored.
1218+
1219+
: <dfn>content-width</dfn>
1220+
: <dfn>content-height</dfn>
1221+
: <dfn>content-block-size</dfn>
1222+
: <dfn>content-inline-size</dfn>
1223+
::
1224+
If the element has an [=internal layout intrinsic size=],
1225+
its [=intrinsic size=]
1226+
takes the corresponding dimension
1227+
(either width or height)
1228+
from the [=internal layout intrinsic size=].
1229+
(The other dimension is determined normally.)
1230+
1231+
Logical directions resolve based on the [=writing mode=] of the element.
1232+
(Not the embedded document.)
1233+
</dl>
1234+
1235+
Which elements can have an [=internal layout intrinsic size=],
12101236
and how it's determined,
12111237
are decided by the [=document language=].
12121238
In HTML, only <{iframe}> elements can have an [=internal layout intrinsic size=],
12131239
and further,
12141240
only when the contained document has also opted in
1215-
via a <code>&lt;meta name=responsive-embedded-sizing></code> element.
1216-
1217-
The first instance of this meta tag added by the parser can make it opt in.
1218-
If the parser encounters multiple such tags, only the first one is used.
1219-
If the parser closes the <code>&lt;head&gt;</code> without seeing the tag,
1220-
it is frozen as not-set.
1221-
1222-
An <{iframe}> initially doesn't have an [=internal layout intrinsic size=].
1223-
When an <{iframe}>'s internal document is loaded,
1224-
if the required <{meta}> element is present,
1225-
the <{iframe}>'s [=internal layout intrinsic size=]'s height or width
1226-
is set to the [=natural size=] of the embedded document as specified by 'frame-sizing'.
1227-
Resizing occurs at the <code>DOMContentLoaded</code> and <code>load</code> events.
1228-
Subsequent changes to content, styling or layout of the embedded document
1229-
do not affect the [=internal layout intrinsic size=].
1230-
1231-
When laying out the <{iframe}>'s internal document,
1232-
its initial containing block size is locked to
1233-
the size at the time of its first layout,
1234-
to mitigate the risks of layout loops and information leaks.
1241+
via a <code highlight=html>&lt;meta name=responsive-embedded-sizing></code> element.
1242+
(See [[#iframe-frame-sizing]].)
12351243

12361244
<div class='example'>
12371245
When the embedded document has the following HTML:
@@ -1254,14 +1262,104 @@ Responsively-sized iframes: the 'frame-sizing' property</h3>
12541262
</div>
12551263

12561264
In addition,
1257-
the internal document can call {{window/requestResize()|window.requestResize()}};
1258-
if the document has the required <{meta}> element
1259-
at the time of parsing as described above,
1260-
its [=internal layout intrinsic size=]
1261-
is updated to its new current [=natural size=].
1262-
1263-
Note: If the required <{meta}> element is not present,
1264-
the call throws a {{NotAllowedError}} {{DOMException}} instead.
1265+
the internal document can call {{Window/requestResize()|window.requestResize()}}
1266+
to update its [=internal layout intrinsic size=] later.
1267+
1268+
1269+
<h4 id=iframe-frame-sizing>
1270+
HTML <{iframe}> Details</h4>
1271+
1272+
In HTML, only the <{iframe}> element can have an [=internal layout intrinsic size=],
1273+
and only when the <{iframe}>'s embedded document has opted in appropriately.
1274+
1275+
An HTML {{Document}} object
1276+
has an <dfn for=Document>responsive embedded sizing flag</dfn> associated with it,
1277+
which is initially unset.
1278+
It is set to true or false
1279+
during the initial document parse,
1280+
depending on which of the following first occurs:
1281+
1282+
* If a <code highlight=html>&lt;meta name=responsive-embedded-sizing></code> element is encountered,
1283+
it is set to true.
1284+
* If the <{head}> element is closed (explicitly or implicitly),
1285+
it is set to false.
1286+
1287+
Once set to either true or false,
1288+
the flag will not change its value again for the lifetime of the {{Document}}.
1289+
1290+
Note: Currently, the HTML <{meta}> element appearing in the <{head}> of an HTML document
1291+
is the only way for an embedded document to opt into this feature in HTML.
1292+
This means that SVG documents in <{iframe}> cannot do so.
1293+
1294+
The [=internal layout intrinsic size=] is first set
1295+
by the results of the embedded document's first layout
1296+
after it fires its {{DOMContentLoaded}} event,
1297+
and again when the {{Window/load}} event is fired at the {{Window}}.
1298+
Subsequent changes to content, styling or layout of the embedded document
1299+
do not automatically affect the [=internal layout intrinsic size=],
1300+
but see {{Window/requestResize()}}.
1301+
1302+
An embedded document can additionally have a <dfn>locked embedded ICB size</dfn>,
1303+
which is initially null.
1304+
If the document's [=responsive embedded sizing flag=] is true
1305+
when it performs a layout,
1306+
and its [=locked embedded ICB size=] is null,
1307+
it records its current [=initial containing block=] size as its [=locked embedded ICB size=].
1308+
On subsequent layouts,
1309+
it uses its [=locked embedded ICB size=]
1310+
instead of calculating its [=initial containing block=] size normally.
1311+
1312+
Note: This freezing of the ICB
1313+
reduces the chance of layout loops
1314+
(an iframe document sizing to slightly larger than its ICB,
1315+
then the parent iframe changing size to match,
1316+
and the next layout again making it slightly larger than the ICB,
1317+
etc to infinity).
1318+
1319+
Issue: Do we want to have a way to force an iframe to forget its [=locked embedded ICB size=]?
1320+
Maybe turning 'frame-sizing' off and on again?
1321+
1322+
Navigating the iframe's document
1323+
causes it to forget its [=locked embedded ICB size=].
1324+
It <strong>does not</strong> forget its [=internal layout intrinsic size=]
1325+
as long as the new document's [=responsive embedded sizing flag=] is unset.
1326+
Once the flag is set (to true <em>or</em> false),
1327+
the [=internal layout intrinsic size=] is forgotten;
1328+
if the flag is set to true,
1329+
both are then freshly computed as normal.
1330+
1331+
1332+
<h4 id=window-requestresize>
1333+
Extensions to the {{Window}} Interface</h4>
1334+
1335+
<xmp class=idl>
1336+
partial interface Window {
1337+
undefined requestResize();
1338+
};
1339+
</xmp>
1340+
1341+
<div algorithm>
1342+
When <dfn for=Window method>requestResize()</dfn> is invoked:
1343+
1344+
1. Let |navigable| be the [=/navigable=] that has [=this=] as its <l spec=html>[=content window=]</l>.
1345+
If |navigable| is not a [=child navigable=],
1346+
[=throw=] a {{NotAllowedError}} {{DOMException}}.
1347+
1348+
1. Let |host element| be the [=navigable container=] whose [=content navigable=] is |navigable|.
1349+
If |host element| is not an HTML <{iframe}> element,
1350+
[=throw=] a {{NotAllowedError}} {{DOMException}}.
1351+
1352+
1. Let |document| be [=this's=] [=active document=].
1353+
If |document|'s [=Document/responsive embedded sizing flag=]
1354+
is unset or false,
1355+
[=throw=] a {{NotAllowedError}} {{DOMException}}.
1356+
1357+
1. If |document| has pending style or layout changes,
1358+
perform them.
1359+
1360+
1. Set the [=internal layout intrinsic size=] of |host element|
1361+
to the width and height of the <l spec=cssom-view>[=scrolling area=]</l> of [=this=].
1362+
</div>
12651363

12661364

12671365
<h3 id="intrinsic-contribution">

0 commit comments

Comments
 (0)