`ContentEventHandler` may not replace open/close tags of inline elements and
close tags of block elements with a line break etc. Therefore, one offset may
mean multiple points in the DOM tree. From the DOM tree point of view, every
DOM point may have different meaning and styles. Therefore, if IME sets
`Selection` to current range, we should not update `Selection` with the log of
`ContentEventHandler`. Otherwise, new content will appear at different position
in the DOM tree and it may cause different style text, etc.
`IMEContentObserver` has cache of `Selection` while an editor has focus.
Therefore, for avoiding the query cost of `Selection` for each `eSetSelection`
event, `ContentEventHandler` should be used in `IMEContentObserver` instead if
an instance is available. Therefore, this patch makes `TextComposition`
delegate the handling to `IMEContentObserver` and check `Selection` range only
when `IMEContentObserver` is available. Note that `eSetSelection` is probably
used only when editable element has focus. Therefore, it must be fine to skip
selection range check in the other cases.
Differential Revision: https://phabricator.services.mozilla.com/D171179