blob: fecd4328a5996b5cd6c30e186b0343043a3642b9 (
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
67
68
69
70
71
72
73
74
75
76
|
<!DOCTYPE html>
<title>Tests relayout after 'position-fallback-bounds' change</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#fallback-bounds">
<link rel="author" href="mailto:xiaochengh@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/test-common.js"></script>
<style>
.bounds {
position: absolute;
left: 100px;
width: 200px;
height: 200px;
background: gray;
opacity: 0.1;
}
#bounds1 {
top: 0;
anchor-name: --bounds1;
}
#bounds2 {
top: 300px;
anchor-name: --bounds2;
}
#anchor {
position: absolute;
width: 100px;
height: 100px;
background: orange;
left: 150px;
top: 200px;
anchor-name: --a;
}
#target {
position: fixed;
width: 100px;
height: 100px;
background: lime;
left: anchor(left);
bottom: anchor(top);
anchor-default: --a;
position-try-options: --bottom;
position-fallback-bounds: --bounds1;
}
@position-try --bottom {
bottom: auto;
top: anchor(bottom);
}
</style>
<div class="bounds" id="bounds1"></div>
<div class="bounds" id="bounds2"></div>
<div id="anchor"></div>
<div id="target"></div>
<script>
test(() => {
assert_fallback_position(target, anchor, 'top');
}, 'Initial layout');
test(() => {
target.style = 'position-fallback-bounds: --bounds2';
assert_fallback_position(target, anchor, 'bottom');
}, 'Layout is updated after position-fallback-bounds property changes');
test(() => {
bounds2.style = 'top: 0; height: 500px';
assert_fallback_position(target, anchor, 'top');
}, 'Layout is updated after additional fallback-bounds rect changes');
</script>
|