Bug 10599 - JSMouseEvent needs to expose floating-point-precise mouse coordinates
Summary: JSMouseEvent needs to expose floating-point-precise mouse coordinates
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P4 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 10601
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-28 00:41 PDT by Eric Seidel (no email)
Modified: 2007-12-30 06:57 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2006-08-28 00:41:37 PDT
JSMouseEvent needs to expose floating-point-precise mouse coordinates

It might be possible to emulate this using a very large viewport which was heavily scaled, so as to result in multiple coordinates per device pixel.  If the browser internally user floating-point-precise mouse coordinates, that could work.

Better would be to expose real "double" mouse coordinates to web applications.  Without this, it would be very very difficult to write any decent drawing applications for the Web.
Comment 1 Oliver Hunt 2007-12-29 20:01:37 PST
How would that work?  the MouseEvent merely provides the cursor position, If the OS does not provide floating point positions for a mouse -- if the coordinates were fractional that would imply that the cursor could have a position between pixels, which would be useless as (by definition) the user would not be able to distinguish the actual position.

Drawing programs should be maintaining a current view scale, and the inverse should be applied to any mouse actions performed on the current drawing surface (eg. <canvas>) to find the position of a mouse event in the scaled surface.
Comment 2 Eric Seidel (no email) 2007-12-29 21:29:07 PST
Mouse events on Mac OS X do in fact provide floating point coordinates, and at those times the pointing device is in-fact "between pixels".  When you're using a tablet, you want the physical tablet dimensions to line up with some set of dimensions on the screen.  The logical dimensions of the devices don't always match up.  Imagine for example a Cintiq: http://www.wacom.com/cintiq/.  There touching a point on the screen/tablet is expected to correspond with that point in the UI, however when you're drawing, the tablet has higher resolution than the screen and you want that higher resolution to be exposed to your drawing application.  If the OS just snapped the incoming tablet events to the top-left corner of every screen pixel (i.e. integer coordinates), then you'd end up with not as nice of a drawing.

In Mac OS X, you are provided floating point coordinates for every mouse event, and as an application you are expected to floor() those points to find the closest pixel (if you care about snapping to pixels).  I don't think we can expect the same of web apps, so we can't just change the existing screenX, screenY to be floats.  But we should expose floating point coordinates so web apps on something like a cintiq (or iphone!) could make an interesting drawing application with sub-pixel positioning.

Another interesting side-effect of tablet mouse events is that you get *a lot* more of them than you do with a normal pointing device.  This could also be a problem for some web apps.  I'm not sure if we do any mouse event throttling in WebKit currently however.  The iPhone might.