Fix cursor positioning on Safari 6.1 and later

Adapted from http://github.com/ajaxorg/ace/pull/1566