[webkit-dev] Selection model is broken
rniwa at webkit.org
Thu Jan 5 16:18:43 PST 2012
On Thu, Jan 5, 2012 at 4:03 PM, Ojan Vafai <ojan at chromium.org> wrote:
> On Thu, Jan 5, 2012 at 3:47 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
>> 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.
> bidi is a different case. It has to do with user-insertion. The user
> inserts it in document order, so it makes sense to select it in document
> order. It does lead to crazy looking selections, but they are selections
> that make sense to bidi-users.
It's essentially the same case. Author puts bidirectional text on the page
and user can't select in visual order. We frequently get complaints about
that. And it's one of use cases for Gecko's multi-range selection (there's
an option to enable this).
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.
> Sure, but Gecko only uses it for selecting table columns, right?
> Otherwise, selections in Gecko are document ordered and between to points
> in the DOM.
No, user can create multi-range selection on regular text, etc...
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.
> It's true, but I think this is a less crappy experience. In these cases we
> could either try to copy in visual order or just paste out of order. It's
> not perfect, but it's better a better experience than selecting text that
> the user clearly didn't want selected.
I don't think that's a good idea. For example in the case of relatively
positioned blocks, those CSS properties that caused blocks to be relatively
positioned will stay with the pasted content. So we may end up pasting
contents that'll end up overlapping with the content at the destination.
Users can already copy all the contents, paste as text, and remove
unnecessary parts. That's much superior solution in that we'll more likely
to end up with the same visual ordering (because all contents will be
copied), and the website or the application into which the contents was
pasted will be able to deal with it appropriately.
Also, what should happen, for example, if those contents appear inside a
>> contenteditable region and the user hits delete, paste, insert a character,
> Yup. We have to handle all these cases appropriately. Copy is the only
> hard case IMO. Delete is implemented as deleting each sub-range
> individually and then collapsing the selection at the beginning of the
> first range. For all the other cases, you do a delete and then insert into
> the now collapsed selection.
That's an over simplification. "Deleting" a relatively positioned block or
contents inside a flexbox isn't as simple as just deleting the element. We
have to make adjustments to adjacent elements, which may also be in other
disjoint ranges of the same selection we're operating on. In general, I'd
expect those disjoint ranges in the selection to have a very complex
dependencies with each other. Dealing with the interactions of those
dependencies within editing commands is extremely difficult. Ehsan (from
Mozilla) can educate us on that topic.
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.
> We'll never get it 100% right, but we can get much much closer than we do
> today and with the increasing number of cases that hit this, it becomes
> more important that we do get this right.
I don't think it's worth the complexity. In my opinion, this is one of
those features we shouldn't implement despite of the potential benefits.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev