Specification link: 10.16 Text selection and clipboard operations

styling-css-04-f ← index → animate-elem-22-b

# text-tselect-01-f
SVG Image | PNG Image
$RCSfile: text-tselect-01-f.svg,v $ 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; } StartIndex: 0 NumChars: 0 abc אבג 123 דהו def startIndex++ startIndex-- numChars++ numChars-- $Revision: 1.2 $ |

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):

"abc"

the space between "c" and "ו"

"1"

the space between "3" and "ג"

"אבג"

If only the substrings listed above were selected then the test has passed.

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.

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 <= startIndex <= 18. It can be noted that the parameter 'numChars' is not restricted in this way.

styling-css-04-f ← index → animate-elem-22-b