Currently, Gecko is the only browser engine which supports multiple
selection ranges.
When user makes a non-collapsed selection range by dragging a mouse or
"Select All", Gecko splits the range to multiple ones to exclude
non-selectable elements. E.g., if you do "Select All" in a bug page,
over 30 selection ranges will be created even if there is only comment#0.
However, some web apps do not handle multiple ranges correctly. They
assume that they need to handle only one range which is returned by
`|getSelection().getRangeAt(0)|`. When the apps use
`|::before|`/`|::after|` pseudo-elements and/or `|user-select:none|`,
only the first range before such non-selectable content will be handled
and the latter content will be ignored.
To improve the compatibility around this, Gecko will stop splitting the
user's selection range automatically. Instead, the layout module stops
painting non-selectable content as selected by itself. And
non-selectable elements won't be contained in the clipboard data when
you copy the range containing them nor in the result of
`|getSelection().toString()|`. However, the result of
`|getSelection().getRangeAt(0).toString()|` will start containing the
non-selectable content.
Gecko has already stopped doing this when the web apps use Selection
API. Therefore, the painting result after selecting non-selectable
elements with Selection API may be changing. However, the painting
results become consistent with the source of selection and more
compatible with Chrome.
Note that this change does *not* mean Gecko stops supporting multiple
selection ranges. Can be create multiple selection ranges with selecting
content with Ctrl or Command key press or `|getSelection().addRange()|`
without `|getSelection().removeAllRanges()|`.
Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1998858
Specification: N/A
Platform coverage: All platforms
Preference: |dom.selection.exclude_non_selectable_nodes|
DevTools bug: N/A
Other browsers: Do not support multiple selection ranges so that they
won't split user's selection range
web-platform-tests: N/A (there are tons of incompatibility at edge
cases, but testing with a lot of mochitests)
--
Masayuki Nakano<[email protected]>
Working on DOM, Events, editor and IME handling for Gecko
--
You received this message because you are subscribed to the Google Groups
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/8e324215-bbea-4a77-9016-f4bf0c286d01%40d-toybox.com.