Skip to content

Commit d707964

Browse files
committed
[css-layout-api] Move concepts up to layoutWorklet section.
1 parent 01a1158 commit d707964

File tree

1 file changed

+64
-52
lines changed

1 file changed

+64
-52
lines changed

css-layout-api/Overview.bs

Lines changed: 64 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,15 @@ As the layout is entirely up to the author, properties which are used in other l
142142
flex, block) may not apply. For example an author may not respect the 'margin' property on children.
143143

144144
<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.
146147

147148
<pre class="lang-html">
148149
&lt;!DOCTYPE html>
149150
&lt;style>
150-
.centering-layout { display: layout(centering); }
151+
@supports (display: layout(centering)) {
152+
.centering-layout { display: layout(centering); }
153+
}
151154
&lt;/style>
152155
&lt;div class="centering-layout">&lt;/div>
153156
</pre>
@@ -215,7 +218,7 @@ Layout Worklet {#layout-worklet}
215218
The {{layoutWorklet}} attribute allows access to the {{Worklet}} responsible for all the classes
216219
which are related to layout.
217220

218-
The {{layoutWorklet}}'s <a>worklet global scope type</a> is {{LayoutWorkletGlobalScope}}.
221+
The {{layoutWorklet}}'s [=worklet global scope type=] is {{LayoutWorkletGlobalScope}}.
219222

220223
<pre class='idl'>
221224
partial namespace CSS {
@@ -232,6 +235,54 @@ interface LayoutWorkletGlobalScope : WorkletGlobalScope {
232235
};
233236
</pre>
234237

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+
235286
Registering A Layout {#registering-layout}
236287
------------------------------------------
237288

@@ -255,20 +306,20 @@ enum LayoutSizingMode {
255306
};
256307
</pre>
257308

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.
260311

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.
263314

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
265316
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=].
267318

268319
<div class='note'>
269320
Note: The shape of the class should be:
270321
<pre class='lang-javascript'>
271-
class MyLayout {
322+
registerLayout('example', class {
272323
static get inputProperties() { return ['--foo']; }
273324
static get childrenInputProperties() { return ['--bar']; }
274325
static get layoutOptions() {
@@ -282,16 +333,13 @@ instances</dfn>. Initially this map is empty; it is populated when the user agen
282333
async layout(children, edges, constraints, styleMap, breakToken) {
283334
// Layout code goes here.
284335
}
285-
}
336+
});
286337
</pre>
287338
</div>
288339
</div>
289340

290-
Registering A Layout Algorithm {#registering-a-layout-algorithm}
291-
----------------------------------------------------------------
292-
293341
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.
295343

296344
<div algorithm>
297345
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:
352400
17. Let |intrinsicSizes| be the result of [=converting=] |intrinsicSizesValue| to the
353401
[=Function=] [=callback function=] type. Rethrow any exceptions from the conversion.
354402

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>).
356404

357405
19. Let |layout| be the result of [=converting=] |layoutValue| to the [=Function=] [=callback
358406
function=] type. Rethrow any exceptions from the conversion.
@@ -1460,42 +1508,6 @@ Layout {#layout}
14601508

14611509
This section describes how the CSS Layout API interacts with the user agent's layout engine.
14621510

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-
14991511
Layout Invalidation {#layout-invalidation}
15001512
------------------------------------------
15011513

0 commit comments

Comments
 (0)