Skip to content

Commit 22a4680

Browse files
committed
[css-layout-api] Update algorithm to get the cache version of a LayoutChild.
1 parent 6551dbc commit 22a4680

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

css-layout-api/Overview.bs

+30-29
Original file line numberDiff line numberDiff line change
@@ -1355,9 +1355,9 @@ is empty; it is populated when {{registerLayout(name, layoutCtor)}} is called.
13551355
The {{LayoutWorkletGlobalScope}} has a <a>map</a> of <dfn>layout definitions</dfn>. Initially this
13561356
map is empty; it is populated when {{registerLayout(name, layoutCtor)}} is called.
13571357

1358-
The {{LayoutWorkletGlobalScope}} has a <a>map</a> of <dfn>layout class instances</dfn>. Initially
1359-
this map is empty; it is populated when the user agent calls either <a>determine the intrinsic
1360-
sizes</a> or <a>generate a fragment</a> for a <a>box</a>.
1358+
Each <a>box</a> representing a <a>layout API container</a> has a <a>map</a> of <dfn>layout class
1359+
instances</dfn>. Initially this map is empty; it is populated when the user agent calls either
1360+
<a>determine the intrinsic sizes</a> or <a>generate a fragment</a> for a <a>box</a>.
13611361

13621362
<div algorithm>
13631363
When the <dfn method for=LayoutWorkletGlobalScope>registerLayout(|name|, |layoutCtor|)</dfn> method
@@ -1692,30 +1692,31 @@ When the user agent wants to <dfn>invoke a intrinsic sizes callback</dfn> given
16921692
If <a>get a layout definition</a> returned failure, let the |box| fallback to the <a>flow
16931693
layout</a> and abort all these steps.
16941694

1695-
2. Let |layoutInstance| be the result of <a>get a layout class instance</a> given |name|, |box|,
1695+
2. Let |layoutInstance| be the result of <a>get a layout class instance</a> given |box|,
16961696
|definition|, |workletGlobalScope|.
16971697

16981698
If <a>get a layout class instance</a> returned failure, let the |box| fallback to the
16991699
<a>flow layout</a> and abort all these steps.
17001700

17011701
3. Let |inputProperties| be |definition|'s <a for="layout definition">input properties</a>.
17021702

1703-
4. Let |childInputProperties| be |definition|'s <a for="layout definition">child input
1704-
properties</a>.
1703+
4. Let |children| be a new <a>list</a>.
1704+
1705+
5. <a for=list>For each</a> |childBox| in |childBoxes| perform the following substeps:
17051706

1706-
5. Let |children| be a new <a>list</a> populated with new {{LayoutChild}} objects which
1707-
represent |childBoxes|.
1707+
1. Let |layoutChild| be the result of <a>get a layout child</a> given |workletGlobalScope|,
1708+
|name|, and |childBox|.
17081709

1709-
The {{LayoutChild/styleMap}} on each {{LayoutChild}} should be a new
1710-
{{StylePropertyMapReadOnly}} populated with <em>only</em> the <a>computed values</a> for
1711-
properties listed in |childInputProperties|.
1710+
2. <a for=list>Append</a> |layoutChild| to |children|.
17121711

17131712
6. Let |edges| be a new {{LayoutEdgeSizes}} populated with the <a>computed value</a> for all the
17141713
<a>box model edges</a> for |box|.
17151714

17161715
7. Let |styleMap| be a new {{StylePropertyMapReadOnly}} populated with <em>only</em> the
17171716
<a>computed values</a> for properties listed in |inputProperties| for |box|.
17181717

1718+
Issue: We may want to store |styleMap| on |box| instead, similar to |layoutInstance|.
1719+
17191720
8. At this stage the user agent may re-use the <a>intrinsic sizes</a> from a previous invocation
17201721
if |children|, |styleMap| are equivalent to that previous invocation. If so let the
17211722
intrinsic sizes the cached intrinsic sizes and abort all these steps.
@@ -1813,23 +1814,22 @@ following steps:
18131814
If <a>get a layout definition</a> returned failure, let the |box| fallback to the <a>flow
18141815
layout</a> and abort all these steps.
18151816

1816-
2. Let |layoutInstance| be the result of <a>get a layout class instance</a> given |name|, |box|,
1817+
2. Let |layoutInstance| be the result of <a>get a layout class instance</a> given |box|,
18171818
|definition|, |workletGlobalScope|.
18181819

18191820
If <a>get a layout class instance</a> returned failure, let the |box| fallback to the
18201821
<a>flow layout</a> and abort all these steps.
18211822

18221823
3. Let |inputProperties| be |definition|'s <a for="layout definition">input properties</a>.
18231824

1824-
4. Let |childInputProperties| be |definition|'s <a for="layout definition">child input
1825-
properties</a>.
1825+
4. Let |children| be a new <a>list</a>.
18261826

1827-
5. Let |children| be a new <a>list</a> populated with new {{LayoutChild}} objects which
1828-
represent |childBoxes|.
1827+
5. <a for=list>For each</a> |childBox| in |childBoxes| perform the following substeps:
18291828

1830-
The {{LayoutChild/styleMap}} on each {{LayoutChild}} should be a new
1831-
{{StylePropertyMapReadOnly}} populated with <em>only</em> the <a>computed values</a> for
1832-
properties listed in |childInputProperties|.
1829+
1. Let |layoutChild| be the result of <a>get a layout child</a> given |workletGlobalScope|,
1830+
|name|, and |childBox|.
1831+
1832+
2. <a for=list>Append</a> |layoutChild| to |children|.
18331833

18341834
6. Let |edges| be a new {{LayoutEdgeSizes}} populated with the <a>computed value</a> for all the
18351835
<a>box model edges</a> for |box|.
@@ -1840,6 +1840,8 @@ following steps:
18401840
8. Let |styleMap| be a new {{StylePropertyMapReadOnly}} populated with <em>only</em> the
18411841
<a>computed values</a> for properties listed in |inputProperties| for |box|.
18421842

1843+
Issue: We may want to store |styleMap| on |box| instead, similar to |layoutInstance|.
1844+
18431845
9. Let |breakToken| be a new {{BreakToken}} populated with the appropriate information from
18441846
|internalBreakToken|.
18451847

@@ -1930,18 +1932,17 @@ When the user agent wants to <dfn>get a layout definition</dfn> given |name|, an
19301932
</div>
19311933

19321934
<div algorithm="get a layout class instance">
1933-
When the user agent wants to <dfn>get a layout class instance</dfn> given |name|, |box|,
1934-
|definition|, and |workletGlobalScope|, it <em>must</em> run the following steps:
1935-
1936-
1. Let |layoutClassInstanceMap| be |workletGlobalScope|'s <a>layout class instances</a> map.
1935+
When the user agent wants to <dfn>get a layout class instance</dfn> given |box|, |definition|, and
1936+
|workletGlobalScope|, it <em>must</em> run the following steps:
19371937

1938-
2. Let |key| be a stable <a for=map>key</a> which is unique to |box| and |name|.
1938+
1. Let |layoutClassInstanceMap| be |box|'s <a>layout class instances</a> map.
19391939

1940-
3. Let |layoutInstance| be the result of <a>get</a> |layoutClassInstanceMap|[|key|]. If
1941-
|layoutInstance| is null, run the following steps:
1940+
2. Let |layoutInstance| be the result of <a>get</a>
1941+
|layoutClassInstanceMap|[|workletGlobalScope|]. If |layoutInstance| is null, run the
1942+
following steps:
19421943

1943-
1. If the <a>constructor valid flag</a> on |definition| is false, let |box| fallback to the
1944-
<a>flow layout</a> and a abort all these steps.
1944+
1. If the <a>constructor valid flag</a> on |definition| is false, then return failure and
1945+
abort all these steps.
19451946

19461947
2. Let |layoutCtor| be the <a>class constructor</a> on |definition|.
19471948

@@ -1950,7 +1951,7 @@ When the user agent wants to <dfn>get a layout class instance</dfn> given |name|
19501951
If <a>construct</a> throws an exception, set the |definition|'s <a>constructor valid
19511952
flag</a> to false, then return failure and abort all these steps.
19521953

1953-
4. <a for=map>Set</a> |layoutClassInstanceMap|[|key|] to |layoutInstance|.
1954+
4. <a for=map>Set</a> |layoutClassInstanceMap|[|workletGlobalScope|] to |layoutInstance|.
19541955

19551956
4. Return |layoutInstance|.
19561957
</div>

0 commit comments

Comments
 (0)