Skip to content

[css-highlight-api] Is a HighlightPointerEvent type needed? #7512

Open
@dandclark

Description

@dandclark

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:

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 Ranges 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 Ranges 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Monday

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions