Properly handle selection and highlighting even if the text flow is bad.
We do this by re-ordering the text elements if we can find a better order.  We already find the nearest right and nearest bottom neighbor for each text element.  Now we put them into a link list in order if we're sure we're not dealing with column text.

Note that this only works intra-line. It's much harder to deal with line-to-line. (Although possible with another pass through the data).

Also, a comparatively minor change.  If a text element is just whitespace, still turn it into a div, because it is used for copy/paste.