Skip to content

Commit 1f5605e

Browse files
committed
[css-layout-api] Initial parts of contentSize callback.
1 parent b8aadd0 commit 1f5605e

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

css-layout-api/Overview.bs

+38-9
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ Layout Children {#layout-children}
156156
<pre class='idl'>
157157
[Exposed=LayoutWorklet]
158158
interface LayoutChild {
159+
readonly attribute StylePropertyMapReadOnly styleMap;
160+
159161
FragmentRequest layoutNextFragment(ConstraintSpace space, ChildBreakToken breakToken);
160162
};
161163

@@ -165,7 +167,6 @@ interface InlineLayoutChild : LayoutChild {
165167

166168
[Exposed=LayoutWorklet]
167169
interface BoxLayoutChild : LayoutChild {
168-
readonly attribute StylePropertyMapReadOnly styleMap;
169170
};
170171
</pre>
171172

@@ -206,7 +207,7 @@ Note: In a future level of the specification there may be a way to query the com
206207
of ranges inside a {{InlineLayoutChild}}.
207208

208209
A {{BoxLayoutChild}} represents a single <a>box</a>. It does have an associated computed style which
209-
can be accessed by {{BoxLayoutChild/styleMap}}. The {{BoxLayoutChild/styleMap}} will only contain
210+
can be accessed by {{LayoutChild/styleMap}}. The {{LayoutChild/styleMap}} will only contain
210211
properties which are listed in the child input properties array.
211212

212213
A {{BoxLayoutChild}} could be generated by:
@@ -777,6 +778,9 @@ A <dfn>layout definition</dfn> is a <a>struct</a> which describes the informatio
777778
- <dfn for="layout definition">layout generator function</dfn> which is the layout <a>generator
778779
function</a> callback.
779780

781+
- <dfn for="layout definition">content size generator function</dfn> which is the content size
782+
<a>generator function</a> callback.
783+
780784
- <dfn for="layout definition">constructor valid flag</dfn>.
781785

782786
- <dfn for="layout definition">input properties</dfn> which is a <a>list</a> of
@@ -905,12 +909,22 @@ is called, the user agent <em>must</em> run the following steps:
905909
18. If |layout|'s <code>\[[FunctionKind]]</code> internal slot is not <code>"generator"</code>,
906910
<a>throw</a> a <a>TypeError</a> and abort all these steps.
907911

908-
19. Let |definition| be a new <a>layout definition</a> with:
912+
19. Let |contentSize| be the result of <a>Get</a>(|prototype|, <code>"contentSize"</code>).
913+
914+
20. If the result of <a>IsCallable</a>(|contentSize|) is false, <a>throw</a> a <a>TypeError</a>
915+
and abort all these steps.
916+
917+
21. If |contentSize|'s <code>\[[FunctionKind]]</code> internal slot is not
918+
<code>"generator"</code>, <a>throw</a> a <a>TypeError</a> and abort all these steps.
919+
920+
22. Let |definition| be a new <a>layout definition</a> with:
909921

910922
- <a>class constructor</a> being |layoutCtor|.
911923

912924
- <a>layout generator function</a> being |layout|.
913925

926+
- <a>content size generator function</a> being |contentSize|.
927+
914928
- <a>constructor valid flag</a> being <b>true</b>.
915929

916930
- <a for="layout definition">input properties</a> being |inputProperties|.
@@ -919,9 +933,9 @@ is called, the user agent <em>must</em> run the following steps:
919933

920934
- <a for="layout definition">child display</a> being |childDisplay|.
921935

922-
20. <a for=map>Set</a> |layoutDefinitionMap|[|name|] to |definition|.
936+
23. <a for=map>Set</a> |layoutDefinitionMap|[|name|] to |definition|.
923937

924-
21. <a>Queue a task</a> to run the following steps:
938+
24. <a>Queue a task</a> to run the following steps:
925939

926940
1. Let |documentLayoutDefinitionMap| be the associated <a>document's</a> <a>document layout
927941
definitions</a> <a>map</a>.
@@ -964,6 +978,10 @@ is called, the user agent <em>must</em> run the following steps:
964978
static get childrenInputProperties() { return ['--bar']; }
965979
static get childDisplay() { return 'normal'; }
966980

981+
*contentSize(children, styleMap) {
982+
// min/max content size code goes here.
983+
}
984+
967985
*layout(constraintSpace, children, styleMap, breakToken) {
968986
// Layout code goes here.
969987
}
@@ -983,11 +1001,17 @@ interface FragmentRequest {
9831001
// [[constraintSpace]] - The constraint space to perform layout in.
9841002
// [[breakToken]] - The break token to resume the layout with.
9851003
};
1004+
1005+
[Exposed=LayoutWorklet]
1006+
interface ContentSizeRequest {
1007+
// Has internal slots:
1008+
// [[layoutChild]] - The layout child to calculate the content size for.
1009+
};
9861010
</pre>
9871011

988-
The layout method on the author supplied layout class is a generator function instead of a regular
989-
javascript function. This is for user-agents to be able to support asynchronous and parallel layout
990-
engines.
1012+
The layout method and content size method on the author supplied layout class is a generator
1013+
function instead of a regular javascript function. This is for user-agents to be able to support
1014+
asynchronous and parallel layout engines.
9911015

9921016
When an author invokes the {{LayoutChild/layoutNextFragment()}} method on a {{LayoutChild}} the
9931017
user-agent doesn't synchronously generate a {{Fragment}} to return to the author's code. Instead it
@@ -1018,7 +1042,7 @@ class LayoutEngine {
10181042
// This function takes a FragmentRequest and calls the appropriate layout
10191043
// algorithm to generate the a Fragment.
10201044
layoutFragment(fragmentRequest) {
1021-
const box = fragmentRequest.box;
1045+
const box = fragmentRequest.layoutChild;
10221046
const algorithm = selectLayoutAlgorithmForBox(box);
10231047
const fragmentRequestGenerator = algorithm.layout(
10241048
fragmentRequest.constraintSpace,
@@ -1060,6 +1084,11 @@ dictionary FragmentResultOptions {
10601084
BreakTokenOptions breakToken = null;
10611085
double alignmentBaseline = null;
10621086
};
1087+
1088+
dictionary ContentSizeResultOptions {
1089+
double maxContentSize;
1090+
double minContentSize;
1091+
};
10631092
</pre>
10641093

10651094
Issue: Specify how we do min/max content contributions.

0 commit comments

Comments
 (0)