@@ -156,6 +156,8 @@ Layout Children {#layout-children}
156
156
<pre class='idl'>
157
157
[Exposed=LayoutWorklet]
158
158
interface LayoutChild {
159
+ readonly attribute StylePropertyMapReadOnly styleMap;
160
+
159
161
FragmentRequest layoutNextFragment(ConstraintSpace space, ChildBreakToken breakToken);
160
162
};
161
163
@@ -165,7 +167,6 @@ interface InlineLayoutChild : LayoutChild {
165
167
166
168
[Exposed=LayoutWorklet]
167
169
interface BoxLayoutChild : LayoutChild {
168
- readonly attribute StylePropertyMapReadOnly styleMap;
169
170
};
170
171
</pre>
171
172
@@ -206,7 +207,7 @@ Note: In a future level of the specification there may be a way to query the com
206
207
of ranges inside a {{InlineLayoutChild}} .
207
208
208
209
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
210
211
properties which are listed in the child input properties array.
211
212
212
213
A {{BoxLayoutChild}} could be generated by:
@@ -777,6 +778,9 @@ A <dfn>layout definition</dfn> is a <a>struct</a> which describes the informatio
777
778
- <dfn for="layout definition">layout generator function</dfn> which is the layout <a>generator
778
779
function</a> callback.
779
780
781
+ - <dfn for="layout definition">content size generator function</dfn> which is the content size
782
+ <a>generator function</a> callback.
783
+
780
784
- <dfn for="layout definition">constructor valid flag</dfn> .
781
785
782
786
- <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:
905
909
18. If |layout|'s <code> \[[FunctionKind]] </code> internal slot is not <code> "generator"</code> ,
906
910
<a>throw</a> a <a>TypeError</a> and abort all these steps.
907
911
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:
909
921
910
922
- <a>class constructor</a> being |layoutCtor|.
911
923
912
924
- <a>layout generator function</a> being |layout|.
913
925
926
+ - <a>content size generator function</a> being |contentSize|.
927
+
914
928
- <a>constructor valid flag</a> being <b> true</b> .
915
929
916
930
- <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:
919
933
920
934
- <a for="layout definition">child display</a> being |childDisplay|.
921
935
922
- 20 . <a for=map>Set</a> |layoutDefinitionMap|[|name|] to |definition|.
936
+ 23 . <a for=map>Set</a> |layoutDefinitionMap|[|name|] to |definition|.
923
937
924
- 21 . <a>Queue a task</a> to run the following steps:
938
+ 24 . <a>Queue a task</a> to run the following steps:
925
939
926
940
1. Let |documentLayoutDefinitionMap| be the associated <a>document's</a> <a>document layout
927
941
definitions</a> <a>map</a> .
@@ -964,6 +978,10 @@ is called, the user agent <em>must</em> run the following steps:
964
978
static get childrenInputProperties() { return ['--bar'] ; }
965
979
static get childDisplay() { return 'normal' ; }
966
980
981
+ *contentSize(children, styleMap) {
982
+ // min/max content size code goes here.
983
+ }
984
+
967
985
*layout(constraintSpace, children, styleMap, breakToken) {
968
986
// Layout code goes here.
969
987
}
@@ -983,11 +1001,17 @@ interface FragmentRequest {
983
1001
// [[constraintSpace]] - The constraint space to perform layout in.
984
1002
// [[breakToken]] - The break token to resume the layout with.
985
1003
};
1004
+
1005
+ [Exposed=LayoutWorklet]
1006
+ interface ContentSizeRequest {
1007
+ // Has internal slots:
1008
+ // [[layoutChild]] - The layout child to calculate the content size for.
1009
+ };
986
1010
</pre>
987
1011
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.
991
1015
992
1016
When an author invokes the {{LayoutChild/layoutNextFragment()}} method on a {{LayoutChild}} the
993
1017
user-agent doesn't synchronously generate a {{Fragment}} to return to the author's code. Instead it
@@ -1018,7 +1042,7 @@ class LayoutEngine {
1018
1042
// This function takes a FragmentRequest and calls the appropriate layout
1019
1043
// algorithm to generate the a Fragment.
1020
1044
layoutFragment(fragmentRequest) {
1021
- const box = fragmentRequest.box ;
1045
+ const box = fragmentRequest.layoutChild ;
1022
1046
const algorithm = selectLayoutAlgorithmForBox(box);
1023
1047
const fragmentRequestGenerator = algorithm.layout(
1024
1048
fragmentRequest.constraintSpace,
@@ -1060,6 +1084,11 @@ dictionary FragmentResultOptions {
1060
1084
BreakTokenOptions breakToken = null;
1061
1085
double alignmentBaseline = null;
1062
1086
};
1087
+
1088
+ dictionary ContentSizeResultOptions {
1089
+ double maxContentSize;
1090
+ double minContentSize;
1091
+ };
1063
1092
</pre>
1064
1093
1065
1094
Issue: Specify how we do min/max content contributions.
0 commit comments