On 2016/12/20 8:00, Mats Palmgren wrote:
On 12/15/2016 10:46 AM, Masayuki Nakano wrote:
> Supporting multiple selection in editor makes our editor code
> complicated.
Why is that so exactly? By necessity, the code already operates
on one Range, right? so why can't we implement something like:
Selection.ApplyToAllRanges(aFunction) that applies the existing
code to all the ranges?
That's a good point. Even if we won't remove multiple selection feature
from editor, we should rewrite *all* selection loop with such utility.
> And for functions that doesn't make sense
to apply to all ranges, it's usually the first or last range
you want, so let's make convenience functions for those too.
Makes sense!
Would that help solve the problem?
I can say "yes" from the point of maintenance cost. But there is another
concern. Other browsers *ignore* Selection.addRange() when there is
already one range in the Selection. So, following code may be
incompatible with other browsers:
onSomething() {
let newRange = document.createRange();
newRange.setStart(foo, bar);
// If rangeCount is 0, the result on Gecko is same as other browsers,
// but not so if selection already has a range.
document.getSelection().addRange(newRange);
// Unexpected range (newRange) will be removed on Gecko, but the
// range may be a bug of web apps, but it won't be found with
// testing other browsers.
document.execCommand("delete");
}
--
Masayuki Nakano <masay...@d-toybox.com>
Manager, Internationalization, Mozilla Japan.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform