Re: [csswg-drafts] [css-highlight-api] Approaches for dispatching highlight pointer events (#7513)

> So highlight would get something like highlightpointerdown/up events? and if one called preventDefault() on those, pointerdown/up (and possible mousedown/up, touchdown/up) events wouldn't fire?

Basically. It wouldn't need to be new event name though (like highlightpointerdown/up); it could just be a separate instance of pointerdown/pointerup that gets delivered to highlights before the pointerdown/up that gets delivered to DOM elements.

> Another thing to remember, if highlights can be accessed from the event, is that we'd need to tweak event state when events pass shadow DOM boundary, or stop propagation at shadow DOM boundary. Highlights in shadow DOM shouldn't be exposed to light DOM. Perhaps the events just wouldn't be composed.

This is a good point. We also need to think this through for `CSS.highlights.highlightsFromPoint()`, though. Would it be a problem if that API returned highlights from inside closed shadow DOMs? In a way that would break shadow DOM encapsulation, but it's not necessarily a new issue since those ranges are available via `CSS.highlights.get()` anyway. So shadow DOM encapsulation is basically already broken as long as there are active Highlights in the shadow.

Currently `document.elementsFromPoint` excludes content inside shadows, so for consistency's sake it would seem appropriate that `highlightsFromPoint` do the same. That would make the API useless in a scenario with shadow DOM though -- and in that case it might be better to go straight to a highlight eventing approach that would support shadow DOM properly.

> To me CSS.highlights.highlightsFromPoint() smells like the minimum viable API. Highlights wouldn't need to be event targets. If we later figure out a good way to dispatch events to Highlights themselves, that could be added separately.

I'm inclined to agree with this, but only if we can work around the potential performance issues and the shadow DOM questions above, and if the lack of ability to coordinate between different highlight libraries doesn't turn out to be a hard requirement.

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


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

Received on Monday, 29 August 2022 22:29:01 UTC