The test calls hiddenInput.focus(), but in reality, nothing external to
the editor can trigger this. I'd rather just have
bringHiddenInputIntoView() called in one place, but this is insurance.
This is slower than the position cache in the best case, but faster
in the worst and average case. With this, you can search for a space
in find and replace, and still scroll the buffer.
In editor.coffee, there are 10,500 spaces. To highlight all of them,
the previous cache method took 7 seconds, this takes 2 when the cache
is empty, and about 10ms when the entire file is cached.
We know it's visible if it is on the dom and doesn't have
display == none set. This is an order of magnitude faster than the
default implementation which calls getComputedStyle()
This is is faster and simpler than the old method. Running each function
20,000 times yielded these results:
Old: 3750ms
This method: 1523ms
By looking up each char's width in a dict: 29ms
Previously this was set via a style tag which ate up a lot of spec
time and seemed to be functionally equivalent to just setting the
style directly on the element instead of finding and adding/removing
style tags.
Previously the input could be offscreen depend on the scroll
position of the editor and this would cause a scroll event to
occur when the input gained focused causing the editor rendering
to go out of sync.
On OS X, press and hold `c` could show an accent menu to replace `c` with
accented ones like `ć`, there is no corresponding events in W3C, so we
detected it by checking whether the text in input box are selected (this
is how Chrome implemented this feature).
And also note that IME inputs were handled the same way in Chrome, the
compostion text would be marked as selected and got replaced with final
inputs. However the compostion text won't trigger textInput event, so
it's distinguished by checking whether the hiddenInput's value are
changed by Chrome.
Fixesatom/atom-shell#50.
The composition text should only show on screen temporarily and gets
disappered when input is cancelled or done. We simply mark the
composition as selected, so it can not only indicate this is composition
text instead of normal text, but also updates the composition without
adding new interfaces.