@@ -446,10 +446,10 @@ direction), while centering its children in the inline direction.
446
446
447
447
<pre class="lang-javascript">
448
448
registerLayout('block-like' , class {
449
- * intrinsicSizes(children, edges, styleMap) {
450
- const childrenSizes = yield children.map((child) => {
449
+ async intrinsicSizes(children, edges, styleMap) {
450
+ const childrenSizes = await Promise.all( children.map((child) => {
451
451
return child.intrinsicSizes();
452
- });
452
+ })) ;
453
453
454
454
const maxContentSize = childrenSizes.reduce((max, childSizes) => {
455
455
return Math.max(max, childSizes.maxContentSize);
@@ -462,16 +462,18 @@ registerLayout('block-like', class {
462
462
return {maxContentSize, minContentSize};
463
463
}
464
464
465
- *layout(children, edges, constraints, styleMap) {
465
+ async layout(children, edges, constraints, styleMap) {
466
+ // Determine our (inner) available size.
466
467
const availableInlineSize = constraints.fixedInlineSize - edges.all.inline;
467
- const availableBlockSize = (constraints.fixedBlockSize || Infinity) - edges.all.block;
468
+ const availableBlockSize = constraints.fixedBlockSize ?
469
+ constraints.fixedBlockSize - edges.all.block : null;
468
470
469
471
const childFragments = [];
470
472
const childConstraints = { availableInlineSize, availableBlockSize };
471
473
472
- const childFragments = yield children.map((child) => {
474
+ const childFragments = await Promise.all( children.map((child) => {
473
475
return child.layoutNextFragment(childConstraints);
474
- });
476
+ })) ;
475
477
476
478
let blockOffset = edges.all.blockStart;
477
479
for (let fragment of childFragments) {
@@ -594,10 +596,10 @@ The example below shows the border-box intrinsic sizes of two children.
594
596
595
597
<pre class="lang-javascript">
596
598
registerLayout('intrinsic-sizes-example' , class {
597
- * intrinsicSizes(children, edges, styleMap) {
598
- const childrenSizes = yield children.map((child) => {
599
+ async intrinsicSizes(children, edges, styleMap) {
600
+ const childrenSizes = await Promise.all( children.map((child) => {
599
601
return child.intrinsicSizes();
600
- });
602
+ })) ;
601
603
602
604
childrenSizes[0] .minContentSize; // 400, (380+10+10) child has a fixed size.
603
605
childrenSizes[0] .maxContentSize; // 400, (380+10+10) child has a fixed size.
@@ -606,7 +608,7 @@ registerLayout('intrinsic-sizes-example', class {
606
608
childrenSizes[1] .maxContentSize; // 200, size of "XXX XXXX".
607
609
}
608
610
609
- * layout() {}
611
+ layout() {}
610
612
});
611
613
</pre>
612
614
</div>
@@ -691,8 +693,8 @@ creates child layout constraints which specify that a child should be a fixed in
691
693
692
694
<pre class="lang-javascript">
693
695
registerLayout('flex-distribution-like' , class {
694
- * intrinsicSizes(children, edges, styleMap) {
695
- const childrenSizes = yield children.map((child) => {
696
+ async intrinsicSizes(children, edges, styleMap) {
697
+ const childrenSizes = children.map((child) => {
696
698
return child.intrinsicSizes();
697
699
});
698
700
@@ -707,18 +709,18 @@ registerLayout('flex-distribution-like', class {
707
709
return {maxContentSize, minContentSize};
708
710
}
709
711
710
- * layout(children, edges, constraints, styleMap) {
711
-
712
+ async layout(children, edges, constraints, styleMap) {
713
+ // Determine our (inner) available size.
712
714
const availableInlineSize =
713
715
constraints.fixedInlineSize - edges.all.inline;
714
- const availableBlockSize =
715
- ( constraints.fixedInlineSize || Infinity) - edges.all.block;
716
+ const availableBlockSize = constraints.fixedBlockSize ?
717
+ constraints.fixedBlockSize - edges.all.block : null ;
716
718
717
719
const childConstraints = { availableInlineSize, availableBlockSize };
718
720
719
- const unconstrainedChildFragments = yield children.map((child) => {
721
+ const unconstrainedChildFragments = await Promise.all( children.map((child) => {
720
722
return child.layoutNextFragment(childConstraints);
721
- });
723
+ })) ;
722
724
723
725
const unconstrainedSizes = [];
724
726
const totalSize = unconstrainedChildFragments.reduce((sum, fragment, i) => {
@@ -730,12 +732,12 @@ registerLayout('flex-distribution-like', class {
730
732
const remainingSpace = Math.max(0, inlineSize - totalSize);
731
733
const extraSpace = remainingSpace / children.length;
732
734
733
- const childFragments = yield children.map((child, i) => {
735
+ const childFragments = await Promise.all( children.map((child, i) => {
734
736
return child.layoutNextFragment({
735
737
fixedInlineSize: unconstrainedSizes[i] + extraSpace,
736
738
availableBlockSize
737
739
});
738
- });
740
+ })) ;
739
741
740
742
// Position the fragments.
741
743
let inlineOffset = 0;
@@ -866,13 +868,12 @@ registerLayout('indent-lines', class {
866
868
static layoutOptions = {childDisplay: 'normal' };
867
869
static inputProperties = ['--indent', '--indent-lines'] ;
868
870
869
- *layout(children, edges, constraints, styleMap, breakToken) {
870
-
871
+ async layout(children, edges, constraints, styleMap, breakToken) {
871
872
// Determine our (inner) available size.
872
873
const availableInlineSize =
873
874
constraints.fixedInlineSize - edges.all.inline;
874
- const availableBlockSize =
875
- ( constraints.fixedBlockSize || Infinity) - edges.all.block;
875
+ const availableBlockSize = constraints.fixedBlockSize ?
876
+ constraints.fixedBlockSize - edges.all.block : null ;
876
877
877
878
// Detrermine the number of lines to indent, and the indent amount.
878
879
const indent = resolveLength(constraints, styleMap.get('--indent' ));
@@ -904,7 +905,7 @@ registerLayout('indent-lines', class {
904
905
blockFragmentationType: constraints.blockFragmentationType,
905
906
};
906
907
907
- const fragment = yield child.layoutNextFragment(childConstraints,
908
+ const fragment = await child.layoutNextFragment(childConstraints,
908
909
childBreakToken);
909
910
childFragments.push(fragment);
910
911
@@ -1020,7 +1021,7 @@ This example shows an node styled by CSS, and what its respective {{LayoutEdges}
1020
1021
1021
1022
<pre class="lang-javascript">
1022
1023
registerLayout('box-edges' , class {
1023
- * layout(children, edges, constraints, styleMap, breakToken) {
1024
+ async layout(children, edges, constraints, styleMap, breakToken) {
1024
1025
edges.padding.inlineStart; // 5 (as 10% * 50px = 5px).
1025
1026
edges.border.blockEnd; // 2
1026
1027
edges.scrollbar.inlineEnd; // UA-dependent, may be 0 or >0 (e.g. 16).
@@ -1219,7 +1220,7 @@ baselines themselves. This will be of the form:
1219
1220
1220
1221
To <em> query</em> baseline information from a {{LayoutChild}} .
1221
1222
<pre class="lang-javascript">
1222
- const fragment = yield child.layoutNextFragment({
1223
+ const fragment = await child.layoutNextFragment({
1223
1224
fixedInlineSize: availableInlineSize,
1224
1225
baselineRequests: ['alphabetic', 'middle'] ,
1225
1226
});
@@ -1229,7 +1230,7 @@ fragment.baselines.get('alphabetic') === 25 /* or something */;
1229
1230
To <em> produce</em> baseline information for a <a>parent layout</a> :
1230
1231
<pre class="lang-javascript">
1231
1232
registerLayout('baseline-producing' , class {
1232
- * layout(children, edges, constraints, styleMap) {
1233
+ async layout(children, edges, constraints, styleMap) {
1233
1234
const result = {baselines: {}};
1234
1235
1235
1236
for (let baselineRequest of constraints.baselineRequests) {
@@ -1549,11 +1550,11 @@ is called, the user agent <em>must</em> run the following steps:
1549
1550
return {childDisplay: 'normal' , sizing: 'block-like' }
1550
1551
}
1551
1552
1552
- * intrinsicSizes(children, edges, styleMap) {
1553
+ async intrinsicSizes(children, edges, styleMap) {
1553
1554
// Intrinsic sizes code goes here.
1554
1555
}
1555
1556
1556
- * layout(children, edges, constraints, styleMap, breakToken) {
1557
+ async layout(children, edges, constraints, styleMap, breakToken) {
1557
1558
// Layout code goes here.
1558
1559
}
1559
1560
}
0 commit comments