-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add validity criteria for StaticRange #1009
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to clarify that w3c/csswg-drafts#4597 (comment) is intentional before we move ahead with this, but overall this seems reasonable to me.
Have any measurements been done to show that this is indeed faster?
cc @smaug----
Commented here.
Yes, @ffiori built some benchmarks for this and ran them on Chromium's Highlight API prototype, with the findings documented here. As expected, adding a large number of live Ranges to a document increases the cost of DOM node moves due to the cost of keeping the Ranges up-to-date for every DOM operation. For StaticRange, these costs were avoided, and since it's possible to cache the results of the validity checks StaticRanges were in some cases significantly fater, and never significantly slower. |
Use of StaticRanges forces one to use MutationObserver or other mechanisms to detect mutations in order to keep StaticRanges up-to-date all the time, so the tests were very much unrealistic. But anyhow, this change as such is fine. |
Add criteria defining whether a StaticRange is valid.
This will be used by the CSS Highlight API to determine whether or not to paint highlights specified by StaticRanges. See https://drafts.csswg.org/css-highlight-api-1/#range-invalidation (which will be updated to point to the DOM spec definition) and the CSSWG resolution that Highlight API should use StaticRanges internally rather than backing them with live Ranges.
Resolves #947.
determine when to paint or paint a given StaticRange. See in particular custom-highlight-painting-invalidation-*.html
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff