summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-layout-api/child-constraints/available-size-for-percentages-vrl-htb.https.html
blob: ce8ff95dd0d15d9d05c8bf022e3ccb5e5eaa2deb (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
<!DOCTYPE html>
<html class=reftest-wait>
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#dom-layoutconstraintsoptions-availableinlinesize">
<link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#dom-layoutconstraintsoptions-availableblocksize">
<link rel="match" href="../green-square-ref.html">
<meta name="assert" content="This test checks that resolving percentages against the available size works as expected." />

<style>
.test {
  writing-mode: vertical-rl;
  background: red;
  height: 100px;
}

.child {
  writing-mode: horizontal-tb;
  visibility: hidden;

  --available-inline-size: 20;
  --available-block-size: 50;

  --inline-size-expected: 10px;
  --block-size-expected: 10px;
}

@supports (display: layout(test)) {
  .test {
    background: green;
    display: layout(test);
  }
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>

<div class="test">
  <!-- A fixed width/height shouldn't be affected by the available size. -->
  <div class="child" style="width: 10px; height: 10px;"></div>

  <!-- A percentage width/height should resolve itself against the available size. -->
  <div class="child" style="width: 20%; height: 50%;"></div>

  <!-- A percentage max-width/max-height should resolve itself against the available size. -->
  <div class="child" style="width: 15px; max-width: 20%; height: 15px; max-height: 50%;"></div>

  <!-- A percentage min-width/min-height should resolve itself against the available size. -->
  <div class="child" style="width: 5px; min-width: 20%; height: 5px; min-height: 50%;"></div>

  <!-- A replaced percentage width/height should resolve itself against the available size. -->
  <img class="child" style="width: 20%; height: 50%;" />

  <!-- A replaced percentage max-width/max-height should resolve itself against the available size. -->
  <img class="child" style="width: 15px; max-width: 20%; height: 15px; max-height: 50%;" />

  <!-- A replaced percentage min-width/min-height should resolve itself against the available size. -->
  <img class="child" style="width: 5px; min-width: 20%; height: 5px; min-height: 50%;" />
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, {url: 'support/layout-child-sizes-worklet.js'});
</script>