Current spec is: https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface
There was this very old request from an Apple engineer here: https://lists.w3.org/Archives/Public/www-style/2012Oct/0683.html
This week I was asked for some help with performance of an add-on, which was doing something particularly expensive to see if an element was visible. I suggested that, given a lot of the bottleneck was walking the DOM since it's an extension and it has security wrappers, using elementFromPoint-like APIs should speed up stuff, and indeed it did quite a lot. See mozilla/fathom#91. But that misses the element if it's outside of the viewport.
We have similar non-web-exposed APIs that avoid this clip for various Firefox features, and apparently the best work-around this problem if you're an author resides in using window.scrollTo and such. See for example: https://stackoverflow.com/questions/19715620/javascript-get-element-at-point-outside-viewport
The original thread suggests new APIs altogether. I think it'd be better to add some dictionary argument to the existing APIs, something like:
dictionary FromPointOptions {
boolean ignoreViewportClip = false;
}
Or such?
While working on this, I could also try to do a bit of spec maintenance, since there's multiple stuff we've resolved on that hasn't been incorporated to the spec. If only, moving these to DocumentOrShadowRoot, the node/nodesFromPoint APIs discussed in here.
This also fits nicely for the "include display: contents parents" option that people discussed in #556.
Does an API like this make sense to y'all? :)
/cc @tabatkins @zcorpan @smfr
Current spec is: https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface
There was this very old request from an Apple engineer here: https://lists.w3.org/Archives/Public/www-style/2012Oct/0683.html
This week I was asked for some help with performance of an add-on, which was doing something particularly expensive to see if an element was visible. I suggested that, given a lot of the bottleneck was walking the DOM since it's an extension and it has security wrappers, using
elementFromPoint-like APIs should speed up stuff, and indeed it did quite a lot. See mozilla/fathom#91. But that misses the element if it's outside of the viewport.We have similar non-web-exposed APIs that avoid this clip for various Firefox features, and apparently the best work-around this problem if you're an author resides in using
window.scrollToand such. See for example: https://stackoverflow.com/questions/19715620/javascript-get-element-at-point-outside-viewportThe original thread suggests new APIs altogether. I think it'd be better to add some dictionary argument to the existing APIs, something like:
dictionary FromPointOptions { boolean ignoreViewportClip = false; }Or such?
While working on this, I could also try to do a bit of spec maintenance, since there's multiple stuff we've resolved on that hasn't been incorporated to the spec. If only, moving these to
DocumentOrShadowRoot, thenode/nodesFromPointAPIs discussed in here.This also fits nicely for the "include
display: contentsparents" option that people discussed in #556.Does an API like this make sense to y'all? :)
/cc @tabatkins @zcorpan @smfr