# HG changeset patch # User Aryeh Gregor # Date 1294795143 25200 # Node ID 7963331ee0cb241fd07ae48b9b617b8a25379fde # Parent de818fdcdac1ff0db105241c543feb42ccb333d4 First pass at direction support for selections http://www.w3.org/Bugs/Public/show_bug.cgi?id=10624 diff --git a/source.html b/source.html --- a/source.html +++ b/source.html @@ -817,16 +817,31 @@ that it has only one segment and that se same) then the selection's position should equal the caret position. When the selection is not empty, this specification does not define the caret position; user agents should follow platform conventions in deciding whether the caret is at the start of the selection, the end of the selection, or somewhere else. +

Each selection has a direction, either forwards or +backwards. If the user creates a selection by indicating first one boundary point of the selection and then the other (such as by +clicking on one point and dragging to another), and the position of the first indicated boundary point relative to the second is +"after", then the corresponding selection +should initially be backwards. Otherwise, it should be forwards (including if +the user didn't create the selection, +created it by selecting an entire part of the page using a keyboard shortcut, +etc.). +

On some platforms (such as those using Wordstar editing conventions), the caret position is totally independent of the start and end of the selection, even when the selection is empty. On such platforms, user agents may ignore the requirement that the cursor position be linked to the position of the selection altogether.

User agents may selectively ignore attempts to use the API to adjust the @@ -924,34 +939,50 @@ any explicitly called out below.

Returns the offset of the end of the selection relative to the element that contains the end of the selection.

Returns 0 if there's no selection.

The anchorNode -attribute must return the value returned by the -startContainer attribute of the last -Range object in the list, or null if the list is empty. +attribute must return null if the list is empty. Otherwise, if the selection's direction is forwards (respectively +backwards), it must return the value returned by the startContainer (respectively endContainer) attribute of the last +Range object in the list.

The anchorOffset -attribute must return the value returned by the -startOffset attribute of the last -Range object in the list, or 0 if the list is empty. +attribute must return 0 if the list is empty. Otherwise, if the selection's direction is forwards (respectively +backwards), it must return the value returned by the startOffset (respectively endOffset) attribute of the last +Range object in the list.

The focusNode -attribute must return the value returned by the -endContainer attribute of the last -Range object in the list, or null if the list is empty. +attribute must return null if the list is empty. Otherwise, if the selection's direction is forwards (respectively +backwards), it must return the value returned by the endContainer (respectively startContainer) attribute of the last +Range object in the list.

The focusOffset -attribute must return the value returned by the -endOffset attribute of the last -Range object in the list, or 0 if the list is empty. +attribute must return 0 if the list is empty. Otherwise, if the selection's direction is forwards (respectively +backwards), it must return the value returned by the endOffset (respectively startOffset) attribute of the last +Range object in the list.


collapsed = selection . isCollapsed()

Returns true if there's no selection or if the selection is empty. @@ -1111,17 +1142,18 @@ title>range) method m

The removeAllRanges() method must remove all the Ranges from the list of Ranges, such that the rangeCount attribute returns 0 after the removeAllRanges() method is invoked (and until a new Range is added to the list, either through -this interface or via user interaction). +this interface or via user interaction). The direction must be set to forwards.


The stringifier must return the concatenation of the results of stringifying each of the