WICG / canvas-place-element

Other
58 stars 3 forks source link

Hit Testing Meta Issue #9

Open schenney-chromium opened 2 months ago

schenney-chromium commented 2 months ago

There are a few concerns about hit testing and APIs that use geometric information (like intersection observer).

The first is that the HTML content that is live in the canvas via placeElement should report geometry information that matches it's location within the canvas within the page. Presumably this also means things like offsetTop should report the real offset, and not the offset relative to the canvas or something else. The various uses should be reviewed as the spec is developed.

A more challenging problem is correctly hit testing when canvas content has been drawn on top of the placed element. How do we know whether the canvas of the element should receive the event? Canvas does not support methods for tracking hit test regions, but maybe it needs to now. Do we need to maintain coverage masks?

khushalsagar commented 1 month ago

There's a few issues brought up above and in other issues/offline conversations. I'll try to summarize them here with some initial thoughts, please add if I missed anything:

khushalsagar commented 1 month ago

Copying over a related issue from https://github.com/whatwg/html/issues/10650

And also things like IME popups - since the element's layout depends on the canvas itself, it is unclear how IME related popups can position themself correctly, if the visual representation on the canvas is in totally different place.

Since the browser anchors IME popups to the where the element is in viewport space, positioning IME popups is related to other APIs where we need to map a point in the rendered element to its corresponding position in the canvas buffer.

chrishtr commented 1 month ago
  • like offsetTop,

What about getBoundingClientRect? That one is affected by transforms, and is often used to find the screen-space rect for an element.

A similar-feeling analysis was done as part of standardizing the zoom CSS property which may be useful in figuring out what to do here.

khushalsagar commented 1 month ago

What about getBoundingClientRect? That one is affected by transforms, and is often used to find the screen-space rect for an element.

That should be affected by where the element is rendered in the canvas, similar to how it's affected by CSS transform.