Skip to content

Commit fdf018c

Browse files
committed
[css-layout-api] Fix the --run a generator-- algorithm.
1 parent 22a4680 commit fdf018c

File tree

1 file changed

+76
-36
lines changed

1 file changed

+76
-36
lines changed

css-layout-api/Overview.bs

+76-36
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ urlPrefix: https://heycam.github.io/webidl/; type: dfn;
6464
urlPrefix: https://tc39.github.io/ecma262/#sec-; type: dfn;
6565
text: constructor
6666
text: Construct
67+
text: GetMethod
6768
text: IsArray
6869
text: IsCallable
6970
text: IsConstructor
@@ -1530,6 +1531,9 @@ interface IntrinsicSizesRequest {
15301531
[Exposed=LayoutWorklet]
15311532
interface LayoutFragmentRequest {
15321533
};
1534+
1535+
typedef (IntrinsicSizesRequest or LayoutFragmentRequest)
1536+
LayoutFragmentRequestOrIntrinsicSizesRequest;
15331537
</pre>
15341538

15351539
The {{IntrinsicSizesRequest}} has internal slot(s):
@@ -1960,57 +1964,61 @@ When the user agent wants to <dfn>get a layout class instance</dfn> given |box|,
19601964
When the user agent wants to <dfn>run a generator</dfn> given |generator|, and |generatorType|, it
19611965
<em>must</em> run the following steps:
19621966

1963-
1. Let |nextResult| be the result of calling <a>Invoke</a>(<code>next</code>, |generator|).
1967+
1. Let |done| be a <a>boolean</a> initialized to <code>false</code>.
1968+
1969+
2. Let |nextValue| be undefined.
1970+
1971+
3. Perform the following substeps until |done| is <code>true</code>:
1972+
1973+
1. Let |nextFunction| be the result of <a>Get</a>(|generator|, <code>"next"</code>).
1974+
1975+
2. If the result of <a>IsCallable</a>(|nextFunction|) is false, <a>throw</a> a
1976+
<a>TypeError</a> and abort all these steps.
19641977

1965-
If an exception is <a>thrown</a> return failure, and abort all these steps.
1978+
3. Let |nextResult| be the result of calling <a>Invoke</a>(|nextFunction|, |generator|,
1979+
«|nextValue|»).
19661980

1967-
2. Perform the following substeps until the result of <a>Get</a>(|nextResult|,
1968-
<code>"done"</code>) is <code>true</code>.
1981+
If an exception is <a>thrown</a> return failure, and abort all these steps.
19691982

1970-
1. Let |requests| be the result of <a>Get</a>(|nextResult|, <code>"value"</code>).
1983+
4. If the result of <a>Type</a>(|nextResult|) is not Object, <a>throw</a> a <a>TypeError</a>
1984+
and abort all these steps.
19711985

1972-
2. Let |results| be an <a for=list>empty</a> <a>list</a>.
1986+
5. Let |requestOrRequests| be the result of <a>Get</a>(nextResult|, <code>"value"</code>).
19731987

1974-
3. <a for=list>For each</a> |request| in |requests| perform the following substeps:
1988+
6. Let |done| be the result of <a>Get</a>(|nextResult|, <code>"done"</code>).
19751989

1976-
1. Let |result| be null.
1990+
7. If the result of <a>GetMethod</a>(|requestOrRequests|, <code>@@iterable</code>) exists
1991+
then:
19771992

1978-
2. If |request| is a {{IntrinsicSizesRequest}} then:
1993+
1. Set |results| to be a new <a for=list>empty</a> <a>list</a>.
19791994

1980-
1. Let |layoutChild| be the result of looking up the internal slot
1981-
<code>\[[layoutChild]]</code> on |request|.
1995+
2. Let |requests| be the result of <a>converting</a> |requestOrRequests| to a
1996+
<code>sequence&lt;LayoutFragmentRequestOrIntrinsicSizesRequest></code>.
19821997

1983-
2. Let |internalIntrinsicSizes| be the result of the user agent calculating the
1984-
<b>border box</b> min/max content contribution of |layoutChild|.
1998+
If an exception is <a>thrown</a>, rethrow the exception and abort all these steps.
19851999

1986-
3. Let |result| be the result of <a>create an intrinsic sizes object</a> given
1987-
|request|, and |internalIntrinsicSizes|.
2000+
3. <a for=list>For each</a> |request| in |requests| perform the following substeps:
19882001

1989-
3. If |request| is a {{LayoutFragmentRequest}} and |generatorType| is
1990-
<code>"layout"</code> then:
2002+
1. Let |result| be the result of <a>produce a generator result</a> given |request|,
2003+
|generator|, |generatorType|.
19912004

1992-
1. Let |layoutChild| be result of looking up the internal slot
1993-
<code>\[[layoutChild]]</code> on |request|.
2005+
2. <a for=list>Append</a> |result| to |results|.
19942006

1995-
2. Let |childLayoutConstraints| be the result of looking up the internal slot
1996-
<code>\[[childLayoutConstraints]]</code> on |request|.
2007+
4. Set |nextValue| to be |results|.
19972008

1998-
3. Let |childBreakToken| be the result of looking up the internal slot
1999-
<code>\[[childBreakToken]]</code> on |request|.
2009+
5. Continue.
20002010

2001-
4. Let |internalFragment| be the result of the user agent producing a
2002-
<a>fragment</a> based on |layoutChild|, |childLayoutConstraints|, and
2003-
|childBreakToken|.
2011+
8. Let |request| be the result of <a>converting</a> |requestOrRequests| to a
2012+
{{LayoutFragmentRequestOrIntrinsicSizesRequest}}.
20042013

2005-
5. Let |targetRealm| be |generator|'s <a>Realm</a>.
2014+
If an exception is <a>thrown</a>, rethrow the exception and abort all these steps.
20062015

2007-
6. Let |result| be the result of <a>create a layout fragment</a> given
2008-
|targetRealm|, |request|, and |internalFragment|.
2016+
9. Let |result| be the result of <a>produce a generator result</a> given |request|,
2017+
|generator|, |generatorType|.
20092018

2010-
4. If |result| is null (that is neither of the above branches was taken), return
2011-
failure, and abort all these steps.
2019+
10. Set |nextValue| to be |result|.
20122020

2013-
5. <a for=list>Append</a> |result| to |results|.
2021+
11. Continue.
20142022

20152023
The user agent may perform the above loop out of order, and <a>in parallel</a>. The ordering
20162024
for |requests| and |results| however <em>must</em> be consistent.
@@ -2021,10 +2029,42 @@ When the user agent wants to <dfn>run a generator</dfn> given |generator|, and |
20212029
thread tasks are complete before calling the generator again. It cannot return partial
20222030
results to the author.
20232031

2024-
4. Let |nextResult| be the result of calling <a>Invoke</a>(<code>next</code>,
2025-
|generator|, |results|).
2032+
3. Return the result of calling <a>Get</a>(|nextResult|, <code>"value"</code>).
2033+
</div>
20262034

2027-
If an exception is <a>thrown</a> then return failure, and abort all these steps.
2035+
<div algorithm="produce a generator result">
2036+
When the user agent wants to <dfn>produce a generator result</dfn> given |request|, |generator|, and
2037+
|generatorType|, it <em>must</em> run the following steps:
2038+
1. If |request| is a {{IntrinsicSizesRequest}} then:
20282039

2029-
3. Return the result of calling <a>Get</a>(|nextResult|, <code>"value"</code>).
2040+
1. Let |layoutChild| be the result of looking up the internal slot
2041+
{{IntrinsicSizesRequest/[[layoutChild]]}} on |request|.
2042+
2043+
2. Let |internalIntrinsicSizes| be the result of the user agent calculating the <b>border
2044+
box</b> min/max content contribution of |layoutChild|.
2045+
2046+
3. Return the result of <a>create an intrinsic sizes object</a> given |request|, and
2047+
|internalIntrinsicSizes|.
2048+
2049+
2. If |request| is a {{LayoutFragmentRequest}} and |generatorType| is <code>"layout"</code>
2050+
then:
2051+
2052+
1. Let |layoutChild| be result of looking up the internal slot
2053+
{{LayoutFragmentRequest/[[layoutChild]]}} on |request|.
2054+
2055+
2. Let |childLayoutConstraints| be the result of looking up the internal slot
2056+
{{LayoutFragmentRequest/[[layoutConstraints]]}} on |request|.
2057+
2058+
3. Let |childBreakToken| be the result of looking up the internal slot
2059+
{{LayoutFragmentRequest/[[breakToken]]}} on |request|.
2060+
2061+
4. Let |internalFragment| be the result of the user agent producing a <a>fragment</a> based
2062+
on |layoutChild|, |childLayoutConstraints|, and |childBreakToken|.
2063+
2064+
5. Let |targetRealm| be |generator|'s <a>Realm</a>.
2065+
2066+
6. Return the result of <a>create a layout fragment</a> given |targetRealm|, |request|, and
2067+
|internalFragment|.
2068+
2069+
3. Return failure (neither of the above branches was taken).
20302070
</div>

0 commit comments

Comments
 (0)