[whatwg] selection.modify behavior across platforms

Ehsan Akhgari ehsan at mozilla.com
Mon Mar 28 16:09:14 PDT 2011


> Why would an author want to use Selection.modify() to implement a
> spellcheck API? Wouldn't that imply that they'd have to save the
> user's selection somewhere, create a new one, modify() it to the right
> place, do whatever they want to do with the resulting range, then
> remove the ranges and restore the original selection? Not only is
> this complicated and easy to get wrong, it might result in the
> selection visibly flickering. For things like spellcheck, wouldn't we
> want to have an API on Range instead?

I was talking about the way that the spell checking dialog works in OpenOffice Writer, for example.  The selection would be visible on the screen, and its contents might get changed if the user chooses to.  But spell checking is just one example where Selection.modify might be useful.  Let's not get distracted from the main discussion.

> Why can't such an application just return true from the event handler
> to let the platform-specific behavior take effect? Indeed, if it
> wants to respect platform-specific behavior, it can't rely on calling
> modify() in response to keypresses, because the same keypresses have
> entirely different effects on different platforms. For instance,
> IIRC, Home on OS X goes to the beginning of the text field instead of
> the beginning of the line as on Windows/typical Linux; Ctrl-A goes to
> the beginning of the line instead of doing nothing special as on
> Windows/typical Linux; etc. Some of this stuff is even configurable
> on some platforms (at least GTK, AFAICT). So if the user presses
> Home, how are you going to decide whether to modify() by
> "lineboundary" or "documentboundary"? The only reliable way is to not
> interfere at all.
> 
> At this point I'm still really unclear on what the use-cases are for
> this feature. I wasn't able to find discussion in the WebKit bug
> tracker in a quick search. I also didn't find any explanation of
> actual use-cases on the Mozilla bug:
> <https://bugzilla.mozilla.org/show_bug.cgi?id=496275>. I get the
> impression there are actual use-cases for *something* resembling this
> feature, I just haven't figured out what they are . . .

Here's a possible use case: https://bugzilla.mozilla.org/show_bug.cgi?id=496275#c10


--
Ehsan Akhgari
ehsan at mozilla.com
http://ehsanakhgari.org/



More information about the whatwg mailing list