OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <style> | 2 <style> |
3 text { | 3 text { |
4 font: 10px Arial; | 4 font: 10px Arial; |
5 } | 5 } |
6 </style> | 6 </style> |
7 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlin
k" width="400" height="400" viewBox="0 0 350 350" style="border: 1px solid black
;"> | 7 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlin
k" width="400" height="400" viewBox="0 0 350 350" style="border: 1px solid black
;"> |
8 <g> | 8 <g> |
9 <text x="10" y="70">Hello World. Hello, SVG.</text> | 9 <text x="10" y="70">Hello World. Hello, SVG.</text> |
10 </g> | 10 </g> |
11 <g transform="translate(70, 50)"> | 11 <g transform="translate(70, 50)"> |
12 <g transform="rotate(20) scale(1.5)"> | 12 <g transform="rotate(20) scale(1.5)"> |
13 <text id="line1" x="10" y="70">Hello World. Hello, SVG. Hello, ;)link. Hel
lo, Chromium.</text> | 13 <text id="line1" x="10" y="70">Hello World. Hello, SVG. Hello, ;)link. Hel
lo, Chromium.</text> |
14 <text id="line2" x="10" y="80">Hello World. Hello, SVG.</text> | 14 <text id="line2" x="10" y="80">Hello World. Hello, SVG.</text> |
15 </g> | 15 </g> |
16 </g> | 16 </g> |
17 </svg> | 17 </svg> |
18 <script src="../../resources/js-test.js"></script> | 18 <script src="../../resources/testharness.js"></script> |
| 19 <script src="../../resources/testharnessreport.js"></script> |
19 <script src="resources/SelectionTestCase.js"></script> | 20 <script src="resources/SelectionTestCase.js"></script> |
20 <script type="text/javascript"> | 21 <script> |
| 22 test(function() { |
21 function getEndPosition(id, offset, gap) { | 23 function getEndPosition(id, offset, gap) { |
22 var element = document.getElementById(id); | 24 var element = document.getElementById(id); |
23 var endPos = element.getEndPositionOfChar(offset); | 25 var endPos = element.getEndPositionOfChar(offset); |
24 endPos.x += gap.x; | 26 endPos.x += gap.x; |
25 endPos.y += gap.y; | 27 endPos.y += gap.y; |
26 var absEndPos = toAbsoluteCoordinates(endPos, element); | 28 var absEndPos = toAbsoluteCoordinates(endPos, element); |
27 return absEndPos; | 29 return absEndPos; |
28 } | 30 } |
29 | 31 |
30 var absEndPos = getEndPosition('line1', 10, { x : 0, y : -20}); | 32 var absEndPos = getEndPosition('line1', 10, { x : 0, y : -20}); |
31 selectTextFromCharToPoint({ id: 'line1', offset: 0 }, absEndPos, { startElementI
d: "line1", start: "0", endElementId: "line1", end: "11" }); | 33 selectTextFromCharToPoint({ id: 'line1', offset: 0 }, absEndPos, { startElementI
d: "line1", start: 0, endElementId: "line1", end: 11 }); |
32 absEndPos = getEndPosition('line1', 23, { x : 0, y : -20}); | 34 absEndPos = getEndPosition('line1', 23, { x : 0, y : -20}); |
33 selectTextFromCharToPoint({ id: 'line1', offset: 7 }, absEndPos, { startElementI
d: "line1", start: "7", endElementId: "line1", end: "24" }); | 35 selectTextFromCharToPoint({ id: 'line1', offset: 7 }, absEndPos, { startElementI
d: "line1", start: 7, endElementId: "line1", end: 24 }); |
34 absEndPos = getEndPosition('line2', 10, { x : 0, y : 20}); | 36 absEndPos = getEndPosition('line2', 10, { x : 0, y : 20}); |
35 selectTextFromCharToPoint({ id: 'line2', offset: 0 }, absEndPos, { startElementI
d: "line2", start: "0", endElementId: "line2", end: "11" }); | 37 selectTextFromCharToPoint({ id: 'line2', offset: 0 }, absEndPos, { startElementI
d: "line2", start: 0, endElementId: "line2", end: 11 }); |
36 absEndPos = getEndPosition('line2', 23, { x : 0, y : 20}); | 38 absEndPos = getEndPosition('line2', 23, { x : 0, y : 20}); |
37 selectTextFromCharToPoint({ id: 'line2', offset: 7 }, absEndPos, { startElementI
d: "line2", start: "7", endElementId: "line2", end: "24" }); | 39 selectTextFromCharToPoint({ id: 'line2', offset: 7 }, absEndPos, { startElementI
d: "line2", start: 7, endElementId: "line2", end: 24 }); |
38 absEndPos = getEndPosition('line2', 10, { x : 0, y : 20}); | 40 absEndPos = getEndPosition('line2', 10, { x : 0, y : 20}); |
39 selectTextFromCharToPoint({ id: 'line1', offset: 7 }, absEndPos, { startElementI
d: "line1", start: "7", endElementId: "line2", end: "11" }); | 41 selectTextFromCharToPoint({ id: 'line1', offset: 7 }, absEndPos, { startElementI
d: "line1", start: 7, endElementId: "line2", end: 11 }); |
40 absEndPos = getEndPosition('line1', 20, { x : 0, y : -20}); | 42 absEndPos = getEndPosition('line1', 20, { x : 0, y : -20}); |
41 selectTextFromCharToPoint({ id: 'line2', offset: 7 }, absEndPos, { startElementI
d: "line2", start: "7", endElementId: "line1", end: "21" }); | 43 selectTextFromCharToPoint({ id: 'line2', offset: 7 }, absEndPos, { startElementI
d: "line2", start: 7, endElementId: "line1", end: 21 }); |
| 44 }); |
42 </script> | 45 </script> |
OLD | NEW |