[webkit-dev] Selection model is broken
rniwa at webkit.org
Thu Jan 5 15:47:13 PST 2012
On Thu, Jan 5, 2012 at 3:31 PM, Ojan Vafai <ojan at chromium.org> wrote:
> Selections on the web are document ordered (i.e. all the DOM between two
> points). So, any CSS that puts elements out of document order gives a
> crappy selection to the user.
> <div style="position:relative">foo<div
> If you select "foobaz", clearly no user would expect "bar" to get
> selected. The same problem arises with floats, negative margins, flexbox
> and grid ordering. I expect it's likely that CSS will continue to get more
> ways to put elements out of document order.
The same behavior arises from bidirectional text as well.
The only solution I can think of to this is to create a hit-test rect when
> making a selection from the start point to the end point and then only
> include the DOM contents that overlaps the rect. We'd still include all the
> inline content of overlapping elements, but elements that don't overlap at
> all would be excluded.
> So, instead of a selection being a start and end DOM position, it would be
> a list of disjoint start and end DOM positions.
That's exactly what a multi-range selection is.
Does this seem technically feasible? I think we can get the APIs exposed to
> JS to work with this if we are willing to make the change.
Gecko already have such an API.
The big pro is that selections will be much more intuitive for a large and
> growing class of layouts.
> -Making a selection is slower now and involves hit-testing a full rect
> instead of just two points. (is this even possible?)
> -The code that deals with selections now needs to operate on multiple
> selections (e.g. hitting delete in an editable area needs to separately
> delete each sub-range).
> we need to add new APIs in order to maintain backwards compatibility for
> the old APIs.
Also, once user can select such content, they'd expect to be able to copy &
paste that content. In fact, the most probable reason an user selects text
is to copy it.
However, when relatively positioned, flexbox, etc... are involved, there's
virtually no way for us to ensure the pasted content will maintain the
visual order. So users would get crappy experience anyways.
Also, what should happen, for example, if those contents appear inside a
contenteditable region and the user hits delete, paste, insert a character,
Is this too crazy? Are there other solutions?
I'm strongly opposed to the idea of supporting multi-range selection. It's
not worth the complexity and we'll never get it right.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev