Refactoring text layer builder

This work is needed for cleaning up the text layer and for separating the text layer builder from the PDF find controller. This PR:

- fixes code style;
- moves constants to the top of the file;
- reduces unnecessary `typeof` usage;
- caches loop variables;
- reduces unnecessary `in` usage;
- uses strict equalities where possible;
- removes an old TODO;
- uses more descriptive variable names;
- removes the `highlightDiv` and `appendText` functions as `appendText` was just a direct call to `appendTextToDiv` and `highlightDiv` has been inlined because in code it is clear what is does, so this saves some function calls;
Could we perhaps reduce this number to e.g. `10000`?