[whatwg] Control over selection direction

Ryosuke Niwa rniwa at webkit.org
Fri May 6 14:28:18 PDT 2011


On Tue, May 3, 2011 at 4:49 PM, Ian Hickson <ian at hixie.ch> wrote:
>
> I've added selectionDirection = 'forward'/'backward'/'none'. ('none' is
> the default selection direction on Mac OS.)


Thank you for the update!  One thing to point out is that setSelectionRange
in WebKit currently sets "forward" direction when the argument is omitted so
the following lines in the spec 4.10.20 should be revised

The direction of the selection must be set to *backward* if direction is a
case-sensitive<http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#case-sensitive>
match
for the string "backward", *forward* if direction is a
case-sensitive<http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#case-sensitive>
match
for the string "forward" or if the platform does not support selections with
the direction *none*, and *none* otherwise (including if the argument is
omitted)

to

The direction of the selection must be set to *backward* if direction is a
case-sensitive<http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#case-sensitive>
match
for the string "backward", *forward* if direction is a
case-sensitive<http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#case-sensitive>
match
for the string "forward" or if the argument is omitted or the platform does
not support selections with the direction *none*, and *none* otherwise.

On Fri, May 6, 2011 at 2:00 PM, Aryeh Gregor <Simetrical+w3c at gmail.com>wrote:
>
> What does "none" mean?


Means that there's selection doesn't have directionality and the behavior is
platform-dependent.


> If the user hits the right arrow key, does the cursor move to the right of
> the last character of the selection or the first?


On WebKit on Mac, selection is extended forward (right in LTR / left in RTL)
when you press the right arrow key. Selection is extended backward (left in
LTR / right in RTL) when you press the left arrow key.  But that's just one
platform-dependent behavior and shouldn't be considered normative.

What should UAs do on platforms that don't support the concept of a "none"
> direction (assuming there are such)?
>

It should default to forward.

This is also inconsistent with Selection, which has only two directions.


It is consistent since WebKit on Mac supports non-directional DOM Selection.

- Ryosuke



More information about the whatwg mailing list