Skip to content

Commit 22cd40d

Browse files
committed
[css-layout-api] Add in passing of data between layouts.
1 parent 6c901fc commit 22cd40d

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

css-layout-api/Overview.bs

+27-12
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ spec:css-break-3; type:dfn; text:fragment
3636
spec:css-display-3; type:dfn; text:box
3737
spec:css-display-3; type:value; for:display; text:none
3838
spec:css-display-3; type:value; for:<display-inside>; text:grid
39-
spec:dom; type:dfn; for:/; text:element
40-
spec:infra; type:dfn; text:list
4139
spec:css-pseudo-4; type:selector; text:::after
4240
spec:css-pseudo-4; type:selector; text:::before
4341
spec:css-pseudo-4; type:selector; text:::first-letter
4442
spec:css-pseudo-4; type:selector; text:::first-line
43+
spec:dom; type:dfn; for:/; text:element
44+
spec:infra; type:dfn; text:list
45+
spec:html; type:dfn; for:global object; text:realm
4546
</pre>
4647

4748
<pre class="anchors">
@@ -75,6 +76,9 @@ urlPrefix: https://drafts.csswg.org/css-break/#; type: dfn
7576
text: fragmentation break
7677
urlPrefix: https://www.w3.org/TR/CSS21/box.html#; type: dfn
7778
url: box-dimensions; text: box model edges
79+
urlPrefix: https://html.spec.whatwg.org/#; type: dfn
80+
text: structuredserializeforstorage
81+
text: structureddeserialize
7882
</pre>
7983

8084
Introduction {#intro}
@@ -299,12 +303,11 @@ registerLayout('block-like', class {
299303
blockSize: availableBlockSize,
300304
});
301305

302-
let blockOffset = edges.all.blockStart;
303-
304306
const childFragments = yeild children.map((child) => {
305307
return child.layoutNextFragment(childConstraintSpace);
306308
});
307309

310+
let blockOffset = edges.all.blockStart;
308311
for (let fragment of childFragments) {
309312
// Position the fragment in a block like manner, centering it in the
310313
// inline direction.
@@ -330,6 +333,10 @@ registerLayout('block-like', class {
330333
</pre>
331334
</div>
332335

336+
A <a>layout API container</a> can communicate with other <a>layout API containers</a> by using the
337+
{{Fragment/data}} attribute. This is set by the {{FragmentResultOptions/data}} member in the
338+
{{FragmentResultOptions}} dictionary.
339+
333340
The {{Fragment}}'s {{Fragment/breakToken}} specifies where the {{LayoutChild}} last fragmented. If
334341
the {{Fragment/breakToken}} is null the {{LayoutChild}} wont produce any more {{Fragment}}s for that
335342
token chain. The {{Fragment/breakToken}} can be passed to the {{LayoutChild/layoutNextFragment()}}
@@ -508,15 +515,13 @@ dictionary BreakTokenOptions {
508515
any data = null;
509516
};
510517

511-
enum BreakType { "none", "inline", "inline-hyphen", "column", "page", "region" };
518+
enum BreakType { "none", "line", "column", "page", "region" };
512519
</pre>
513520

514-
Issue: Fill out other inline type break types.
515-
516521
A {{LayoutChild}} can produce multiple {{Fragment}}s. A {{LayoutChild}} may fragment in the block
517522
direction if a {{ConstraintSpace/blockFragmentationType}} is not none. Additionally {{LayoutChild}}
518-
which represents <a>inline-level</a> content, may fragment line by line if the displayType is
519-
<code>"normal"</code>.
523+
which represents <a>inline-level</a> content, may fragment line by line if the <a for="layout
524+
definition">child display</a> (set by <code>childDisplay</code>) is <code>"normal"</code>.
520525

521526
A subsequent {{Fragment}} is produced by using the previous {{Fragment}}'s {{Fragment/breakToken}}.
522527
This tells the <a>child layout</a> to produce a {{Fragment}} starting at the point encoded in the
@@ -537,7 +542,7 @@ resume the layout.
537542

538543
<pre class="lang-javascript">
539544
registerLayout('basic-inline', class {
540-
static displayType = 'normal';
545+
static childDisplay = 'normal';
541546

542547
*layout(space, children, styleMap, edges, breakToken) {
543548
// Resolve our inline size.
@@ -1137,6 +1142,7 @@ dictionary FragmentResultOptions {
11371142
double inlineSize = 0;
11381143
double blockSize = 0;
11391144
sequence&lt;Fragment> childFragments = [];
1145+
any data = null;
11401146
BreakTokenOptions breakToken = null;
11411147
};
11421148

@@ -1402,7 +1408,10 @@ following steps:
14021408
- The <a>fragmentation break</a> information set to |fragment|'s
14031409
{{FragmentResultOptions/breakToken}}.
14041410

1405-
TODO: storage of the break token.
1411+
- Let |clonedData| be the result of invoking <a>StructuredSerializeForStorage</a> on
1412+
|fragment|'s {{FragmentResultOptions/data}}.
1413+
1414+
The user agent must store |clonedData| with the <a>fragment</a>.
14061415
</div>
14071416

14081417
### Utility Algorithms ### {#utility-algorithms}
@@ -1520,7 +1529,9 @@ When the user agent wants to <dfn>run a generator</dfn> given |generator|, and |
15201529
<a>fragment</a> based on |layoutChild|, |childConstraintSpace|, and
15211530
|childBreakToken|.
15221531

1523-
5. Let |result| be a new {{Fragment}} with:
1532+
5. Let |targetRealm| be |generator|'s <a>Realm</a>.
1533+
1534+
6. Let |result| be a new {{Fragment}} with:
15241535

15251536
- {{Fragment/inlineSize}} being |internalFragment|'s <a>inline size</a>.
15261537

@@ -1533,6 +1544,10 @@ When the user agent wants to <dfn>run a generator</dfn> given |generator|, and |
15331544
- {{Fragment/breakToken}} being a new {{ChildBreakToken}} representing
15341545
|layoutChild|'s internal break token.
15351546

1547+
- If |internalFragment| has a |clonedData| object stored with it, let
1548+
{{Fragment/data}} being the result of
1549+
<a>StructuredDeserialize</a>(|clonedData|, |targetRealm|), otherwise null.
1550+
15361551
4. If |result| is null (that is neither of the above branches was taken), return
15371552
failure, and abort all these steps.
15381553

0 commit comments

Comments
 (0)