Re: [w3ctag/design-reviews] CSS Layout API (#224)

Issue brought up in the CSSWG meeting:

Using a generator here as a poor-man's async is bad. It's not *actually* an iterator; while `layout()` can be called multiple times, that's not done via the iterator-ness. Instead, the iterator is used solely to allow the engine to pause and do the children's layout asynchronously - in `childFragment = yield child.layoutNextFragment(childConstraints);`, the `lNF()` call doesn't return a fragment, it creates a `LayoutFragmentRequest`, which is yielded out to the engine, and then the completed fragment is pushed back into the function as the return value of the `yield` expression.

Semantically, this should be an async function, with `lNF()` returning a promise for a completed fragment, and `await` used to pause the function and pull out the completed fragment when it fulfills.  Using iterators to achieve this semantic is how some userland libraries created async functions in the past, but it was always a somewhat-confusing hack; we shouldn't reproduce this hack in browser-provided APIs when we have the appropriate primitive available.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/224#issuecomment-379734584

Received on Monday, 9 April 2018 12:45:16 UTC