File: anchor-in-scroller-with-left-side-scrollbar.html

package info (click to toggle)
firefox 145.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,653,528 kB
  • sloc: cpp: 7,594,999; javascript: 6,459,658; ansic: 3,752,909; python: 1,403,455; xml: 629,809; asm: 438,679; java: 186,421; sh: 67,287; makefile: 19,169; objc: 13,086; perl: 12,982; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (128 lines) | stat: -rw-r--r-- 3,874 bytes parent folder | download | duplicates (2)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>

<title>Tests anchor positioning in a scroller with left-hand-side scrollbar</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/">
<link rel="author" href="mailto:kiet.ho@apple.com">

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<style>
    .containing-block {
        position: relative;
        height: 100px;
        width: 100px;

        overflow: scroll;
    }

    #containing-block-vertical-rl {
        writing-mode: vertical-rl;
    }

    .anchor {
        width: 20px;
        height: 20px;
        background: red;

        position: absolute;
        left: 50px;
        top: 50px;
    }

    #anchor-1 {
        anchor-name: --anchor1;
    }

    #anchor-2 {
        anchor-name: --anchor2;
    }

    .target-anchor-function {
        position: absolute;
        top: anchor(top);
        left: anchor(left);
        right: anchor(right);
        bottom: anchor(bottom);

        background: green;
    }

    #target-anchor-function-1 {
        position-anchor: --anchor1;
    }

    #target-anchor-function-2 {
        position-anchor: --anchor2;
    }

    .target-position-area {
        position: absolute;
        position-area: center center;
        width: 100%;
        height: 100%;

        background: blue;
    }

    #target-position-area-1 {
        position-anchor: --anchor1;
    }

    #target-position-area-2 {
        position-anchor: --anchor2;
    }
</style>

<div class="containing-block" dir="rtl">
    <!-- Long content to force scrollbar. -->
    <div style="height: 200px"></div>

    <div class="anchor" id="anchor-1"></div>
    <div class="target-anchor-function" id="target-anchor-function-1"></div>
    <div class="target-position-area" id="target-position-area-1"></div>
</div>

<div class="containing-block" id="containing-block-vertical-rl">
    <!-- Long content to force scrollbar. -->
    <div style="height: 200px; width: 20px"></div>

    <div class="anchor" id="anchor-2"></div>
    <div class="target-anchor-function" id="target-anchor-function-2"></div>
    <div class="target-position-area" id="target-position-area-2"></div>
</div>

<script>
    function getBoundingClientRectAsArray(element) {
        const rect = element.getBoundingClientRect();
        return [rect.left, rect.top, rect.right, rect.bottom];
    }

    test(() => {
        const anchor = document.getElementById("anchor-1");
        const targetAnchorFunction = document.getElementById("target-anchor-function-1");

        assert_array_equals(getBoundingClientRectAsArray(anchor), getBoundingClientRectAsArray(targetAnchorFunction));
    }, "anchor-positioned element using anchor() in horizontal, right-to-left scroller");

    test(() => {
        const anchor = document.getElementById("anchor-1");
        const targetPositionArea = document.getElementById("target-position-area-1");

        assert_array_equals(getBoundingClientRectAsArray(anchor), getBoundingClientRectAsArray(targetPositionArea));
    }, "anchor-positioned element using position-area in horizontal, right-to-left scroller");

    test(() => {
        const anchor = document.getElementById("anchor-2");
        const targetAnchorFunction = document.getElementById("target-anchor-function-2");

        assert_array_equals(getBoundingClientRectAsArray(anchor), getBoundingClientRectAsArray(targetAnchorFunction));
    }, "anchor-positioned element using anchor() in vertical-rl scroller");

    test(() => {
        const anchor = document.getElementById("anchor-2");
        const targetPositionArea = document.getElementById("target-position-area-2");

        assert_array_equals(getBoundingClientRectAsArray(anchor), getBoundingClientRectAsArray(targetPositionArea));
    }, "anchor-positioned element using position-area in vertical-rl scroller");
</script>