Fix mouse handling if the canvas has been scaled via CSS.

This has been extensively discussed in #868. It makes the coordinate matching work if the canvas elements have been scaled. It also has the added benefit of cleaning up the getPointer() calls and related offset calculation, which is now done in one place by getPointer(), rather than each caller doing it for themselves.

This is that patch but applied to the source files.

The second commit extends support to also handle CSS transforms, also discussed in the ticket.