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

I can think of two ways to expose shadow DOM highlights with `highlightsFromPoint()`.

The first is to handle it like `getInnerHTML()` does for Declarative Shadow DOM, in which it takes an `includeShadowRoots` option as well as a list of closed shadow roots so that highlights inside these can be returned without breaking encapsulation: https://web.dev/declarative-shadow-dom/#serialization.  Highlights could do something similar: 
```js
const hitTestResults = CSS.highlights.highlightsFromPoint({
  includeShadowRoots: true,
  closedRoots: [shadowRoot1, shadowRoot2, ...]
});
```

Alternatively, we could put `highlightsFromPoint()` on [`DocumentOrShadowRoot`](https://dom.spec.whatwg.org/#mixin-documentorshadowroot). When called on a Document, it would return only highlights in that document (not in its shadow roots). When called on a shadow root, it would return only highlights in that shadow, or perhaps highlights in that shadow plus highlights in the document (but not highlights in any nested shadow roots). This is analogous to how `elementsFromPoint()` works in Blink and Gecko today, though the [spec](https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint) doesn't yet reflect that `elementsFromPoint()` is callable on shadow DOM and I see some cross-browser inconsistencies in which elements are returned.

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


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

Received on Tuesday, 13 September 2022 19:30:43 UTC