Fixes#1081
* Make sure character dimensions are available right after calling term.open()
* Do not assume var assignments are global anymore, webpack will isolate them
* Use DocumentFragment to build Viewport and helpers before attaching them to the DOM
* Shield term.focus call from crashing when used before term.open
* Measure characters and thread them if they are overlapping
* Fix whitespace
* Use charData and ctx.save/restore, code cleanup
* Fix trailing whitespace
* Corretly inverse foreground and background. Be more conservative when clearing
* add missing space
* Re-enable optimisation with better checks
* Fix insversed check