Re: [csswg-drafts] [css-highlight-api] invalidation of static ranges (#4597)

> Then we need to have performance tests which check how much overhead it is to observe mutations and update highlights based on them. Simple validity check isn't enough on the caller side, but one needs to check if the end points of the StaticRange are pointing to were they should, and that is costly.

We've updated the [test document](https://docs.google.com/document/d/1byMUPIcx2cldNlppyvRP3HX9w1NIryO_F7mgQNytMzs/edit#heading=h.7nki9mck5t64) with a couple of tests along these lines (Tests 6-7, where 6 is the more realistic of the two and 7 is showing a worst-case scenario for StaticRange). When considering the cost of author code to maintain StaticRanges, StaticRange will still often be much better than live range because the StaticRange updates can be batched at the end of a series of DOM mutations, where live range updates always happen during every individual change in a series of DOM mutations.

It's also important to consider that in many scenarios there would also be a cost for author code to update *live* range positions, because the live range repositioning done by the platform will probably not always be the exact behavior that authors need.

For example, consider a live range highlight marking a misspelled word for a custom spell-checker. If the text of the word grows or shrinks, the author will probably need to have some code run to keep the range repositioned around the word (or to remove the range if it’s now spelled correctly). It’s unlikely that the browser engine would update the offsets of the live range in exactly the way required by the author, so in practice there is still cost for running author code to check and update live ranges.


-- 
GitHub Notification of comment by dandclark
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4597#issuecomment-914703682 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 7 September 2021 23:48:31 UTC