blob: 142d9194e91d13d1ef4180bafa253b148fbb669c [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Full//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-flat.dtd">
<svg version="1.1" baseProfile="full" id="svg-root" width="100%" height="100%" viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" onload="doSelection(0,0);">
<!--========================================================================-->
<!--= Copyright 2006 World Wide Web Consortium, (Massachusetts =-->
<!--= Institute of Technology, European Research Consortium for =-->
<!--= Informatics and Mathematics (ERCIM), Keio University). =-->
<!--= All Rights Reserved. =-->
<!--= See http://www.w3.org/Consortium/Legal/. =-->
<!--========================================================================-->
<!-- NOTE: CVS will automatically update the -->
<!-- "$RCSfile: text-tselect-02-f.svg,v $" and "$Revision: 1.2 $" -->
<!-- fields in the file. -->
<!-- There is no need to update this information. -->
<!-- =====================================================================-->
<SVGTestCase xmlns="http://www.w3.org/2000/02/svg/testsuite/description/" reviewer="CL" owner="ED" desc="Tests bidirectional text selection" status="created" version="$Revision: 1.2 $" testname="$RCSfile: text-tselect-02-f.svg,v $">
<OperatorScript>
<Paragraph>
This test demonstrates text selection of bidirectional text.
The initial result should be that the first 9 characters in logical order
starting from logical position 0 are selected. Visually the selection is
discontigous and these substrings must be selected (listed in visual order):
</Paragraph>
<Paragraph>
"abc"
</Paragraph>
<Paragraph>
the space between "c" and "&#1493;"
</Paragraph>
<Paragraph>
"1"
</Paragraph>
<Paragraph>
the space between "3" and "&#1490;"
</Paragraph>
<Paragraph>
"&#1488;&#1489;&#1490;"
</Paragraph>
<Paragraph>
If only the substrings listed above were selected then the test has passed.
</Paragraph>
<Paragraph>
A user agent that allows selecting text in logical order would have generated the same selection
as in this testcase if the user started the selection on the character "a" and ended it on the
character "1".
A user agent that allows selecting text in visual order would not have a discontigous selection
if the user started the selection on the character "a" and ended it on the character "1". The copied
text would be discontigous instead in this case.
Note that the SVG DOM method requires logical order text selection, so for both types of user agents
this testcase must look the same.
</Paragraph>
<Paragraph>
The testcase also shows what happens when the selection is modified via DOM (click the buttons below
the bidi-text). Compliant viewers must throw an exception when the first parameter handed
to SVGTextContentElement.selectSubString is out-of-range.
That means the variable 'startIndex' must always be in the range 0 &lt;= startIndex &lt;= 18.
It can be noted that the parameter 'numChars' is not restricted in this way.
</Paragraph>
<Paragraph>
Note that the color of the text selection is UA dependent and not defined in the SVG specification.
</Paragraph>
</OperatorScript>
</SVGTestCase>
<title id="test-title">$RCSfile: text-tselect-02-f.svg,v $</title>
<!--======================================================================-->
<!--Content of Test Case follows... =====================-->
<!--======================================================================-->
<g id="test-body-content">
<defs>
<script><![CDATA[
var startIndex = 0;
var numChars = 9;
function doSelection(indexDelta, numCharsDelta)
{
try
{
document.getElementById('text').selectSubString(startIndex+indexDelta, numChars+numCharsDelta);
}
catch(e)
{
if(e.code == DOMException.INDEX_SIZE_ERR)
{
// If there was an error, re-select the last range
document.getElementById('text').selectSubString(startIndex, numChars);
return;
}
}
startIndex += indexDelta;
numChars += numCharsDelta;
document.getElementById('info').firstChild.data = "StartIndex: " + startIndex + ". NumChars: " + numChars;
}
]]></script>
</defs>
<g transform="translate(0,60)">
<text id="info" font-size="16" x="10" y="70">StartIndex: 0 NumChars: 0</text>
<text id="text" font-size="48" y="128" x="10">
abc &#1488;&#1489;&#1490; 123 &#1491;&#1492;&#1493; def
</text>
<g id="buttons">
<rect x="10" y="160" width="100" height="20" fill="blue" onclick="doSelection(1,0);"/>
<text x="60" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">startIndex++</text>
<rect x="120" y="160" width="100" height="20" fill="blue" onclick="doSelection(-1,0);"/>
<text x="170" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">startIndex--</text>
<rect x="230" y="160" width="100" height="20" fill="blue" onclick="doSelection(0,1);"/>
<text x="280" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">numChars++</text>
<rect x="340" y="160" width="100" height="20" fill="blue" onclick="doSelection(0,-1);"/>
<text x="390" y="175" text-anchor="middle" font-size="16" fill="white" pointer-events="none">numChars--</text>
</g>
</g>
</g>
<text id="revision" x="10" y="340" font-size="40" stroke="none" fill="black">$Revision: 1.2 $</text>
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
<style>
/* Hebrew */
@font-face {
font-family: 'times';
src: local('Lucida Grande');
unicode-range: U+0590-05FF;
}
</style>
<script>
if (window.testRunner)
window.testRunner.dumpSelectionRect();
</script>
</svg>