summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/multicol/hit-test-end-of-column-with-line-height.html
blob: aaec74f5a997de73e440ebf3635bba39697948f7 (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
<!DOCTYPE html>
<div id="target" style="
    outline: dashed lightblue;
    -webkit-columns: 2;
    -webkit-column-gap: 0;
    columns: 2;
    column-gap: 0;
    column-fill: auto;
    -webkit-logical-width: 400px;
    -webkit-logical-height: 80px;
    font: 20px Ahem;
    line-height: 2;
">Lorem ipsum dolor sit amet</div>
<pre id="console"></pre>
<script>
    if (window.testRunner)
        testRunner.dumpAsText();

    function log(message)
    {
        document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
    }

    // Clicking below the last line in the first column should not select anything from the first
    // line on the second column.
    var target = document.getElementById("target");
    var hitOffset = document.caretRangeFromPoint(target.offsetLeft + 190, target.offsetTop + 77).startOffset;
    log(hitOffset === 11 ? "PASS" : "FAIL: hit offset " + hitOffset + ".");

    // Clicking above the first line in the second column should not snap to the beginning of the line.
    hitOffset = document.caretRangeFromPoint(target.offsetLeft + 250, target.offsetTop + 2).startOffset;
    log(hitOffset === 14 ? "PASS" : "FAIL: hit offset " + hitOffset + ".");

    // Now test with a flipped lines writing mode.
    target.style.webkitWritingMode = "vertical-rl";

    // Clicking above the last line in the first column should not select anything from the first
    // line on the second column.
    hitOffset = document.caretRangeFromPoint(target.offsetLeft + 80, target.offsetTop + 193).startOffset;
    log(hitOffset === 11 ? "PASS" : "FAIL: hit offset " + hitOffset + ".");

    // Clicking below the first line in the second column should not snap to the beginning of the line.
    hitOffset = document.caretRangeFromPoint(target.offsetLeft + 77, target.offsetTop + 250).startOffset;
    log(hitOffset === 14 ? "PASS" : "FAIL: hit offset " + hitOffset + ".");
</script>