[csswg-drafts] [css-highlight-api] Is a HighlightPointerEvent type needed? (#7512)

dandclark has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-highlight-api] Is a HighlightPointerEvent type needed? ==
In #7447 the CSSWG resolved to move forward with developing a spec for handling pointer events in Highlight API.

An initial decision to make about this is whether a new pointer event type is needed, like the following suggested in the [MSEdgeExplainer](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/highlight/events-explainer.md#proposal):

```
interface HighlightPointerEvent : PointerEvent {
    readonly Range range;
}
```

The `Highlight` type would become an `EventTarget` so that developers can add listeners for these events.

```
[Exposed=Window]
interface Highlight : EventTarget {
  constructor(AbstractRange... initialRanges);
  setlike<AbstractRange>;
  attribute long priority;
  attribute HighlightType type;
};
```

With this approach, developers can add a single listener on a `Highlight` that will work for all `Range`s in that `Highlight` group. The event handler can use the event's `range` field to determine which of its ranges was affected by the event.

An alternative is to have the `Range`s receive the events directly. This would require developers to set events on every range, which is would be cumbersome if we generally expect all the ranges in a given `Highlight` group to share the same functionality. It's also not clear in that case how the event handler would know which `Highlight` a given `Range` was associated with. So, I think dispatching against `Highlight` makes more sense.

There are plenty of other open questions around how the event should be dispatched and how event pathing should work for highlights, but in this issue I'm hoping to reach some consensus around whether this basic conception of `HighlightPointerEvent` is the right approach or not.

cc @frivoal @luisjuansp

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7512 using your GitHub account


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

Received on Monday, 18 July 2022 23:42:56 UTC