@@ -150,16 +150,19 @@ Box Tree Transformations {#layout-api-box-tree}
150
150
-----------------------------------------------
151
151
152
152
The <a>layout API children</a> can act in different ways depending on the value of <a for="document
153
- layout definition">child display</a> (set by <code> childDisplay</code> on the class).
153
+ layout definition">layout options</a> ' {{LayoutOptions/childDisplay}} (set by
154
+ <code> layoutOptions</code> on the class).
154
155
155
- If the value of <a for="document layout definition">child display</a> is <code> "block"</code> the
156
- 'display' value of that child is <a>blockified</a> . This is similar to children of <a>flex
157
- containers</a> or <a>grid containers</a> . See [[!css3-display]] .
156
+ If the value of <a for="document layout definition">layout options</a> '
157
+ {{LayoutOptions/childDisplay}} is <code> "block"</code> the 'display' value of that child is
158
+ <a>blockified</a> . This is similar to children of <a>flex containers</a> or <a>grid containers</a> .
159
+ See [[!css3-display]] .
158
160
159
- If the value of <a for="document layout definition">child display</a> is <code> "normal"</code> , no
160
- <a>blockification</a> occurs. Instead children with a <<display-outside>> <a>computed value</a> of
161
- ''inline'' (a <a>root inline box</a> ) will produce a single {{Fragment}} representing each line when
162
- {{LayoutChild/layoutNextFragment()}} is called.
161
+ If the value of <a for="document layout definition">layout options</a> '
162
+ {{LayoutOptions/childDisplay}} is <code> "normal"</code> , no <a>blockification</a> occurs. Instead
163
+ children with a <<display-outside>> <a>computed value</a> of ''inline'' (a <a>root inline box</a> )
164
+ will produce a single {{Fragment}} representing each line when {{LayoutChild/layoutNextFragment()}}
165
+ is called.
163
166
164
167
Note: This allows authors to adjust the available inline size of each line, and position each line
165
168
separately.
@@ -566,8 +569,8 @@ enum BreakType { "none", "line", "column", "page", "region" };
566
569
A {{LayoutChild}} can produce multiple {{Fragment}} s. A {{LayoutChild}} may fragment in the block
567
570
direction if a {{LayoutConstraints/blockFragmentationType}} is not none. Additionally
568
571
{{LayoutChild}} which represents <a>inline-level</a> content, may fragment line by line if the
569
- <a for="document layout definition">child display </a> (set by <code> childDisplay </code> ) is
570
- <code> "normal"</code> .
572
+ <a for="document layout definition">layout options </a> ' {{LayoutOptions/childDisplay}} (set by
573
+ <code> layoutOptions </code> ) is <code> "normal"</code> .
571
574
572
575
A subsequent {{Fragment}} is produced by using the previous {{Fragment}} 's {{Fragment/breakToken}} .
573
576
This tells the <a>child layout</a> to produce a {{Fragment}} starting at the point encoded in the
@@ -589,7 +592,7 @@ resume the layout.
589
592
590
593
<pre class="lang-javascript">
591
594
registerLayout('indent-lines' , class {
592
- static childDisplay = 'normal' ;
595
+ static layoutOptions = {childDisplay: 'normal' } ;
593
596
static inputProperties = ['--indent', '--indent-lines'] ;
594
597
595
598
*layout(constraints, children, styleMap, edges, breakToken) {
@@ -770,17 +773,36 @@ the size they would like the fragment to be.
770
773
If the user agent wishes to force a size on the box, it can use the
771
774
{{LayoutConstraints/fixedInlineSize}} and {{LayoutConstraints/fixedBlockSize}} attributes to do so.
772
775
773
- Issue: Do we want the inlineSize to always be fixed?
776
+ The <a>layout API container</a> can be passed size information in different ways depending on the
777
+ value of <a for="document layout definition">layout options</a> ' {{LayoutOptions/sizing}} (set by
778
+ <code> layoutOptions</code> on the class).
774
779
775
- The downside to this is that we won't be able to things like MathML in the initial version of
776
- the specifcation, which is able to "bubble" up inline sizes to its parent.
780
+ If the value of <a for="document layout definition">layout options</a> ' {{LayoutOptions/sizing}} is
781
+ <code> "block-like"</code> , then the {{LayoutConstraints}} passed to the <a>layout API container</a> :
782
+ - <em> Must</em> calculate and set {{LayoutConstraints/fixedInlineSize}} based off the rules
783
+ specified in [[!css-sizing-3]] and the formatting context in which it participates, e.g.
777
784
778
- We can't do a similar thing for the blockSize due to fragmentation. E.g. the size of the
779
- fragment which is undergoing fragmentation, isn't able to be automatically resolved.
785
+ - As a <a>block-level</a> box in a <a>block formatting context</a> , it is sized like a
786
+ <a>block box</a> that establishes a formatting context, with an ''width/auto'' <a>inline
787
+ size</a> calculated as for non-replaced block boxes.
780
788
781
- If the <a>layout API container</a> is within a <a>block formatting context</a> , is inflow, and has
782
- an ''width/auto'' inline size, the user agent <em> must</em> set the
783
- {{LayoutConstraints/fixedInlineSize}} to the <a>stretch-fit inline size</a> .
789
+ - As an <a>inline-level</a> box in an <a>inline formatting context</a> , it is sized as an
790
+ atomic inline-level box (such as an inline-block).
791
+
792
+ - <em> Must</em> calculate and set {{LayoutConstraints/fixedBlockSize}} based off the rules
793
+ specified in [[!css-sizing-3]] , and the formatting context in which it participates. If the
794
+ <a>layout API container</a> has an ''height/auto'' <a>block size</a> , and cannot be determined
795
+ ahead of time, {{LayoutConstraints/fixedBlockSize}} must be set to <code> null</code> .
796
+
797
+ If the value of <a for="document layout definition">layout options</a> ' {{LayoutOptions/sizing}} is
798
+ <code> "manual"</code> , then the user-agent shouldn't pre-calculate
799
+ {{LayoutConstraints/fixedInlineSize}} and/or {{LayoutConstraints/fixedBlockSize}} ahead of time,
800
+ except when it is being forced to a particular size by the formatting context in which it
801
+ participates, for example:
802
+
803
+ - If the <a>layout API container</a> is within a <a>block formatting context</a> , is inflow, and
804
+ has an ''width/auto'' inline size, the user agent <em> must</em> set the
805
+ {{LayoutConstraints/fixedInlineSize}} to the <a>stretch-fit inline size</a> .
784
806
785
807
<div class="note">
786
808
Note: In the example below the <a>layout API container</a> has its inline size set to 50.
@@ -1012,7 +1034,7 @@ A <dfn>layout definition</dfn> is a <a>struct</a> which describes the informatio
1012
1034
- <dfn for="layout definition">child input properties</dfn> which is a <a>list</a> of
1013
1035
<code> DOMStrings</code> .
1014
1036
1015
- - <dfn for="layout definition">child display </dfn> a {{ChildDisplayType }} .
1037
+ - <dfn for="layout definition">layout options </dfn> a {{LayoutOptions }} .
1016
1038
1017
1039
A <dfn>document layout definition</dfn> is a <a>struct</a> which describes the information needed by
1018
1040
the <a>document</a> about the author defined layout (which can be referenced by the ''layout()''
@@ -1024,7 +1046,7 @@ function). It consists of:
1024
1046
- <dfn for="document layout definition">child input properties</dfn> which is a <a>list</a> of
1025
1047
<code> DOMStrings</code> .
1026
1048
1027
- - <dfn for="document layout definition">child display </dfn> a {{ChildDisplayType }} .
1049
+ - <dfn for="document layout definition">layout options </dfn> a {{LayoutOptions }} .
1028
1050
1029
1051
Layout Worklet {#layout-worklet}
1030
1052
--------------------------------
@@ -1053,11 +1075,23 @@ Registering A Layout {#registering-layout}
1053
1075
------------------------------------------
1054
1076
1055
1077
<pre class='idl'>
1078
+ [Exposed=LayoutWorklet]
1079
+ dictionary LayoutOptions {
1080
+ ChildDisplayType childDisplay = "block";
1081
+ LayoutSizingMode sizing = "block-like";
1082
+ };
1083
+
1056
1084
[Exposed=LayoutWorklet]
1057
1085
enum ChildDisplayType {
1058
1086
"block",
1059
1087
"normal",
1060
1088
};
1089
+
1090
+ [Exposed=LayoutWorklet]
1091
+ enum LayoutSizingMode {
1092
+ "block-like",
1093
+ "manual",
1094
+ };
1061
1095
</pre>
1062
1096
1063
1097
Issue: "normal" is a bad name?
@@ -1109,40 +1143,38 @@ is called, the user agent <em>must</em> run the following steps:
1109
1143
<code> sequence<DOMString></code> . If an exception is <a>thrown</a> , rethrow the exception
1110
1144
and abort all these steps.
1111
1145
1112
- 10. Let |childDisplay | be a {{ChildDisplayType}} set to <code> "block" </code> .
1146
+ 10. Let |layoutOptionsValue | be the result of <a>Get</a> (|layoutCtor|, "layoutOptions") .
1113
1147
1114
- 11. Let |childDisplayValue| be the result of <a>Get</a> (|layoutCtor|, "childDisplay").
1115
-
1116
- 12. If |childDisplayValue| if not undefined, then then |childDisplay| to the result of
1117
- <a>converting</a> |childDisplayValue| to a {{ChildDisplayType}} . If an exception is
1118
- <a>thrown</a> , rethrow the exception and abort all these steps.
1148
+ 11. Let |layoutOptions| be the result of <a>converting</a> |layoutOptionsValue| to a
1149
+ {{LayoutOptions}} . If an exception is <a>thrown</a> , rethrow the exception and abort all
1150
+ these steps.
1119
1151
1120
- 13 . If the result of <a>IsConstructor</a> (|layoutCtor|) is false, <a>throw</a> a
1152
+ 12 . If the result of <a>IsConstructor</a> (|layoutCtor|) is false, <a>throw</a> a
1121
1153
<a>TypeError</a> and abort all these steps.
1122
1154
1123
- 14 . Let |prototype| be the result of <a>Get</a> (|layoutCtor|, "prototype").
1155
+ 13 . Let |prototype| be the result of <a>Get</a> (|layoutCtor|, "prototype").
1124
1156
1125
- 15 . If the result of <a>Type</a> (|prototype|) is not Object, <a>throw</a> a <a>TypeError</a> and
1157
+ 14 . If the result of <a>Type</a> (|prototype|) is not Object, <a>throw</a> a <a>TypeError</a> and
1126
1158
abort all these steps.
1127
1159
1128
- 16 . Let |layout| be the result of <a>Get</a> (|prototype|, <code> "layout"</code> ).
1160
+ 15 . Let |layout| be the result of <a>Get</a> (|prototype|, <code> "layout"</code> ).
1129
1161
1130
- 17 . If the result of <a>IsCallable</a> (|layout|) is false, <a>throw</a> a <a>TypeError</a> and
1162
+ 16 . If the result of <a>IsCallable</a> (|layout|) is false, <a>throw</a> a <a>TypeError</a> and
1131
1163
abort all these steps.
1132
1164
1133
- 18 . If |layout|'s <code> \[[FunctionKind]] </code> internal slot is not <code> "generator"</code> ,
1165
+ 17 . If |layout|'s <code> \[[FunctionKind]] </code> internal slot is not <code> "generator"</code> ,
1134
1166
<a>throw</a> a <a>TypeError</a> and abort all these steps.
1135
1167
1136
- 19 . Let |intrinsicSizes| be the result of <a>Get</a> (|prototype|,
1168
+ 18 . Let |intrinsicSizes| be the result of <a>Get</a> (|prototype|,
1137
1169
<code> "intrinsicSizes"</code> ).
1138
1170
1139
- 20 . If the result of <a>IsCallable</a> (|intrinsicSizes|) is false, <a>throw</a> a
1171
+ 19 . If the result of <a>IsCallable</a> (|intrinsicSizes|) is false, <a>throw</a> a
1140
1172
<a>TypeError</a> and abort all these steps.
1141
1173
1142
- 21 . If |intrinsicSizes|'s <code> \[[FunctionKind]] </code> internal slot is not
1174
+ 20 . If |intrinsicSizes|'s <code> \[[FunctionKind]] </code> internal slot is not
1143
1175
<code> "generator"</code> , <a>throw</a> a <a>TypeError</a> and abort all these steps.
1144
1176
1145
- 22 . Let |definition| be a new <a>layout definition</a> with:
1177
+ 21 . Let |definition| be a new <a>layout definition</a> with:
1146
1178
1147
1179
- <a>class constructor</a> being |layoutCtor|.
1148
1180
@@ -1156,11 +1188,11 @@ is called, the user agent <em>must</em> run the following steps:
1156
1188
1157
1189
- <a for="layout definition">child input properties</a> being |childInputProperties|.
1158
1190
1159
- - <a for="layout definition">child display </a> being |childDisplay |.
1191
+ - <a for="layout definition">layout options </a> being |layoutOptions |.
1160
1192
1161
- 23 . <a for=map>Set</a> |layoutDefinitionMap|[|name|] to |definition|.
1193
+ 22 . <a for=map>Set</a> |layoutDefinitionMap|[|name|] to |definition|.
1162
1194
1163
- 24 . <a>Queue a task</a> to run the following steps:
1195
+ 23 . <a>Queue a task</a> to run the following steps:
1164
1196
1165
1197
1. Let |documentLayoutDefinitionMap| be the associated <a>document's</a> <a>document layout
1166
1198
definitions</a> <a>map</a> .
@@ -1172,7 +1204,7 @@ is called, the user agent <em>must</em> run the following steps:
1172
1204
- <a for="document layout definition">child input properties</a> being
1173
1205
|childInputProperties|.
1174
1206
1175
- - <a for="document layout definition">child display </a> being |childDisplay |.
1207
+ - <a for="document layout definition">layout options </a> being |layoutOptions |.
1176
1208
1177
1209
3. If |documentLayoutDefinitionMap|[|name|] <a for=map>exists</a> , run the following steps:
1178
1210
@@ -1184,13 +1216,13 @@ is called, the user agent <em>must</em> run the following steps:
1184
1216
3. If |existingDocumentDefinition| and |documentDefinition| are not equivalent, (that is
1185
1217
<a for="document layout definition">input properties</a> , <a for="document layout
1186
1218
definition">child input properties</a> , and <a for="document layout
1187
- definition">child display </a> are different), then:
1219
+ definition">layout options </a> are different), then:
1188
1220
1189
1221
<a for=map>Set</a> |documentLayoutDefinitionMap|[|name|] to <code> "invalid"</code> .
1190
1222
1191
1223
Log an error to the debugging console stating that the same class was registered
1192
1224
with different <code> inputProperties</code> , <code> childInputProperties</code> , or
1193
- <code> childDisplay </code> .
1225
+ <code> layoutOptions </code> .
1194
1226
1195
1227
4. Otherwise, <a for=map>set</a> |documentLayoutDefinitionMap|[|name|] to
1196
1228
|documentDefinition|.
@@ -1201,7 +1233,9 @@ is called, the user agent <em>must</em> run the following steps:
1201
1233
class MyLayout {
1202
1234
static get inputProperties() { return ['--foo'] ; }
1203
1235
static get childrenInputProperties() { return ['--bar'] ; }
1204
- static get childDisplay() { return 'normal' ; }
1236
+ static get layoutOptions() {
1237
+ return {childDisplay: 'normal' , sizing: 'block-like' }
1238
+ }
1205
1239
1206
1240
*intrinsicSizes(children, styleMap) {
1207
1241
// Intrinsic sizes code goes here.
0 commit comments