caret-in-svg-text.xhtml 1.32 KB
Newer Older
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
<html xmlns="http://www.w3.org/1999/xhtml">
<body style="margin: 0px; ">
  <div style="width: 400px; height: 100px;">
    <svg xmlns="http://www.w3.org/2000/svg"> 
        <text x="20" y="30"><tspan>Sheriff Woody</tspan></text>
        <text x="20" y="50"><tspan>שדגש</tspan></text>
    </svg>
  </div>
  <div id="log"></div>
  <script>
  function log(message) {
    document.getElementById("log").innerText = document.getElementById("log").innerText + "\n" + message;
  }
  function assert(found, expected) {
      if (found == expected)
        log("Success");
      else
        log("Failure. Was: " + found + ", expected: " + expected);
  }
  if (window.layoutTestController) {
    window.layoutTestController.dumpAsText();
    // First offset, left edge, LTR text
    assert(textInputController.firstRectForCharacterRange(0, 0), "20,566,0,18");
    // Last offset, right edge, RTL text
    assert(textInputController.firstRectForCharacterRange(13, 0), "114,566,0,18");

    // FIXME: These edges are incorrect (although carets in the middle of RTL runs are correct).
    // First offset, right edge, RTL text
    assert(textInputController.firstRectForCharacterRange(14, 0), "58,546,0,18");
    // Last offset, left edge, RTL text
    assert(textInputController.firstRectForCharacterRange(18, 0), "20,546,0,18");
  }
  </script>
</body>
</html>