@@ -318,17 +318,21 @@ A {{LayoutFragment}} represents a CSS <a>fragment</a> of a {{LayoutChild}} after
318
318
on that child. This is produced by the {{LayoutChild/layoutNextFragment()}} method.
319
319
320
320
The {{LayoutFragment}} has {{LayoutFragment/inlineSize}} and {{LayoutFragment/blockSize}}
321
- attributes, which are set by the respective child's layout algorithm. They cannot be changed. If the
322
- <a>current layout</a> requires a different {{LayoutFragment/inlineSize}} or
321
+ attributes, which are set by the respective child's layout algorithm. They represent the <b> border
322
+ box</b> size of the CSS <a>fragment</a> , and are relative to the <a>current layout's</a> writing
323
+ mode.
324
+
325
+ The {{LayoutFragment/inlineSize}} and {{LayoutFragment/blockSize}} attributes cannot be changed. If
326
+ the <a>current layout</a> requires a different {{LayoutFragment/inlineSize}} or
323
327
{{LayoutFragment/blockSize}} the author must perform {{LayoutChild/layoutNextFragment()}} again with
324
328
different arguments in order to get different results.
325
329
326
330
The author inside the current layout can position a resulting {{LayoutFragment}} by setting its
327
331
{{LayoutFragment/inlineOffset}} and {{LayoutFragment/blockOffset}} attributes. If not set by the
328
332
author they default to zero. The {{LayoutFragment/inlineOffset}} and {{LayoutFragment/blockOffset}}
329
- attributes represent the position of the {{LayoutFragment}} relative to its parent's border box,
330
- before transform or positioning (e.g. if a fragment is <a>relatively positioned</a> ) has been
331
- applied.
333
+ attributes represent the position of the {{LayoutFragment}} relative to its parent's <b> border
334
+ box </b> , before transform or positioning (e.g. if a fragment is <a>relatively positioned</a> ) has
335
+ been applied.
332
336
333
337
<div class="example">
334
338
The layout algorithm performs a block-like layout (positioning fragments sequentially in the block
@@ -342,11 +346,11 @@ registerLayout('block-like', class {
342
346
});
343
347
344
348
const maxContentSize = childrenSizes.reduce((max, childSizes) => {
345
- return Math.max(max, childSizes.maxContentContribution );
349
+ return Math.max(max, childSizes.maxContentSize );
346
350
}, 0) + edges.all.inline;
347
351
348
352
const minContentSize = childrenSizes.reduce((max, childSizes) => {
349
- return Math.max(max, childSizes.minContentContribution );
353
+ return Math.max(max, childSizes.minContentSize );
350
354
}, 0) + edges.all.inline;
351
355
352
356
return {maxContentSize, minContentSize};
@@ -398,8 +402,70 @@ particular child. The {{LayoutFragment/breakToken}} cannot be changed.
398
402
If the <a>current layout</a> requires a different {{LayoutFragment/breakToken}} the author must perform
399
403
{{LayoutChild/layoutNextFragment()}} again with different arguments.
400
404
401
- Note: In a future level of the specification there may be a way to query for additional baseline
402
- information, for example where the alphabetic or center baseline is positioned.
405
+ Intrinsic Sizes {#intrinsic-sizes}
406
+ ----------------------------------
407
+
408
+ <pre class='idl'>
409
+ [Exposed=LayoutWorklet]
410
+ interface IntrinsicSizes {
411
+ readonly attribute double minContentSize;
412
+ readonly attribute double maxContentSize;
413
+ };
414
+ </pre>
415
+
416
+ A {{IntrinsicSizes}} object represents the <a>min-content size</a> and <a>max-content size</a> of a
417
+ CSS <a>box</a> . It has {{IntrinsicSizes/minContentSize}} and {{IntrinsicSizes/maxContentSize}}
418
+ attributes which represent the <b> border box</b> min/max-content contribution of the {{LayoutChild}}
419
+ for the <a>current layout</a> . The attributes are relative to the inline direction of the <a>current
420
+ layout's</a> writing mode.
421
+
422
+ The {{IntrinsicSizes/minContentSize}} and {{IntrinsicSizes/maxContentSize}} cannot be changed. They
423
+ must not change for a {{LayoutChild}} within the current layout pass.
424
+
425
+ <div class="example">
426
+ The example below shows the border-box intrinsic sizes of two children.
427
+
428
+ <pre class="lang-html">
429
+ <style>
430
+ .child-0 {
431
+ width: 380px;
432
+ border: solid 10px;
433
+ }
434
+
435
+ .child-1 {
436
+ border: solid 5px;
437
+ }
438
+
439
+ .box {
440
+ display: layout(intrinsic-sizes-example);
441
+ font: 25px/1 Ahem;
442
+ }
443
+ </style>
444
+
445
+ <div class="box">
446
+ <div class="child-0"></div>
447
+ <div class="child-1">XXX XXXX</div>
448
+ </div>
449
+ </pre>
450
+
451
+ <pre class="lang-javascript">
452
+ registerLayout('intrinsic-sizes-example' , class {
453
+ *intrinsicSizes(children, edges, styleMap) {
454
+ const childrenSizes = yield children.map((child) => {
455
+ return child.intrinsicSizes();
456
+ });
457
+
458
+ childrenSizes[0] .minContentSize; // 400, (380+10+10) child has a fixed size.
459
+ childrenSizes[0] .maxContentSize; // 400, (380+10+10) child has a fixed size.
460
+
461
+ childrenSizes[1] .minContentSize; // 100, size of "XXXX".
462
+ childrenSizes[1] .maxContentSize; // 200, size of "XXX XXXX".
463
+ }
464
+
465
+ *layout() {}
466
+ });
467
+ </pre>
468
+ </div>
403
469
404
470
Layout Constraints {#layout-constraints}
405
471
----------------------------------------
@@ -470,11 +536,11 @@ registerLayout('flex-distribution-like', class {
470
536
});
471
537
472
538
const maxContentSize = childrenSizes.reduce((sum, childSizes) => {
473
- return sum + childSizes.maxContentContribution ;
539
+ return sum + childSizes.maxContentSize ;
474
540
}, 0) + edges.all.inline;
475
541
476
542
const minContentSize = childrenSizes.reduce((max, childSizes) => {
477
- return sum + childSizes.minContentContribution ;
543
+ return sum + childSizes.minContentSize ;
478
544
}, 0) + edges.all.inline;
479
545
480
546
return {maxContentSize, minContentSize};
@@ -937,12 +1003,11 @@ child to fragment.
937
1003
Alignment {#interaction-alignment}
938
1004
----------------------------------
939
1005
940
- The first/last baseline sets of a <a>layout API contrainer </a> is generated exactly like block
1006
+ The first/last baseline sets of a <a>layout API container </a> is generated exactly like block
941
1007
containers do (see [[css-align-3#baseline-export]] ). Except that the order of the in-flow children
942
1008
should be determined by the in which they are returned form the layout method (via
943
1009
{{FragmentResultOptions/childFragments}} ) instead of the document order.
944
1010
945
-
946
1011
<div class="note">
947
1012
Note: In a future level of the specification there will be the ability for the author to define the
948
1013
baselines themselves. This will be of the form:
@@ -1403,18 +1468,8 @@ dictionary IntrinsicSizesResultOptions {
1403
1468
double maxContentSize;
1404
1469
double minContentSize;
1405
1470
};
1406
-
1407
- interface IntrinsicSizes {
1408
- readonly attribute double minContentSize;
1409
- readonly attribute double maxContentSize;
1410
- };
1411
1471
</pre>
1412
1472
1413
- Issue: Should {{IntrinsicSizes/minContentSize}} and {{IntrinsicSizes/maxContentSize}} be content
1414
- contributions instead? E.g. minContentContribution, maxContentContribution. Should
1415
- {{IntrinsicSizesResultOptions/minContentSize}} and
1416
- {{IntrinsicSizesResultOptions/maxContentSize}} be content contributions as well?
1417
-
1418
1473
### Determining Intrinsic Sizes ### {#determining-intrinsic-sizes}
1419
1474
1420
1475
The <a>determine the intrinsic sizes</a> algorithm defines how a user agent is to query the author
0 commit comments