OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Text Selection when dragging mouse outside the SVG text element</title> |
2 <style> | 3 <style> |
3 text { | 4 text { |
4 font: 10px Arial; | 5 font: 10px Arial; |
5 } | 6 } |
6 </style> | 7 </style> |
7 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlin
k" width="400" height="400" style="border: 1px solid black;"> | 8 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlin
k" width="400" height="400" style="border: 1px solid black;"> |
8 <g> | 9 <g> |
9 <text id="firsttext" x="130" y="30">Happy, Web</text> | 10 <text id="firsttext" x="130" y="30">Happy, Web</text> |
10 <text id="middletext" x="130" y="50">Happy, SVG</text> | 11 <text id="middletext" x="130" y="50">Happy, SVG</text> |
11 <text id="endtext" x="130" y="70">Happy, ;)link</text> | 12 <text id="endtext" x="130" y="70">Happy, ;)link</text> |
12 </g> | 13 </g> |
13 <text id="line" x="130" y="150">Hello World. Hello, SVG.</text> | 14 <text id="line" x="130" y="150">Hello World. Hello, SVG.</text> |
14 </svg> | 15 </svg> |
15 <script src="../../resources/js-test.js"></script> | 16 <script src="../../resources/testharness.js"></script> |
| 17 <script src="../../resources/testharnessreport.js"></script> |
16 <script src="resources/SelectionTestCase.js"></script> | 18 <script src="resources/SelectionTestCase.js"></script> |
17 <script type="text/javascript"> | 19 <script> |
18 function getEndPosition(id, offset, gap) { | 20 test(function() { |
19 var element = document.getElementById(id); | 21 selectTextFromCharToPoint({ id: 'line', offset: 0 }, { x: 400, y: 400 }, { sta
rtElementId: 'line', start: 0, endElementId: "line", end: 24 }); |
20 var endPos = element.getEndPositionOfChar(offset); | 22 selectTextFromCharToPoint({ id: 'line', offset: 7 }, { x: 400, y: 400 }, { sta
rtElementId: "line", start: 7, endElementId: "line", end: 24 }); |
21 endPos.x += gap.x; | |
22 endPos.y += gap.y; | |
23 var absEndPos = toAbsoluteCoordinates(endPos, element); | |
24 return absEndPos; | |
25 } | |
26 | 23 |
27 selectTextFromCharToPoint({ id: 'line', offset: 0 }, { x: 400, y: 400 }, { start
ElementId: 'line', start: "0", endElementId: "line", end: "24" }); | 24 var absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 0}); |
28 selectTextFromCharToPoint({ id: 'line', offset: 7 }, { x: 400, y: 400 }, { start
ElementId: "line", start: "7", endElementId: "line", end: "24" }); | 25 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startEl
ementId: 'firsttext', start: 0, endElementId: "firsttext", end: 4}); |
29 | 26 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 10}); |
30 var absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 0}); | 27 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startEl
ementId: 'firsttext', start: 0, endElementId: "middletext", end: 4}); |
31 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startElem
entId: 'firsttext', start: "0", endElementId: "firsttext", end: "4"}); | 28 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 20}); |
32 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 10}); | 29 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startEl
ementId: 'firsttext', start: 0, endElementId: "middletext", end: 4}); |
33 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startElem
entId: 'firsttext', start: "0", endElementId: "middletext", end: "4"}); | 30 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 30}); |
34 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 20}); | 31 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startEl
ementId: 'firsttext', start: 0, endElementId: "endtext", end: 4}); |
35 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startElem
entId: 'firsttext', start: "0", endElementId: "middletext", end: "4"}); | 32 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 40}); |
36 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 30}); | 33 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startEl
ementId: 'firsttext', start: 0, endElementId: "endtext", end: 4}); |
37 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startElem
entId: 'firsttext', start: "0", endElementId: "endtext", end: "4"}); | 34 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 50}); |
38 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 40}); | 35 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startEl
ementId: 'firsttext', start: 0, endElementId: "endtext", end: 4}); |
39 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startElem
entId: 'firsttext', start: "0", endElementId: "endtext", end: "4"}); | 36 }); |
40 absEndPos = getEndPosition('firsttext', 3, { x : 0, y : 50}); | |
41 selectTextFromCharToPoint({ id: 'firsttext', offset: 0 }, absEndPos, { startElem
entId: 'firsttext', start: "0", endElementId: "endtext", end: "4"}); | |
42 | |
43 </script> | 37 </script> |
OLD | NEW |