@@ -446,10 +446,10 @@ direction), while centering its children in the inline direction.
446446
447447<pre class="lang-javascript">
448448registerLayout('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) => {
451451 return child.intrinsicSizes();
452- });
452+ })) ;
453453
454454 const maxContentSize = childrenSizes.reduce((max, childSizes) => {
455455 return Math.max(max, childSizes.maxContentSize);
@@ -462,16 +462,18 @@ registerLayout('block-like', class {
462462 return {maxContentSize, minContentSize};
463463 }
464464
465- *layout(children, edges, constraints, styleMap) {
465+ async layout(children, edges, constraints, styleMap) {
466+ // Determine our (inner) available size.
466467 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;
468470
469471 const childFragments = [];
470472 const childConstraints = { availableInlineSize, availableBlockSize };
471473
472- const childFragments = yield children.map((child) => {
474+ const childFragments = await Promise.all( children.map((child) => {
473475 return child.layoutNextFragment(childConstraints);
474- });
476+ })) ;
475477
476478 let blockOffset = edges.all.blockStart;
477479 for (let fragment of childFragments) {
@@ -594,10 +596,10 @@ The example below shows the border-box intrinsic sizes of two children.
594596
595597<pre class="lang-javascript">
596598registerLayout('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) => {
599601 return child.intrinsicSizes();
600- });
602+ })) ;
601603
602604 childrenSizes[0] .minContentSize; // 400, (380+10+10) child has a fixed size.
603605 childrenSizes[0] .maxContentSize; // 400, (380+10+10) child has a fixed size.
@@ -606,7 +608,7 @@ registerLayout('intrinsic-sizes-example', class {
606608 childrenSizes[1] .maxContentSize; // 200, size of "XXX XXXX".
607609 }
608610
609- * layout() {}
611+ layout() {}
610612});
611613</pre>
612614</div>
@@ -691,8 +693,8 @@ creates child layout constraints which specify that a child should be a fixed in
691693
692694<pre class="lang-javascript">
693695registerLayout('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) => {
696698 return child.intrinsicSizes();
697699 });
698700
@@ -707,18 +709,18 @@ registerLayout('flex-distribution-like', class {
707709 return {maxContentSize, minContentSize};
708710 }
709711
710- * layout(children, edges, constraints, styleMap) {
711-
712+ async layout(children, edges, constraints, styleMap) {
713+ // Determine our (inner) available size.
712714 const availableInlineSize =
713715 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 ;
716718
717719 const childConstraints = { availableInlineSize, availableBlockSize };
718720
719- const unconstrainedChildFragments = yield children.map((child) => {
721+ const unconstrainedChildFragments = await Promise.all( children.map((child) => {
720722 return child.layoutNextFragment(childConstraints);
721- });
723+ })) ;
722724
723725 const unconstrainedSizes = [];
724726 const totalSize = unconstrainedChildFragments.reduce((sum, fragment, i) => {
@@ -730,12 +732,12 @@ registerLayout('flex-distribution-like', class {
730732 const remainingSpace = Math.max(0, inlineSize - totalSize);
731733 const extraSpace = remainingSpace / children.length;
732734
733- const childFragments = yield children.map((child, i) => {
735+ const childFragments = await Promise.all( children.map((child, i) => {
734736 return child.layoutNextFragment({
735737 fixedInlineSize: unconstrainedSizes[i] + extraSpace,
736738 availableBlockSize
737739 });
738- });
740+ })) ;
739741
740742 // Position the fragments.
741743 let inlineOffset = 0;
@@ -866,13 +868,12 @@ registerLayout('indent-lines', class {
866868 static layoutOptions = {childDisplay: 'normal' };
867869 static inputProperties = ['--indent', '--indent-lines'] ;
868870
869- *layout(children, edges, constraints, styleMap, breakToken) {
870-
871+ async layout(children, edges, constraints, styleMap, breakToken) {
871872 // Determine our (inner) available size.
872873 const availableInlineSize =
873874 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 ;
876877
877878 // Detrermine the number of lines to indent, and the indent amount.
878879 const indent = resolveLength(constraints, styleMap.get('--indent' ));
@@ -904,7 +905,7 @@ registerLayout('indent-lines', class {
904905 blockFragmentationType: constraints.blockFragmentationType,
905906 };
906907
907- const fragment = yield child.layoutNextFragment(childConstraints,
908+ const fragment = await child.layoutNextFragment(childConstraints,
908909 childBreakToken);
909910 childFragments.push(fragment);
910911
@@ -1020,7 +1021,7 @@ This example shows an node styled by CSS, and what its respective {{LayoutEdges}
10201021
10211022<pre class="lang-javascript">
10221023registerLayout('box-edges' , class {
1023- * layout(children, edges, constraints, styleMap, breakToken) {
1024+ async layout(children, edges, constraints, styleMap, breakToken) {
10241025 edges.padding.inlineStart; // 5 (as 10% * 50px = 5px).
10251026 edges.border.blockEnd; // 2
10261027 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:
12191220
12201221To <em> query</em> baseline information from a {{LayoutChild}} .
12211222<pre class="lang-javascript">
1222- const fragment = yield child.layoutNextFragment({
1223+ const fragment = await child.layoutNextFragment({
12231224 fixedInlineSize: availableInlineSize,
12241225 baselineRequests: ['alphabetic', 'middle'] ,
12251226});
@@ -1229,7 +1230,7 @@ fragment.baselines.get('alphabetic') === 25 /* or something */;
12291230To <em> produce</em> baseline information for a <a>parent layout</a> :
12301231<pre class="lang-javascript">
12311232registerLayout('baseline-producing' , class {
1232- * layout(children, edges, constraints, styleMap) {
1233+ async layout(children, edges, constraints, styleMap) {
12331234 const result = {baselines: {}};
12341235
12351236 for (let baselineRequest of constraints.baselineRequests) {
@@ -1549,11 +1550,11 @@ is called, the user agent <em>must</em> run the following steps:
15491550 return {childDisplay: 'normal' , sizing: 'block-like' }
15501551 }
15511552
1552- * intrinsicSizes(children, edges, styleMap) {
1553+ async intrinsicSizes(children, edges, styleMap) {
15531554 // Intrinsic sizes code goes here.
15541555 }
15551556
1556- * layout(children, edges, constraints, styleMap, breakToken) {
1557+ async layout(children, edges, constraints, styleMap, breakToken) {
15571558 // Layout code goes here.
15581559 }
15591560 }
0 commit comments