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;
I'm not sure if it matters in this particular instance, but these expressions aren't actually equal. It needs to be: `textDiv.dataset.isWhitespace !== undefined` (or `textDiv.dataset['isWhitespace'] !== undefined`).