@@ -271,6 +271,9 @@ function). It consists of:
271271Registering A Layout {#registering-layout}
272272------------------------------------------
273273
274+ The section describes how a web developer uses {{registerLayout(name, layoutCtor)}} to register a
275+ layout.
276+
274277<pre class='idl'>
275278[Exposed=LayoutWorklet]
276279dictionary LayoutOptions {
@@ -280,14 +283,14 @@ dictionary LayoutOptions {
280283
281284[Exposed=LayoutWorklet]
282285enum ChildDisplayType {
283- "block",
286+ "block", // default - "blockifies" the child boxes.
284287 "normal",
285288};
286289
287290[Exposed=LayoutWorklet]
288291enum LayoutSizingMode {
289- "block-like",
290- "manual",
292+ "block-like", // default - Sizing behaves like block containers.
293+ "manual", // Sizing is specified by the web developer.
291294};
292295</pre>
293296
@@ -459,7 +462,7 @@ A <dfn>child layout</dfn> is the layout algorithm for a {{LayoutChild}} of the [
459462Layout API {#layout-api}
460463========================
461464
462- This section gives an overview of the Layout API given to authors .
465+ This section describes the objects of the Layout API provided to web developers .
463466
464467Layout Children {#layout-children}
465468----------------------------------
@@ -586,6 +589,9 @@ user agent must perform the following steps:
586589 1. Return |this|' {{StylePropertyMapReadOnly}} contained in the {{[[styleMap]]}} internal slot.
587590</div>
588591
592+ Note: The {{intrinsicSizes()}} method allows the web developer to query the intrinsic sizes of the
593+ {{LayoutChild}} .
594+
589595<div algorithm>
590596When the <dfn method for=LayoutChild>intrinsicSizes()</dfn> method is called on a {{LayoutChild}}
591597|this|, the user agent must perform the following steps:
@@ -613,6 +619,9 @@ When the <dfn method for=LayoutChild>intrinsicSizes()</dfn> method is called on
613619 6. Return |p|.
614620</div>
615621
622+ Note: The {{layoutNextFragment()}} method allows the web developer to produce a {{LayoutFragment}}
623+ for a given {{LayoutChild}} (the result of performing layout).
624+
616625<div algorithm>
617626When the <dfn method for=LayoutChild>layoutNextFragment(|constraints|, |breakToken|)</dfn> method is
618627called on a {{LayoutChild}} |this|, the user agent must perform the following steps:
@@ -658,6 +667,9 @@ called on a {{LayoutChild}} |this|, the user agent must perform the following st
658667Each [=box=] has a <dfn attribute for=box>\[[layoutChildMap]]</dfn> internal slot, which is a
659668[=map=] of {{LayoutWorkletGlobalScope}} s to {{LayoutChild}} ren.
660669
670+ Note: [=Get a layout child=] returns a {{LayoutChild}} object for the correct
671+ {{LayoutWorkletGlobalScope}} and creates one if it doesn't exist yet.
672+
661673<div algorithm="get a layout child">
662674When the user agent wants to <dfn>get a layout child</dfn> given |workletGlobalScope|, |name|,
663675 |box|, and |uniqueId|, it <em> must</em> run the following steps:
@@ -729,6 +741,9 @@ style=] algorithm.
729741Layout Fragments {#layout-fragments}
730742------------------------------------
731743
744+ A {{LayoutFragment}} represents a CSS [=fragment=] of a {{LayoutChild}} after layout has occurred on
745+ that child. This is produced by the {{LayoutChild/layoutNextFragment()}} method.
746+
732747<pre class='idl'>
733748[Exposed=LayoutWorklet]
734749interface LayoutFragment {
@@ -751,9 +766,6 @@ The {{LayoutFragment}} has internal slot(s):
751766
752767<hr>
753768
754- A {{LayoutFragment}} represents a CSS [=fragment=] of a {{LayoutChild}} after layout has occurred on
755- that child. This is produced by the {{LayoutChild/layoutNextFragment()}} method.
756-
757769The {{LayoutFragment}} has {{LayoutFragment/inlineSize}} and {{LayoutFragment/blockSize}}
758770attributes, which are set by the respective child's layout algorithm. They represent the <b> border
759771box</b> size of the CSS [=fragment=] , and are relative to the [=current layout's=] writing mode.
@@ -890,6 +902,9 @@ registerLayout('intrinsic-sizes-example', class {
890902Layout Constraints {#layout-constraints}
891903----------------------------------------
892904
905+ A {{LayoutConstraints}} object is passed into the layout method which represents the all the
906+ constraints for the [=current layout=] to perform layout within.
907+
893908<pre class='idl'>
894909[Exposed=LayoutWorklet]
895910interface LayoutConstraints {
@@ -911,9 +926,6 @@ interface LayoutConstraints {
911926enum BlockFragmentationType { "none", "page", "column", "region" };
912927</pre>
913928
914- A {{LayoutConstraints}} object is passed into the layout method which represents the all the
915- constraints for the [=current layout=] to perform layout inside.
916-
917929The {{LayoutConstraints}} object has {{LayoutConstraints/availableInlineSize}} and
918930{{LayoutConstraints/availableBlockSize}} attributes. This represents the [=available space=] for the
919931[=current layout=] to respect.
@@ -1015,6 +1027,9 @@ and |internalLayoutConstraints|, it <em>must</em> run the following steps:
10151027
10161028### Constraints for Layout Children ### {#layout-constraints-children}
10171029
1030+ The {{LayoutConstraintsOptions}} dictionary represents the set of constraints which can be passed to
1031+ a {{LayoutChild}} to produce a {{LayoutFragment}} .
1032+
10181033<pre class='idl'>
10191034dictionary LayoutConstraintsOptions {
10201035 double availableInlineSize;
@@ -1033,9 +1048,6 @@ dictionary LayoutConstraintsOptions {
10331048};
10341049</pre>
10351050
1036- The {{LayoutConstraintsOptions}} dictionary represents the set of constraints which can be passed to
1037- a {{LayoutChild}} to produce a {{LayoutFragment}} .
1038-
10391051<div class="example">
10401052The example below shows the basic usage of the {{LayoutConstraintsOptions}} dictionary.
10411053
@@ -1069,6 +1081,12 @@ Issue: Specify how to convert to internal representation of these values.
10691081Breaking and Fragmentation {#breaking-and-fragmentation}
10701082--------------------------------------------------------
10711083
1084+ A {{LayoutChild}} can produce multiple {{LayoutFragment}} s. A {{LayoutChild}} may fragment in the
1085+ block direction if a {{LayoutConstraints/blockFragmentationType}} is not none. Additionally
1086+ {{LayoutChild}} which represents [=inline-level=] content, may fragment line by line if the
1087+ <a for="document layout definition">layout options'</a> {{LayoutOptions/childDisplay}} (set by
1088+ <code> layoutOptions</code> ) is <code> "normal"</code> .
1089+
10721090<pre class="idl">
10731091[Exposed=LayoutWorklet]
10741092interface ChildBreakToken {
@@ -1097,19 +1115,16 @@ The {{ChildBreakToken}} has internal slot(s):
10971115
10981116<hr>
10991117
1100- A {{LayoutChild}} can produce multiple {{LayoutFragment}} s. A {{LayoutChild}} may fragment in the
1101- block direction if a {{LayoutConstraints/blockFragmentationType}} is not none. Additionally
1102- {{LayoutChild}} which represents [=inline-level=] content, may fragment line by line if the
1103- <a for="document layout definition">layout options'</a> {{LayoutOptions/childDisplay}} (set by
1104- <code> layoutOptions</code> ) is <code> "normal"</code> .
1105-
11061118A subsequent {{LayoutFragment}} is produced by using the previous {{LayoutFragment}} 's
11071119{{LayoutFragment/breakToken}} . This tells the [=child layout=] to produce a {{LayoutFragment}}
11081120starting at the point encoded in the {{ChildBreakToken}} .
11091121
11101122Edges {#edges}
11111123--------------
11121124
1125+ A {{LayoutEdges}} object is passed into the layout method. This represents the sum of all the [=box
1126+ model edges=] (border, scrollbar, padding), for the current box which is being laid out.
1127+
11131128<pre class='idl'>
11141129[Exposed=LayoutWorklet]
11151130interface LayoutEdges {
@@ -1125,9 +1140,6 @@ interface LayoutEdges {
11251140};
11261141</pre>
11271142
1128- A {{LayoutEdges}} object is passed into the layout method. This represents the sum of all the [=box
1129- model edges=] (border, scrollbar, padding), for the current box which is being laid out.
1130-
11311143Each of the accessors represents the width in CSS pixels of an edge in each of the [=abstract
11321144dimensions=] ({{LayoutEdges/inlineStart}} , {{LayoutEdges/inlineEnd}} , {{LayoutEdges/blockStart}} ,
11331145{{LayoutEdges/blockEnd}} ).
@@ -1450,6 +1462,9 @@ run the following steps:
14501462Performing Layout {#performing-layout}
14511463--------------------------------------
14521464
1465+ The section describes how a user agent calls the web developer defined layout to produces intrinsic
1466+ sizes, and fragments.
1467+
14531468<pre class='idl'>
14541469// This is the final return value from the author defined layout() method.
14551470dictionary FragmentResultOptions {
@@ -1654,16 +1669,16 @@ context=] for a given |box|, |childBoxes| it <em>must</em> run the following ste
16541669 The user agent <em> may</em> also [=create a WorkletGlobalScope=] at this time, given the
16551670 layout {{Worklet}} .
16561671
1657- 5. Run [=invoke a intrinsic sizes callback=] given |name|, |box|, |childBoxes|, and
1672+ 5. Run [=invoke an intrinsic sizes callback=] given |name|, |box|, |childBoxes|, and
16581673 |workletGlobalScope| optionally [=in parallel=] .
16591674
1660- Note: If the user agent runs [=invoke a intrinsic sizes callback=] on a thread [=in
1675+ Note: If the user agent runs [=invoke an intrinsic sizes callback=] on a thread [=in
16611676 parallel=] , it should select a layout worklet global scope which can be used on that
16621677 thread.
16631678</div>
16641679
1665- <div algorithm="invoke a intrinsic sizes callback">
1666- When the user agent wants to <dfn>invoke a intrinsic sizes callback</dfn> given |name|, |box|,
1680+ <div algorithm="invoke an intrinsic sizes callback">
1681+ When the user agent wants to <dfn>invoke an intrinsic sizes callback</dfn> given |name|, |box|,
16671682|childBoxes|, and |workletGlobalScope|, it <em> must</em> run the following steps:
16681683
16691684 1. Let |definition| be the result of [=get a layout definition=] given |name|, and
@@ -1709,6 +1724,8 @@ When the user agent wants to <dfn>invoke a intrinsic sizes callback</dfn> given
17091724 If an exception is [=thrown=] the let |box| fallback to the [=flow layout=] and abort all
17101725 these steps.
17111726
1727+ Issue: Handle non-promise case.
1728+
17121729 12. Let |intrinsicSizesValue| be the result of [=run a work queue=] given |promise|, and
17131730 |context|'s [=work queue=] .
17141731
@@ -1769,8 +1786,8 @@ it <em>must</em> run the following steps:
17691786 |internalLayoutConstraints|, |internalBreakToken|, and |workletGlobalScope| optionally [=in
17701787 parallel=] .
17711788
1772- Note: If the user agent runs [=invoke a intrinsic sizes callback=] on a thread [=in
1773- parallel=] , it should select a layout worklet global scope which can be used on that thread.
1789+ Note: If the user agent runs [=invoke a layout callback=] on a thread [=in parallel=] , it
1790+ should select a layout worklet global scope which can be used on that thread.
17741791</div>
17751792
17761793<div algorithm="invoke a layout callback">
@@ -1873,6 +1890,9 @@ following steps:
18731890The section specifies algorithms common to the [=determine the intrinsic sizes=] and [=generate
18741891a fragment=] algorithms.
18751892
1893+ Note: [=Get a document layout definition=] returns a [=document layout definition=] from the
1894+ owning [=document=] .
1895+
18761896<div algorithm="get a document layout definition">
18771897When the user agent wants to <dfn>get a document layout definition</dfn> given |name|, it
18781898<em> must</em> run the following steps:
@@ -1886,6 +1906,10 @@ When the user agent wants to <dfn>get a document layout definition</dfn> given |
18861906 3. Return the result of <a for=map>get</a> |documentLayoutDefinitionMap|[|name|] .
18871907</div>
18881908
1909+ Note: [=Get a layout definition=] returns a [=layout definition=] for a given
1910+ {{LayoutWorkletGlobalScope}} , it the desired definition doesn't exist it will "invalidate" the
1911+ [=document layout definition=] , (so that the layout can't be used again), and return failure.
1912+
18891913<div algorithm="get a layout definition">
18901914When the user agent wants to <dfn>get a layout definition</dfn> given |name|, and
18911915|workletGlobalScope|, it <em> must</em> run the following steps:
@@ -1909,6 +1933,10 @@ When the user agent wants to <dfn>get a layout definition</dfn> given |name|, an
19091933 3. Return the result of [=get=] |layoutDefinitionMap|[|name|] .
19101934</div>
19111935
1936+ Note: [=Get a layout class instance=] returns an instance of the web developer provided class.
1937+ (Registered in {{registerLayout()}} ). If one isn't present yet, it will create a new one. This
1938+ algorithm may fail, as the constructor may throw an exception.
1939+
19121940<div algorithm="get a layout class instance">
19131941When the user agent wants to <dfn>get a layout class instance</dfn> given |box|, |definition|, and
19141942|workletGlobalScope|, it <em> must</em> run the following steps:
@@ -1949,6 +1977,14 @@ When the user agent wants to <dfn>get a style map</dfn> given |box|, and |inputP
19491977[=Run a work queue=] is designed to allow user agents to work in both a single threaded, and
19501978multi-threaded environment.
19511979
1980+ Note: [=Run a work queue=] processes [=layout api work task=] s enqueued with
1981+ {{LayoutChild/intrinsicSizes()}} and {{LayoutChild/layoutNextFragment()}} . It will continue
1982+ processing tasks until the promise from the web developers layout or intrinsicSizes method is
1983+ resolved, or the queue is empty after running the microtask queue.
1984+
1985+ The result of running the queue will either be the result of the layout or intrinsicSizes
1986+ method, or failure.
1987+
19521988<div algorithm="run a work queue">
19531989When the user agent wants to <dfn>run a work queue</dfn> given |promise|, and |workQueue|, it
19541990<em> must</em> run the following steps:
@@ -2018,6 +2054,8 @@ When the user agent wants to <dfn>run a work queue</dfn> given |promise|, and |w
20182054
20192055 2. Wait (optionally [=in parallel=] ) for all of the above tasks to complete.
20202056
2057+ Note: If the tasks were perform synchronously, then this step is a no-op.
2058+
20212059 3. [=list/Empty=] |workQueue|.
20222060
20232061 4. [=Perform a microtask checkpoint=] .
0 commit comments