Oh, looks like that this is a path for bug 1703040. `nsRange` allows to update itself into an orphan fragment even if it's associated with `Selection`. Chrome removes the range from the `Selection` immediately. I think that we should follow that. However, it means that the loops like: ```c++ uint32_t rangeCount = selection->RangeCount(); for (uint32_t i = 0; i < rangeCount; i++) { RefPtr<nsRange> range = selection->GetRangeAt(i); range->DoSomething(); // May crash if `rangeCount` is larger than 1. } ``` https://searchfox.org/mozilla-central/search?q=Selection%3A%3ARangeCount&path=&case=true®exp=false
Bug 1878191 Comment 4 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Oh, looks like that this is a path for bug 1703040. `nsRange` allows to update itself into an orphan fragment even if it's associated with `Selection`. Chrome removes the range from the `Selection` immediately. I think that we should follow that. However, it means that the loops like: ```c++ uint32_t rangeCount = selection->RangeCount(); for (uint32_t i = 0; i < rangeCount; i++) { RefPtr<nsRange> range = selection->GetRangeAt(i); range->DoSomething(); // May crash if `rangeCount` is larger than 1. } ``` become crash or handle something with wrong ranges. https://searchfox.org/mozilla-central/search?q=Selection%3A%3ARangeCount&path=&case=true®exp=false