Make mouse handling respect CSS scaling.

Also DRYs getPointer() calls in many places.

See #868.
Also consider CSS transforms when handling mouse.
Fix mouse handling inside a scrollable div.

See also #870, which was incorrectly merged.