summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-contain/container-queries/custom-layout-container-001.https.html
blob: 8f301e8ebf626035f967d01e585e0832eefe72de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!doctype html>
<html class=reftest-wait>
<title>CSS Container Queries Test: Size queries on CSS Layout API containers</title>
<link rel="help" href="https://drafts.csswg.org/css-contain-3/#size-container">
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/">
<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<style>
  #test1 {
    width: 400px;
    height: 100px;
  }
  #outer {
    display: inline; /* Shouldn't pass without layout api support */
    display: layout(half);
    height: 100px;
    container-type: inline-size;
  }
  @container (width = 400px) {
    #inner {
      display: inline; /* Shouldn't pass without layout api support */
      display: layout(half);
      height: 100px;
      container-type: inline-size;
    }
  }
  @container (width = 200px) {
    #green {
      background-color: green;
      height: 100px;
    }
  }
</style>
<p>Test passes if there is a filled green square.</p>
<div id="test1">
  <div id="outer">
    <div id="inner">
      <div id="green"></div>
    </div>
  </div>
</div>

<script id="code" type="text/worklet">
  registerLayout("half", class {
    async intrinsicSizes() {}
    async layout(children, edges, constraints, styleMap) {
      const childInlineSize = constraints.fixedInlineSize / 2;
      const childFragments = await Promise.all(children.map((child) => {
        return child.layoutNextFragment({fixedInlineSize: childInlineSize});
      }));

      for (let childFragment of childFragments) {
        childFragment.inlineOffset = 0;
        childFragment.blockOffset = 0;
      }
      const autoBlockSize = 100;
      return {autoBlockSize, childFragments};
    }
  });
</script>

<script>
  importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById("code").textContent);
</script>
</html>