forked from mirrors/gecko-dev
Automatic update from web-platform-tests[css-layout-api] Allow passing of serialized data between parent<->child.
This allow arbitary parent<->child communation during layout. A parent
can send data to a child via:
// parent
const fragment = yield child.layoutNextFragment({data});
// child
*layout(children, edges, constraints, style) {
const data = constraints.data; // receive data.
}
And child to parent via:
// child
*layout() {
return {data};
}
// parent
const fragment = yield child.layoutNextFragment();
const data = fragment.data; // receive data.
As the parent and child layouts may be invoked in different worklet
global scopes, and don't allow data shared, the serialization of data
uses "kForStorage" which means that SharedArrayBuffers aren't allowed
in the serialization.
Serialization also occurs so that we are able to cache results.
Bug: 726125
Change-Id: Ib7e81b5778cef3af2c2f8a1ccef749f1d2ba4dfa
Reviewed-on: https://chromium-review.googlesource.com/1072150
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563235}
--
wpt-commits: 8c8238ca96f913c1b90f838def7f9cf0253c0113
wpt-pr: 11166
44 lines
1.2 KiB
HTML
44 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<html class=reftest-wait>
|
|
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#dom-layoutfragment-data">
|
|
<link rel="match" href="green-square-ref.html">
|
|
<meta name="assert" content="This test checks that passing something that can't be serialized to the parent triggers a fallback to block layout." />
|
|
<style>
|
|
.test {
|
|
background: red;
|
|
width: 100px;
|
|
}
|
|
|
|
.child {
|
|
height: 100px;
|
|
}
|
|
|
|
@supports (display: layout(fallback-fn)) {
|
|
.test {
|
|
display: layout(fallback-fn);
|
|
background: green;
|
|
}
|
|
}
|
|
</style>
|
|
<script src="/common/reftest-wait.js"></script>
|
|
<script src="/common/worklet-reftest.js"></script>
|
|
|
|
<div class="test">
|
|
<div class="child"></div>
|
|
</div>
|
|
|
|
<script id="code" type="text/worklet">
|
|
registerLayout('fallback-fn', class {
|
|
*intrinsicSizes() {}
|
|
*layout() {}
|
|
*layout(children, edges, constraints, styleMap) {
|
|
const childFragments = yield children.map(child => child.layoutNextFragment());
|
|
return {autoBlockSize: 0, childFragments, data: {fn: function() {}}};
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<script>
|
|
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
|
|
</script>
|
|
</html>
|