summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/multicol/client-rects.html
blob: b230834cc1468d530582982752e96327b96f2f38 (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
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
129
130
131
132
133
<!DOCTYPE html>
<script src="../../resources/ahem.js"></script>
<style>
    div.columns {
        height: 50px;
        width: 110px;
        margin: 10px 0;
        padding: 10px;
        border: solid black;
        font-family: Ahem;
        font-size: 25px;
        color: lightblue;
        -webkit-columns: 2;
        -webkit-column-gap: 10px;
        columns: 2;
        column-gap: 10px;
        column-fill: auto;
        display: inline-block;
        vertical-align: bottom;
    }

    div.marker {
        position: absolute;
        border: solid dodgerblue;
        -webkit-box-sizing: border-box;
    }

    input[type="range"] {
        -webkit-appearance: none;
        width: 25px;
        height: 25px;
        background-color: lightblue;
        margin: 0;
    }

    input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
    }
</style>
<p>
    The blue borders should coincide with light blue squares, like this:
    <span style="display: inline-block; background-color: lightblue; border: solid dodgerblue; width: 19px; height: 19px;"></span>.
    There should be none of this:
    <span style="display: inline-block; background-color: lightblue; width: 25px; height: 25px;"></span>
    or this:
    <span style="display: inline-block; border: solid dodgerblue; width: 19px; height: 19px;"></span>.
</p>
<div class="columns" id="t1">
    <br>x y z
</div>

<div class="columns">
    <br><span id="t2">x y z</span>
</div>

<div class="columns">
    <br><div id="t3">x y z</div>
</div>

<div class="columns">
    <br><div id="t4"><br>y z</div>
</div>

<div class="columns">
    <br><div><br><input id="t5" type="range"></div>
</div>

<div class="columns">
    <br><div><br><img id="t6" style="width: 25px; height: 25px; background-color: lightblue;"></div>
</div>

<p>
    Except here, where the blue border should be around the bigger slice of the blue square, on the right.
</p>

<div class="columns">
    <div id="t7" style=" margin-top: 40px; width: 25px; height: 25px; background-color: lightblue;"></div>
</div>

<script>
    function placeMarker(clientRect)
    {
        var marker = document.body.appendChild(document.createElement("div"));
        marker.className = "marker";
        marker.style.left = clientRect.left + "px";
        marker.style.top = clientRect.top + "px";
        marker.style.width = clientRect.width + "px";
        marker.style.height = clientRect.height + "px";
    }

    function placeMarkersForRange(range, startOffset)
    {
        if (startOffset === undefined)
            startOffset = 0;

        var clientRects = range.getClientRects();
        for (var i = startOffset; i < clientRects.length; ++i)
            placeMarker(clientRects[i]);
    }

    var range = document.createRange();

    var textNode = document.getElementById("t1").firstChild.nextSibling.nextSibling;
    range.setStart(textNode, 0);
    range.setEnd(textNode, 5);
    placeMarkersForRange(range);

    textNode = document.getElementById("t2").firstChild;
    range.setStart(textNode, 0);
    range.setEnd(textNode, 5);
    placeMarkersForRange(range);

    textNode = document.getElementById("t3").firstChild;
    range.setStart(textNode, 0);
    range.setEnd(textNode, 5);
    placeMarkersForRange(range);

    var block = document.getElementById("t4");
    range.selectNode(block);
    placeMarkersForRange(range, 1);

    var slider = document.getElementById("t5");
    range.selectNode(slider);
    placeMarkersForRange(range);

    var image = document.getElementById("t6");
    range.selectNode(image);
    placeMarkersForRange(range);

    var div = document.getElementById("t7");
    range.selectNode(div);
    placeMarkersForRange(div);
</script>