frontend/html: cursor improvements

Adds a faster algorithm when moving cursor.

The cursor is now moved using DOM traversal. It's faster and it's the first step to support selection ranges.