Open
Description
There seem to be at least two different models for hit testing at (x, y)
:
- Treat the hit test location as a pixel, namely, a 1x1 rectangle with top-left corner at
(x, y)
, and then return elements whose boxes have non-zero intersection with the pixel - Treat the hit test location as a zero-sized point at
(x, y)
, and return elements whose boxes contain the point. Note that boxes are considered as left-closed-right-open and top-closed-bottom-open; In other words, a point on the bottom or right edge of a box doesn't hit the box.
The two models have different behaviors when taking subpixels into account. See fiddle https://jsfiddle.net/bgec7tzo/4/, where the behavior in Chrome is different from Firefox/Safari. Chrome uses model 1, while Firefox and Safari seem closer to model 2.
Also note that in some other cases Safari and Firefox behave differently.
So I think we should make it clear how hit testing works with subpixels.
Btw, neither of the models seems fully natural to me:
- In model 1, using a 1x1 pixel coordinated at a non-integer location seems weird
- In model 2, the left-closed-right-open requirement seems artificial, but all browsers follow it so I guess we can't really remove it; This requirement also creates some difficulties when we need to flip the coordinate space for
direction
andwriting-mode