@@ -271,6 +271,9 @@ function). It consists of:
271
271
Registering A Layout {#registering-layout}
272
272
------------------------------------------
273
273
274
+ The section describes how a web developer uses {{registerLayout(name, layoutCtor)}} to register a
275
+ layout.
276
+
274
277
<pre class='idl'>
275
278
[Exposed=LayoutWorklet]
276
279
dictionary LayoutOptions {
@@ -280,14 +283,14 @@ dictionary LayoutOptions {
280
283
281
284
[Exposed=LayoutWorklet]
282
285
enum ChildDisplayType {
283
- "block",
286
+ "block", // default - "blockifies" the child boxes.
284
287
"normal",
285
288
};
286
289
287
290
[Exposed=LayoutWorklet]
288
291
enum LayoutSizingMode {
289
- "block-like",
290
- "manual",
292
+ "block-like", // default - Sizing behaves like block containers.
293
+ "manual", // Sizing is specified by the web developer.
291
294
};
292
295
</pre>
293
296
@@ -459,7 +462,7 @@ A <dfn>child layout</dfn> is the layout algorithm for a {{LayoutChild}} of the [
459
462
Layout API {#layout-api}
460
463
========================
461
464
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 .
463
466
464
467
Layout Children {#layout-children}
465
468
----------------------------------
@@ -586,6 +589,9 @@ user agent must perform the following steps:
586
589
1. Return |this|' {{StylePropertyMapReadOnly}} contained in the {{[[styleMap]]}} internal slot.
587
590
</div>
588
591
592
+ Note: The {{intrinsicSizes()}} method allows the web developer to query the intrinsic sizes of the
593
+ {{LayoutChild}} .
594
+
589
595
<div algorithm>
590
596
When the <dfn method for=LayoutChild>intrinsicSizes()</dfn> method is called on a {{LayoutChild}}
591
597
|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
613
619
6. Return |p|.
614
620
</div>
615
621
622
+ Note: The {{layoutNextFragment()}} method allows the web developer to produce a {{LayoutFragment}}
623
+ for a given {{LayoutChild}} (the result of performing layout).
624
+
616
625
<div algorithm>
617
626
When the <dfn method for=LayoutChild>layoutNextFragment(|constraints|, |breakToken|)</dfn> method is
618
627
called 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
658
667
Each [=box=] has a <dfn attribute for=box>\[[layoutChildMap]]</dfn> internal slot, which is a
659
668
[=map=] of {{LayoutWorkletGlobalScope}} s to {{LayoutChild}} ren.
660
669
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
+
661
673
<div algorithm="get a layout child">
662
674
When the user agent wants to <dfn>get a layout child</dfn> given |workletGlobalScope|, |name|,
663
675
|box|, and |uniqueId|, it <em> must</em> run the following steps:
@@ -729,6 +741,9 @@ style=] algorithm.
729
741
Layout Fragments {#layout-fragments}
730
742
------------------------------------
731
743
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
+
732
747
<pre class='idl'>
733
748
[Exposed=LayoutWorklet]
734
749
interface LayoutFragment {
@@ -751,9 +766,6 @@ The {{LayoutFragment}} has internal slot(s):
751
766
752
767
<hr>
753
768
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
-
757
769
The {{LayoutFragment}} has {{LayoutFragment/inlineSize}} and {{LayoutFragment/blockSize}}
758
770
attributes, which are set by the respective child's layout algorithm. They represent the <b> border
759
771
box</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 {
890
902
Layout Constraints {#layout-constraints}
891
903
----------------------------------------
892
904
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
+
893
908
<pre class='idl'>
894
909
[Exposed=LayoutWorklet]
895
910
interface LayoutConstraints {
@@ -911,9 +926,6 @@ interface LayoutConstraints {
911
926
enum BlockFragmentationType { "none", "page", "column", "region" };
912
927
</pre>
913
928
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
-
917
929
The {{LayoutConstraints}} object has {{LayoutConstraints/availableInlineSize}} and
918
930
{{LayoutConstraints/availableBlockSize}} attributes. This represents the [=available space=] for the
919
931
[=current layout=] to respect.
@@ -1015,6 +1027,9 @@ and |internalLayoutConstraints|, it <em>must</em> run the following steps:
1015
1027
1016
1028
### Constraints for Layout Children ### {#layout-constraints-children}
1017
1029
1030
+ The {{LayoutConstraintsOptions}} dictionary represents the set of constraints which can be passed to
1031
+ a {{LayoutChild}} to produce a {{LayoutFragment}} .
1032
+
1018
1033
<pre class='idl'>
1019
1034
dictionary LayoutConstraintsOptions {
1020
1035
double availableInlineSize;
@@ -1033,9 +1048,6 @@ dictionary LayoutConstraintsOptions {
1033
1048
};
1034
1049
</pre>
1035
1050
1036
- The {{LayoutConstraintsOptions}} dictionary represents the set of constraints which can be passed to
1037
- a {{LayoutChild}} to produce a {{LayoutFragment}} .
1038
-
1039
1051
<div class="example">
1040
1052
The example below shows the basic usage of the {{LayoutConstraintsOptions}} dictionary.
1041
1053
@@ -1069,6 +1081,12 @@ Issue: Specify how to convert to internal representation of these values.
1069
1081
Breaking and Fragmentation {#breaking-and-fragmentation}
1070
1082
--------------------------------------------------------
1071
1083
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
+
1072
1090
<pre class="idl">
1073
1091
[Exposed=LayoutWorklet]
1074
1092
interface ChildBreakToken {
@@ -1097,19 +1115,16 @@ The {{ChildBreakToken}} has internal slot(s):
1097
1115
1098
1116
<hr>
1099
1117
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
-
1106
1118
A subsequent {{LayoutFragment}} is produced by using the previous {{LayoutFragment}} 's
1107
1119
{{LayoutFragment/breakToken}} . This tells the [=child layout=] to produce a {{LayoutFragment}}
1108
1120
starting at the point encoded in the {{ChildBreakToken}} .
1109
1121
1110
1122
Edges {#edges}
1111
1123
--------------
1112
1124
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
+
1113
1128
<pre class='idl'>
1114
1129
[Exposed=LayoutWorklet]
1115
1130
interface LayoutEdges {
@@ -1125,9 +1140,6 @@ interface LayoutEdges {
1125
1140
};
1126
1141
</pre>
1127
1142
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
-
1131
1143
Each of the accessors represents the width in CSS pixels of an edge in each of the [=abstract
1132
1144
dimensions=] ({{LayoutEdges/inlineStart}} , {{LayoutEdges/inlineEnd}} , {{LayoutEdges/blockStart}} ,
1133
1145
{{LayoutEdges/blockEnd}} ).
@@ -1450,6 +1462,9 @@ run the following steps:
1450
1462
Performing Layout {#performing-layout}
1451
1463
--------------------------------------
1452
1464
1465
+ The section describes how a user agent calls the web developer defined layout to produces intrinsic
1466
+ sizes, and fragments.
1467
+
1453
1468
<pre class='idl'>
1454
1469
// This is the final return value from the author defined layout() method.
1455
1470
dictionary FragmentResultOptions {
@@ -1654,16 +1669,16 @@ context=] for a given |box|, |childBoxes| it <em>must</em> run the following ste
1654
1669
The user agent <em> may</em> also [=create a WorkletGlobalScope=] at this time, given the
1655
1670
layout {{Worklet}} .
1656
1671
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
1658
1673
|workletGlobalScope| optionally [=in parallel=] .
1659
1674
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
1661
1676
parallel=] , it should select a layout worklet global scope which can be used on that
1662
1677
thread.
1663
1678
</div>
1664
1679
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|,
1667
1682
|childBoxes|, and |workletGlobalScope|, it <em> must</em> run the following steps:
1668
1683
1669
1684
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
1709
1724
If an exception is [=thrown=] the let |box| fallback to the [=flow layout=] and abort all
1710
1725
these steps.
1711
1726
1727
+ Issue: Handle non-promise case.
1728
+
1712
1729
12. Let |intrinsicSizesValue| be the result of [=run a work queue=] given |promise|, and
1713
1730
|context|'s [=work queue=] .
1714
1731
@@ -1769,8 +1786,8 @@ it <em>must</em> run the following steps:
1769
1786
|internalLayoutConstraints|, |internalBreakToken|, and |workletGlobalScope| optionally [=in
1770
1787
parallel=] .
1771
1788
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.
1774
1791
</div>
1775
1792
1776
1793
<div algorithm="invoke a layout callback">
@@ -1873,6 +1890,9 @@ following steps:
1873
1890
The section specifies algorithms common to the [=determine the intrinsic sizes=] and [=generate
1874
1891
a fragment=] algorithms.
1875
1892
1893
+ Note: [=Get a document layout definition=] returns a [=document layout definition=] from the
1894
+ owning [=document=] .
1895
+
1876
1896
<div algorithm="get a document layout definition">
1877
1897
When the user agent wants to <dfn>get a document layout definition</dfn> given |name|, it
1878
1898
<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 |
1886
1906
3. Return the result of <a for=map>get</a> |documentLayoutDefinitionMap|[|name|] .
1887
1907
</div>
1888
1908
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
+
1889
1913
<div algorithm="get a layout definition">
1890
1914
When the user agent wants to <dfn>get a layout definition</dfn> given |name|, and
1891
1915
|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
1909
1933
3. Return the result of [=get=] |layoutDefinitionMap|[|name|] .
1910
1934
</div>
1911
1935
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
+
1912
1940
<div algorithm="get a layout class instance">
1913
1941
When the user agent wants to <dfn>get a layout class instance</dfn> given |box|, |definition|, and
1914
1942
|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
1949
1977
[=Run a work queue=] is designed to allow user agents to work in both a single threaded, and
1950
1978
multi-threaded environment.
1951
1979
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
+
1952
1988
<div algorithm="run a work queue">
1953
1989
When the user agent wants to <dfn>run a work queue</dfn> given |promise|, and |workQueue|, it
1954
1990
<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
2018
2054
2019
2055
2. Wait (optionally [=in parallel=] ) for all of the above tasks to complete.
2020
2056
2057
+ Note: If the tasks were perform synchronously, then this step is a no-op.
2058
+
2021
2059
3. [=list/Empty=] |workQueue|.
2022
2060
2023
2061
4. [=Perform a microtask checkpoint=] .
0 commit comments