@@ -142,12 +142,15 @@ As the layout is entirely up to the author, properties which are used in other l
142
142
flex, block) may not apply. For example an author may not respect the 'margin' property on children.
143
143
144
144
<div class="example">
145
- The HTML below shows an example of setting the ''display'' to a ''layout()'' function.
145
+ The HTML below shows an example of setting the ''display'' to a ''layout()'' function, if the CSS
146
+ Layout API is supported.
146
147
147
148
<pre class="lang-html">
148
149
<!DOCTYPE html>
149
150
<style>
150
- .centering-layout { display: layout(centering); }
151
+ @supports (display: layout(centering)) {
152
+ .centering-layout { display: layout(centering); }
153
+ }
151
154
</style>
152
155
<div class="centering-layout"></div>
153
156
</pre>
@@ -215,7 +218,7 @@ Layout Worklet {#layout-worklet}
215
218
The {{layoutWorklet}} attribute allows access to the {{Worklet}} responsible for all the classes
216
219
which are related to layout.
217
220
218
- The {{layoutWorklet}} 's <a> worklet global scope type</a> is {{LayoutWorkletGlobalScope}} .
221
+ The {{layoutWorklet}} 's [= worklet global scope type=] is {{LayoutWorkletGlobalScope}} .
219
222
220
223
<pre class='idl'>
221
224
partial namespace CSS {
@@ -232,6 +235,54 @@ interface LayoutWorkletGlobalScope : WorkletGlobalScope {
232
235
};
233
236
</pre>
234
237
238
+ <div class='example'>
239
+ Web developers can feature detect by:
240
+ <pre class='lang-javascript'>
241
+ if ('layoutWorklet' in CSS) {
242
+ console.log('CSS Layout API available!' );
243
+ }
244
+ </pre>
245
+ </div>
246
+
247
+ Concepts {#concepts}
248
+ --------------------
249
+
250
+ This section describes internal data-structures created when {{registerLayout(name, layoutCtor)}} is
251
+ called.
252
+
253
+ A <dfn>layout definition</dfn> is a [=struct=] which describes the information needed by the
254
+ {{LayoutWorkletGlobalScope}} about the author defined layout (which can be referenced by the
255
+ ''layout()'' function). It consists of:
256
+
257
+ - <dfn for="layout definition">class constructor</dfn> which is the class [=constructor=] .
258
+
259
+ - <dfn for="layout definition">layout function</dfn> which is the layout [=function=] callback.
260
+
261
+ - <dfn for="layout definition">intrinsic sizes function</dfn> which is the intrinsic sizes
262
+ [=function=] callback.
263
+
264
+ - <dfn for="layout definition">constructor valid flag</dfn> .
265
+
266
+ - <dfn for="layout definition">input properties</dfn> which is a [=list=] of
267
+ <code> DOMStrings</code> .
268
+
269
+ - <dfn for="layout definition">child input properties</dfn> which is a [=list=] of
270
+ <code> DOMStrings</code> .
271
+
272
+ - <dfn for="layout definition">layout options</dfn> a {{LayoutOptions}} .
273
+
274
+ A <dfn>document layout definition</dfn> is a [=struct=] which describes the information needed by
275
+ the [=document=] about the author defined layout (which can be referenced by the ''layout()''
276
+ function). It consists of:
277
+
278
+ - <dfn for="document layout definition">input properties</dfn> which is a [=list=] of
279
+ <code> DOMStrings</code>
280
+
281
+ - <dfn for="document layout definition">child input properties</dfn> which is a [=list=] of
282
+ <code> DOMStrings</code> .
283
+
284
+ - <dfn for="document layout definition">layout options</dfn> a {{LayoutOptions}} .
285
+
235
286
Registering A Layout {#registering-layout}
236
287
------------------------------------------
237
288
@@ -255,20 +306,20 @@ enum LayoutSizingMode {
255
306
};
256
307
</pre>
257
308
258
- The <a> document</a> has a <a> map</a> of <dfn>document layout definitions</dfn> . Initially this map
259
- is empty; it is populated when {{registerLayout(name, layoutCtor)}} is called.
309
+ The [= document=] has a [= map=] of <dfn>document layout definitions</dfn> . Initially this map is
310
+ empty; it is populated when {{registerLayout(name, layoutCtor)}} is called.
260
311
261
- The {{LayoutWorkletGlobalScope}} has a <a> map</a> of <dfn>layout definitions</dfn> . Initially this
262
- map is empty; it is populated when {{registerLayout(name, layoutCtor)}} is called.
312
+ The {{LayoutWorkletGlobalScope}} has a [= map=] of <dfn>layout definitions</dfn> . Initially this map
313
+ is empty; it is populated when {{registerLayout(name, layoutCtor)}} is called.
263
314
264
- Each <a> box</a> representing a <a> layout API container</a> has a <a> map</a> of <dfn>layout class
315
+ Each [= box=] representing a [= layout API container</a> has a [= map=] of <dfn>layout class
265
316
instances</dfn> . Initially this map is empty; it is populated when the user agent calls either
266
- <a> determine the intrinsic sizes</a> or <a> generate a fragment</a> for a <a> box</a> .
317
+ [= determine the intrinsic sizes=] or [= generate a fragment=] for a [= box=] .
267
318
268
319
<div class='note'>
269
320
Note: The shape of the class should be:
270
321
<pre class='lang-javascript'>
271
- class MyLayout {
322
+ registerLayout( 'example' , class {
272
323
static get inputProperties() { return ['--foo'] ; }
273
324
static get childrenInputProperties() { return ['--bar'] ; }
274
325
static get layoutOptions() {
@@ -282,16 +333,13 @@ instances</dfn>. Initially this map is empty; it is populated when the user agen
282
333
async layout(children, edges, constraints, styleMap, breakToken) {
283
334
// Layout code goes here.
284
335
}
285
- }
336
+ });
286
337
</pre>
287
338
</div>
288
339
</div>
289
340
290
- Registering A Layout Algorithm {#registering-a-layout-algorithm}
291
- ----------------------------------------------------------------
292
-
293
341
The algorithm below is run when the {{registerLayout(name, layoutCtor)}} is called. It notifies the
294
- engine about the new user defined layout.
342
+ user agent rendering engine about the new user defined layout.
295
343
296
344
<div algorithm>
297
345
When the <dfn method for=LayoutWorkletGlobalScope>registerLayout(|name|, |layoutCtor|)</dfn> method
@@ -352,7 +400,7 @@ is called, the user agent <em>must</em> run the following steps:
352
400
17. Let |intrinsicSizes| be the result of [=converting=] |intrinsicSizesValue| to the
353
401
[=Function=] [=callback function=] type. Rethrow any exceptions from the conversion.
354
402
355
- 18. Let |layoutValue| be the result of <a> Get</a> (|prototype|, <code> "layout"</code> ).
403
+ 18. Let |layoutValue| be the result of [= Get=] (|prototype|, <code> "layout"</code> ).
356
404
357
405
19. Let |layout| be the result of [=converting=] |layoutValue| to the [=Function=] [=callback
358
406
function=] type. Rethrow any exceptions from the conversion.
@@ -1460,42 +1508,6 @@ Layout {#layout}
1460
1508
1461
1509
This section describes how the CSS Layout API interacts with the user agent's layout engine.
1462
1510
1463
- Concepts {#concepts}
1464
- --------------------
1465
-
1466
- A <dfn>layout definition</dfn> is a <a>struct</a> which describes the information needed by the
1467
- {{LayoutWorkletGlobalScope}} about the author defined layout (which can be referenced by the
1468
- ''layout()'' function). It consists of:
1469
-
1470
- - <dfn for="layout definition">class constructor</dfn> which is the class <a>constructor</a> .
1471
-
1472
- - <dfn for="layout definition">layout function</dfn> which is the layout <a>function</a> callback.
1473
-
1474
- - <dfn for="layout definition">intrinsic sizes function</dfn> which is the intrinsic sizes
1475
- <a>function</a> callback.
1476
-
1477
- - <dfn for="layout definition">constructor valid flag</dfn> .
1478
-
1479
- - <dfn for="layout definition">input properties</dfn> which is a <a>list</a> of
1480
- <code> DOMStrings</code>
1481
-
1482
- - <dfn for="layout definition">child input properties</dfn> which is a <a>list</a> of
1483
- <code> DOMStrings</code> .
1484
-
1485
- - <dfn for="layout definition">layout options</dfn> a {{LayoutOptions}} .
1486
-
1487
- A <dfn>document layout definition</dfn> is a <a>struct</a> which describes the information needed by
1488
- the <a>document</a> about the author defined layout (which can be referenced by the ''layout()''
1489
- function). It consists of:
1490
-
1491
- - <dfn for="document layout definition">input properties</dfn> which is a <a>list</a> of
1492
- <code> DOMStrings</code>
1493
-
1494
- - <dfn for="document layout definition">child input properties</dfn> which is a <a>list</a> of
1495
- <code> DOMStrings</code> .
1496
-
1497
- - <dfn for="document layout definition">layout options</dfn> a {{LayoutOptions}} .
1498
-
1499
1511
Layout Invalidation {#layout-invalidation}
1500
1512
------------------------------------------
1501
1513
0 commit comments