Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit dd38623

Browse files
bfgeekchromium-wpt-export-bot
authored andcommitted
[css-layout-api] Convert to promise based API.
As above! This switches the API from being generator based, to promise based. This introduces the specification's work queue, which is run until exhaustion. After the work queue has been run the given promise should be resolved, (if not we fallback to block layout). This also introduces the CustomLayoutScope, and CustomLayoutToken which are used together. The CustomLayoutToken is a heap allocated class held onto objects which should only be used within a certain layout pass. E.g. you cannot hold onto a fragment from a previous layout pass, and use it within the current layout pass. This is managed by a stack allocated CustomLayoutScope, which once destroyed marks the CustomLayoutToken as "detached". Any object which has a "detached" token shouldn't be used. The CustomLayoutScope is also used to hold onto the work queue. Bug: 726125 Change-Id: Ic435c8c50fe3d3779f068b41eada815253d0b78b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1716035 Commit-Queue: Ian Kilpatrick <[email protected]> Reviewed-by: Koji Ishii <[email protected]> Cr-Commit-Position: refs/heads/master@{#684927}
1 parent 1d05642 commit dd38623

29 files changed

+217
-177
lines changed

css/css-layout-api/auto-block-size-absolute.https.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060

6161
<script id="code" type="text/worklet">
6262
registerLayout('block-size-100', class {
63-
*intrinsicSizes() {}
64-
*layout() {
63+
async intrinsicSizes() {}
64+
async layout() {
6565
return {autoBlockSize: 100};
6666
}
6767
});

css/css-layout-api/auto-block-size-flex.https.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242

4343
<script id="code" type="text/worklet">
4444
registerLayout('block-size-100', class {
45-
*intrinsicSizes() {}
46-
*layout() {
45+
async intrinsicSizes() {}
46+
async layout() {
4747
return {autoBlockSize: 100};
4848
}
4949
});
5050
registerLayout('block-size-50', class {
51-
*intrinsicSizes() {}
52-
*layout() {
51+
async intrinsicSizes() {}
52+
async layout() {
5353
return {autoBlockSize: 50};
5454
}
5555
});

css/css-layout-api/auto-block-size-floats.https.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444

4545
<script id="code" type="text/worklet">
4646
registerLayout('block-size-100', class {
47-
*intrinsicSizes() {}
48-
*layout() {
47+
async intrinsicSizes() {}
48+
async layout() {
4949
return {autoBlockSize: 100};
5050
}
5151
});

css/css-layout-api/auto-block-size-inflow.https.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050

5151
<script id="code" type="text/worklet">
5252
registerLayout('block-size-100', class {
53-
*intrinsicSizes() {}
54-
*layout() {
53+
async intrinsicSizes() {}
54+
async layout() {
5555
return {autoBlockSize: 100};
5656
}
5757
});

css/css-layout-api/auto-block-size-negative.https.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
<script id="code" type="text/worklet">
4040
registerLayout('block-size-negative', class {
41-
*intrinsicSizes() {}
42-
*layout() {
41+
async intrinsicSizes() {}
42+
async layout() {
4343
return {autoBlockSize: -100};
4444
}
4545
});

css/css-layout-api/box-tree-registered.https.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555

5656
<script id="code" type="text/worklet">
5757
registerLayout('registered', class {
58-
*intrinsicSizes() {}
59-
*layout() { throw Error(); }
58+
async intrinsicSizes() {}
59+
async layout() { throw Error(); }
6060
});
6161
</script>
6262

css/css-layout-api/constraints-data-function-failure.https.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@
2929

3030
<script id="code" type="text/worklet">
3131
registerLayout('parent', class {
32-
*intrinsicSizes() {}
33-
*layout() {}
34-
*layout([child], edges, constraints, styleMap) {
32+
async intrinsicSizes() {}
33+
async layout([child], edges, constraints, styleMap) {
3534
let childFragment = null;
3635

3736
try {
38-
childFragment = yield child.layoutNextFragment({
37+
childFragment = await child.layoutNextFragment({
3938
data: { fn: function() {} }
4039
});
4140
} catch(e) {
4241
// Success! The structured cloning algorithm should have thrown an error.
43-
childFragment = yield child.layoutNextFragment({});
42+
childFragment = await child.layoutNextFragment({});
4443
return {autoBlockSize: 100, childFragments: [childFragment]};
4544
}
4645

@@ -49,9 +48,8 @@
4948
});
5049

5150
registerLayout('child', class {
52-
*intrinsicSizes() {}
53-
*layout() {}
54-
*layout() {
51+
async intrinsicSizes() {}
52+
async layout() {
5553
return {autoBlockSize: 0};
5654
}
5755
});

css/css-layout-api/constraints-data-sab-failure.https.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@
2929

3030
<script id="code" type="text/worklet">
3131
registerLayout('parent', class {
32-
*intrinsicSizes() {}
33-
*layout() {}
34-
*layout([child], edges, constraints, styleMap) {
32+
async intrinsicSizes() {}
33+
async layout([child], edges, constraints, styleMap) {
3534
let childFragment = null;
3635

3736
try {
38-
childFragment = yield child.layoutNextFragment({
37+
childFragment = await child.layoutNextFragment({
3938
data: { sab: new SharedArrayBuffer(4) }
4039
});
4140
} catch(e) {
4241
// Success! The structured cloning algorithm should have thrown an error.
43-
childFragment = yield child.layoutNextFragment({});
42+
childFragment = await child.layoutNextFragment({});
4443
return {autoBlockSize: 100, childFragments: [childFragment]};
4544
}
4645

@@ -49,9 +48,8 @@
4948
});
5049

5150
registerLayout('child', class {
52-
*intrinsicSizes() {}
53-
*layout() {}
54-
*layout() {
51+
async intrinsicSizes() {}
52+
async layout() {
5553
return {autoBlockSize: 0};
5654
}
5755
});

css/css-layout-api/constraints-data.https.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@
3535
};
3636

3737
registerLayout('parent', class {
38-
*intrinsicSizes() {}
39-
*layout() {}
40-
*layout([child], edges, constraints, styleMap) {
38+
async intrinsicSizes() {}
39+
async layout([child], edges, constraints, styleMap) {
4140

42-
const childFragment = yield child.layoutNextFragment({data: DATA});
41+
const childFragment = await child.layoutNextFragment({data: DATA});
4342

4443
// If the child's block-size is 100 the structured cloning worked.
4544
if (childFragment.blockSize === 100) {
@@ -51,9 +50,8 @@
5150
});
5251

5352
registerLayout('child', class {
54-
*intrinsicSizes() {}
55-
*layout() {}
56-
*layout(children, edges, constraints, styleMap) {
53+
async intrinsicSizes() {}
54+
async layout(children, edges, constraints, styleMap) {
5755
// Use JSON.stringify to make sure the structured cloning worked.
5856
if (constraints.data !== DATA &&
5957
JSON.stringify(constraints.data) === JSON.stringify(DATA)) {

css/css-layout-api/fallback-constructor-error.https.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
<script id="code" type="text/worklet">
4141
registerLayout('throwing-ctor', class {
4242
constructor() { throw Error('fail!'); }
43-
*intrinsicSizes() {}
44-
*layout() {}
43+
async intrinsicSizes() {}
44+
async layout() {}
4545
});
4646
</script>
4747

0 commit comments

Comments
 (0)