On 12/20/2016 03:25 AM, Masayuki Nakano wrote:
I'm talking about only nsISelectionController::SELECTION_NORMAL. Other selections need multiple selection.
I suspect that treating SELECTION_NORMAL differently from other kinds of Selections will actually make the code more complicated, not less.
At this time, we need to create loop for deleting all selection ranges, but the ranges may be changed/removed during handling other selection ranges.
Is that due to notifying selection listeners? If so, there is a RAII class for blocking those until you're done: SelectionBatcher. Anyway, I believe that we can add a few convenience methods/classes to make this stuff easy to work with... But let's take that code discussion off-list. :-)
We don't have any spec how do we behave in such case.
The current spec editor seems open to discussing multi-range Selection, which is encouraging. Perhaps we could add something like this: selection.forEachRange(function (range) { // do awesome stuff }) Since web developers are essentially doing this today: doAwesomeStuff(selection.getRangeAt(0)); it seems it should be an easy upgrade to do this instead: selection.forEachRange(doAwesomeStuff); Look, it's even shorter! :-) /Mats _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform