| 1 |
<svg version="1.1" baseProfile="full" onload="doSelection(0,0);" id="svg-root" |
| 2 |
width="100%" height="100%" viewBox="0 0 480 360" |
| 3 |
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 4 |
<!--======================================================================--> |
| 5 |
<!--= SVG 1.1 2nd Edition Test Case =--> |
| 6 |
<!--======================================================================--> |
| 7 |
<!--= Copyright 2009 World Wide Web Consortium, (Massachusetts =--> |
| 8 |
<!--= Institute of Technology, European Research Consortium for =--> |
| 9 |
<!--= Informatics and Mathematics (ERCIM), Keio University). =--> |
| 10 |
<!--= All Rights Reserved. =--> |
| 11 |
<!--= See http://www.w3.org/Consortium/Legal/. =--> |
| 12 |
<!--======================================================================--> |
| 13 |
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/" |
| 14 |
template-version="1.4" reviewer="CL" author="ED" status="accepted" |
| 15 |
version="$Revision: 1.6 $" testname="$RCSfile: text-tselect-02-f.svg,v $"> |
| 16 |
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/text.html#TextSelection"> |
| 17 |
<p> |
| 18 |
This test demonstrates text selection of bidirectional text. |
| 19 |
</p> |
| 20 |
</d:testDescription> |
| 21 |
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml"> |
| 22 |
<p> |
| 23 |
Run the test. No interaction required. |
| 24 |
</p> |
| 25 |
</d:operatorScript> |
| 26 |
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml"> |
| 27 |
<p> |
| 28 |
The initial result should be that the first 9 characters in logical order |
| 29 |
starting from logical position 0 are selected. |
| 30 |
</p> |
| 31 |
<p> |
| 32 |
Visually the selection is discontigous and these substrings must be selected (listed in visual order): |
| 33 |
</p> |
| 34 |
<p> |
| 35 |
"abc" |
| 36 |
</p> |
| 37 |
<p> |
| 38 |
the space between "c" and "ו" |
| 39 |
</p> |
| 40 |
<p> |
| 41 |
"1" |
| 42 |
</p> |
| 43 |
<p> |
| 44 |
the space between "3" and "ג" |
| 45 |
</p> |
| 46 |
<p> |
| 47 |
"אבג" |
| 48 |
</p> |
| 49 |
<p> |
| 50 |
If only the substrings listed above were selected then the test has passed. |
| 51 |
</p> |
| 52 |
<p> |
| 53 |
A user agent that allows selecting text in logical order would have generated the same selection |
| 54 |
as in this testcase if the user started the selection on the character "a" and ended it on the |
| 55 |
character "1". |
| 56 |
|
| 57 |
A user agent that allows selecting text in visual order would not have a discontigous selection |
| 58 |
if the user started the selection on the character "a" and ended it on the character "1". The copied |
| 59 |
text would be discontigous instead in this case. |
| 60 |
|
| 61 |
Note that the SVG DOM method requires logical order text selection, so for both types of user agents |
| 62 |
this testcase must look the same. |
| 63 |
</p> |
| 64 |
<p> |
| 65 |
The testcase also shows what happens when the selection is modified via DOM (click the buttons below |
| 66 |
the bidi-text). Compliant viewers must throw an exception when the first parameter handed |
| 67 |
to SVGTextContentElement.selectSubString is out-of-range. |
| 68 |
That means the variable 'startIndex' must always be in the range 0 <= startIndex <= 18. |
| 69 |
It can be noted that the parameter 'numChars' is not restricted in this way. |
| 70 |
</p> |
| 71 |
<p> |
| 72 |
Note that the color of the text selection is UA dependent and not defined in the SVG specification. |
| 73 |
</p> |
| 74 |
</d:passCriteria> |
| 75 |
</d:SVGTestCase> |
| 76 |
<title id="test-title">$RCSfile: text-tselect-02-f.svg,v $</title> |
| 77 |
<defs> |
| 78 |
<font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F"> |
| 79 |
<font-face-src> |
| 80 |
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> |
| 81 |
</font-face-src> |
| 82 |
</font-face> |
| 83 |
</defs> |
| 84 |
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> |
| 85 |
<defs> |
| 86 |
<script> |
| 87 |
var startIndex = 0; |
| 88 |
var numChars = 9; |
| 89 |
|
| 90 |
function doSelection(indexDelta, numCharsDelta) |
| 91 |
{ |
| 92 |
try |
| 93 |
{ |
| 94 |
document.getElementById('text').selectSubString(startIndex+indexDelta, numChars+numCharsDelta); |
| 95 |
} |
| 96 |
catch(e) |
| 97 |
{ |
| 98 |
if(e.code == DOMException.INDEX_SIZE_ERR) |
| 99 |
{ |
| 100 |
// If there was an error, re-select the last range |
| 101 |
document.getElementById('text').selectSubString(startIndex, numChars); |
| 102 |
return; |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
startIndex += indexDelta; |
| 107 |
numChars += numCharsDelta; |
| 108 |
|
| 109 |
document.getElementById('info').firstChild.data = "StartIndex: " + startIndex + ". NumChars: " + numChars; |
| 110 |
} |
| 111 |
</script> |
| 112 |
</defs> |
| 113 |
|
| 114 |
<g transform="translate(0,60)"> |
| 115 |
<text id="info" font-size="16" x="10" y="70">StartIndex: 0 NumChars: 0</text> |
| 116 |
|
| 117 |
<text id="text" font-size="48" y="128" x="10"> |
| 118 |
abc אבג 123 דהו def |
| 119 |
</text> |
| 120 |
|
| 121 |
<g id="buttons"> |
| 122 |
<rect x="10" y="160" width="100" height="20" fill="blue" onclick="doSelection(1,0);"/> |
| 123 |
<text x="60" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">startIndex++</text> |
| 124 |
|
| 125 |
<rect x="120" y="160" width="100" height="20" fill="blue" onclick="doSelection(-1,0);"/> |
| 126 |
<text x="170" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">startIndex--</text> |
| 127 |
|
| 128 |
<rect x="230" y="160" width="100" height="20" fill="blue" onclick="doSelection(0,1);"/> |
| 129 |
<text x="280" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">numChars++</text> |
| 130 |
|
| 131 |
<rect x="340" y="160" width="100" height="20" fill="blue" onclick="doSelection(0,-1);"/> |
| 132 |
<text x="390" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">numChars--</text> |
| 133 |
</g> |
| 134 |
</g> |
| 135 |
</g> |
| 136 |
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> |
| 137 |
<text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.6 $</text> |
| 138 |
</g> |
| 139 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/> |
| 140 |
<!-- comment out this watermark once the test is approved --> |
| 141 |
<!--<g id="draft-watermark"> |
| 142 |
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> |
| 143 |
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" |
| 144 |
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> |
| 145 |
</g>--> |
| 146 |
</svg> |