frontend/html: selection improvements

Adds a fastest 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.