Re: [csswg-drafts] [css-highlight-api] Should highlightsFromPoint also return ranges under the hit point? (#12031)

The CSS Working Group just discussed `[css-highlight-api] Should highlightsFromPoint also return ranges under the hit point?`, and agreed to the following:

* `RESOLVED: Accept the proposal in the issue.`

<details><summary>The full IRC log of that discussion</summary>
&lt;TabAtkins> fernando: this is about the return value of highlightsFromPoint<br>
&lt;TabAtkins> fernando: original proposal for for highlights that are hit under a certain point<br>
&lt;TabAtkins> fernando: after some examples, might be useful to return the *ranges* hit for every highlight that is hit, too<br>
&lt;TabAtkins> fernando: so proposing to return, rather than a sequence of highlights, a sequence of highlighthitresults that are the highlight and the range<br>
&lt;TabAtkins> fernando: this is useful fro spell checkers, custom find in page, etc where you need to know what word you're interacting with<br>
&lt;TabAtkins> fernando: so i'd like to hear your thoughts<br>
&lt;emilio> q+<br>
&lt;Rossen5> ack ChrisL<br>
&lt;Rossen5> ack emilio<br>
&lt;schenney> q+<br>
&lt;TabAtkins> emilio: seems fine overall<br>
&lt;TabAtkins> emilio: is the idea that... presuambly we're not synthesizing ranges, we return the actual Range objects right? just filtering down the ranges that the highlight currently has?<br>
&lt;TabAtkins> fernando:  yes, correct<br>
&lt;TabAtkins> emilio: okay, i think we had similar discussions (unsure if this api or another one), the concern was that it wasn't clear exactly what ranges to return<br>
&lt;TabAtkins> emilio: but as long as we're just filtering the existing ranges from the highlight, that's fine<br>
&lt;Rossen5> q+ to ask about overlapping ranges<br>
&lt;TabAtkins> emilio: one concern is you can't early-out as soon as you hit a highlight, you do need to iterate over the ranges<br>
&lt;TabAtkins> emilio: might be a littl eanoying to have to do that work if the user doesn't need it<br>
&lt;TabAtkins> emilio: but if you're clickign on one misspelled word, having to walk all the ranges associated with that highlight in author-land seems bad<br>
&lt;TabAtkins> emilio: so i think it's probably fine, just a bit unfortunate you'll still have to pay for it if all you need is the highlight itself<br>
&lt;TabAtkins> emilio: but the commonc ase is not hitting them anyway<br>
&lt;Rossen5> ack schenney<br>
&lt;TabAtkins> schenney: i think the issue you're remembering is related to the pseudo-classes on pseudo-elements, if you hovered a [missed due to overtalk]<br>
&lt;TabAtkins> emilio: that's right<br>
&lt;TabAtkins> schenney: if you set a highlight with a particuilar name, with multiple sub ranges, and you click on any one range you'll get all the ranges for that highlight? or just the ones under the hit point<br>
&lt;TabAtkins> fernando: the latter, only the ranges that were hit<br>
&lt;Rossen5> q-<br>
&lt;TabAtkins> fernando: you can already retrieve all the associated ranges just from the highlight directly<br>
&lt;TabAtkins> schenney: okay, i think that addresses the concern i raised on the intent. i'm happy, then<br>
&lt;Rossen5> ack fantasai<br>
&lt;Zakim> fantasai, you wanted to ask about a11y<br>
&lt;TabAtkins> fantasai: two questions<br>
&lt;TabAtkins> fantasai: for emilio's question, would it make sense to have two different apis? one that returns the highlight and one that filters the ranges?<br>
&lt;dandclark> q+<br>
&lt;TabAtkins> fantasai: if there's use-cases for just getting the highlight, the extra compute doesn't have to be done<br>
&lt;TabAtkins> fantasai: second, seems like we're envisioning some sophisticated interfaces being built. is there a plan for how this would work for keyboard users?<br>
&lt;TabAtkins> fernando: for first, currently there's no extra compute, we already have to go thru the ranges to hit-test anyway<br>
&lt;TabAtkins> fernando: but maybe there's another impl that can be done where it's an extra cost<br>
&lt;TabAtkins> fernando: for second, could you repeat?<br>
&lt;emilio> q+<br>
&lt;TabAtkins> fantasai: [repeats the question]<br>
&lt;TabAtkins> fernando: the API takes two coords, x y, that can be done with keyboard if you get the caret position<br>
&lt;TabAtkins> fantasai: that sounds a lot more complicated. do we think authors will acutally do that?<br>
&lt;schenney> q+<br>
&lt;TabAtkins> q+<br>
&lt;TabAtkins> fernando: hm, that could be something to think about. but i think this is similar to elementsFromPoint... was this a concern there as well?<br>
&lt;TabAtkins> fernando: would be interested to know how that api deals with it, it seems like the same idea<br>
&lt;TabAtkins> fantasai: so i suggest the spec should include a practical example with this API that shows off keyboard usage<br>
&lt;TabAtkins> fantasai: if that ends up being unreasonably complicated, we should solve that somehow<br>
&lt;TabAtkins> fantasai: whether that's altering this api or adding a new one<br>
&lt;fantasai> But in any case the spec should show off best practices<br>
&lt;TabAtkins> emilio: i think the keyboard interface is a lot simploer, you don't need to compute the caret position. the selection api has ranges<br>
&lt;TabAtkins> emilio: at least the range api does have an isPointInRange or something<br>
&lt;Rossen5> ack emilio<br>
&lt;TabAtkins> emilio: so it's actually easier to imlement for keyboard users, they just iterate over the highlights, then the ranges, and see if the caret point is in there<br>
&lt;TabAtkins> emilio: also i don't think AbstractRange has that API, only the live ranges. i think we should fix that.<br>
&lt;TabAtkins> fantasai: so yeah, i think the spec should just have an example of how to do this properly, so people know how to do it<br>
&lt;Rossen5> ack dandclark<br>
&lt;TabAtkins> dandclark: i think we shoudl also take a look at what devs are doing now<br>
&lt;TabAtkins> dandclark: we're just taking this ability into the engine. should look and see if that's already keyboard accessible.<br>
&lt;TabAtkins> fantasai: think the other point from fantasai about two APIs - wasn't sure if we were talkinga bout extra work from author or engine. either case, i think it makes more sense to be just one API.<br>
&lt;TabAtkins> s/fantasai/dandclark/<br>
&lt;emilio> q+<br>
&lt;TabAtkins> dandclark: from engine side we're doing the work anyway, from dev side fi they're getting it all together anyway they can just ignore one<br>
&lt;Rossen5> ack schenney<br>
&lt;dandclark> q+<br>
&lt;TabAtkins> schenney: on the a11y issues, i think it's a broader issue. no way to know in the a11y data if  a word or string is highlighted, i think<br>
&lt;TabAtkins> schenney: i'll look into that and raise an issue if that is a problem<br>
&lt;fantasai> scribe+<br>
&lt;TabAtkins> dandclark: exposing a11y of highlights is something we looked at. different platforms have different ways of exposing it, but OSes do have wayss to expose grammar/spelling/emphasis<br>
&lt;TabAtkins> dandclark: details escape me, they're different between paltforms, but we do expose things to a degree.<br>
&lt;Rossen5> ack TabAtkins<br>
&lt;flackr> q+ to ask about generic api combining things you might want to hit test<br>
&lt;fantasai> TabAtkins: Want to emphasize that this is essentially identical to elementsFromPoint()<br>
&lt;dandclark> TabAtkins: emphasizing that this is identical to elementsFromPoint. Should ensure it's solvable, add example, but that shouldn't be a blocker<br>
&lt;dandclark> ...it's doing the same things this other thing is already doing, and that thing is good on its own merits<br>
&lt;dandclark> q-<br>
&lt;Rossen5> ack emilio<br>
&lt;TabAtkins> emilio: one clarification on perf arg<br>
&lt;TabAtkins> emilio: i agree it's probably not worth two APIs, the common case needs the hit range anyway<br>
&lt;TabAtkins> emilio: my point is just that right now you could stop once you hit *one* range that works, you don't nhave to iterate all the rest<br>
&lt;emilio> https://github.com/whatwg/dom/issues/591<br>
&lt;TabAtkins> emilio: but i think in the common case you'll do it anyway, so no need for a separate api<br>
&lt;TabAtkins> emilio: for keyboards, i just linked to a DOM issue moving a lot of stuff from Range to AbstractRange. should move a lot of the test stuff<br>
&lt;TabAtkins> flackr: dunno if i mentioned it in this group, but i said it in the intent thread. i think we need to think about a more generic hit-testing api that combines the variosu things<br>
&lt;Rossen5> ack flackr<br>
&lt;Zakim> flackr, you wanted to ask about generic api combining things you might want to hit test<br>
&lt;TabAtkins> flackr: i think highlightFromPoint, you onlly get a highlight if the element with the highlight woudl have bene hit<br>
&lt;TabAtkins> flackr: but elementsFromPoint gives you the list in order<br>
&lt;TabAtkins> flackr: could be useful to ahve elements and highlights together, in order. maybe with options to let you test for pointer-events:none, etc<br>
&lt;TabAtkins> flackr: so this doesn't need to block this work, but we should pursue a more general hit-test API so we can deal with interleaved things<br>
&lt;TabAtkins> +1<br>
&lt;TabAtkins> Rossen5: so it sounds like we're agreeing with the proposal<br>
&lt;TabAtkins> Rossen5: there's good feedback i'm hoping editors will take back to the spec, for added clarity if nothing else<br>
&lt;TabAtkins> Rossen5: how it's different from rangesFromPoint(), how it addresses keyboard a11y, etc<br>
&lt;TabAtkins> Rossen5: but that said, any objections to the proposal as outlined?<br>
&lt;TabAtkins> RESOLVED: Accept the proposal in the issue.<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12031#issuecomment-2859227004 using your GitHub account


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

Received on Wednesday, 7 May 2025 16:24:43 UTC