





























@@ -66,6 +66,7 @@ below. You should read the code below with its explanatory section.
66666767```js
6868registerLayout('centering', class {
69+async intrinsicSizes() {}
6970async layout(children, edges, constraints, styleMap) {
7071// (1) Determine our (inner) available size.
7172const availableInlineSize = constraints.fixedInlineSize - edges.inline;
@@ -229,6 +230,7 @@ registerLayout('style-read', class {
229230static inputProperties = ['--a-number'];
230231static childInputProperties = ['--a-string'];
231232233+async intrinsicSizes() {}
232234async layout(children, edges, constraints, styleMap) {
233235// We can read our own style:
234236styleMap.get('--a-number').value === 42;
@@ -307,13 +309,14 @@ We pass the `BreakToken` to add back into the `layout()` call in order to produc
307309registerLayout('basic-inline', class {
308310static layoutOptions = {childDisplay: 'normal'};
309311312+async intrinsicSizes() {}
310313async layout(children, edges, constraints, styleMap) {
311314// Determine our (inner) available size.
312315const availableInlineSize = constraints.fixedInlineSize - edges.inline;
313316const availableBlockSize = constraints.fixedBlockSize !== null ?
314317constraints.fixedBlockSize - edges.block : null;
315318316-const constraints = {
319+const childConstraints = {
317320 availableInlineSize,
318321 availableBlockSize,
319322 };
@@ -327,11 +330,14 @@ registerLayout('basic-inline', class {
327330// Layout the next line, the produced line will try and respect the
328331// availableInlineSize given, you could use this to achieve a column
329332// effect or similar.
330-const fragment = await child.layoutNextFragment(constraints, childBreakToken);
333+const fragment = await child.layoutNextFragment(childConstraints, childBreakToken);
331334childFragments.push(fragment);
332335333336// Position the fragment, note we could do something special here, like
334337// placing all the lines on a "rythmic grid", or similar.
338+||||||| parent of a2dd8db ([css-layout-api][explainer] add mandatory intrinsicSizes function)
339+// Position the fragment, note we coulld do something special here, like
340+// placing all the lines on a "rythimic grid", or similar.
335341 fragment.inlineOffset = edges.inlineStart;
336342 fragment.blockOffset = blockOffset;
337343@@ -409,6 +415,7 @@ We can make our children fragment by passing them a constraint space with a frag
409415410416```js
411417registerLayout('special-multi-col', class {
418+async intrinsicSizes() {}
412419async layout(children, edges, constraints, styleMap, breakToken) {
413420for (let child of children) {
414421// Create a constraint space with a fragmentation line.
@@ -435,6 +442,7 @@ We can also allow our own layout to be fragmented by respecting the fragmentatio
435442436443```js
437444registerLayout('basic-inline', class {
445+async intrinsicSizes() {}
438446async layout(children, edges, constraints, styleMap, breakToken) {
439447440448// We can check if we need to fragment in the block direction.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。