Make IMEContentObserver observe ParentChainChanged and let IMEStateManager know that
mozAutoDocUpdate does not make it in a document change when container node
of insertBefore has already been removed from the tree. Therefore, once
IMEContentObserver::mRootElement is removed from the DOM tree without a
focus move, IMEContentObserver is notified mutations not in a document change.
Similar situations are handled in IMEStateManager::OnRemoveContent with
emulating a focus change and that will destroy the active IMEContentObserver.
Therefore, if IMEContentObserver::mRootElement is removed, we should emulate
a focus move when IMEStateManager does not have focused element but there
is active IMEContentObserver (that means it is/was in the design mode).
However, checking whether the removed node contains the observing node of the
active IMEContentObserver may be expensive. So, doing expensive things in
IMEStateManager::OnRemoveContent may make mutations slower. Therefore, this
patch makes IMEContentObserver observe ParentChainChanged and it let
IMEStateManager know that with calling its
OnParentChainChangedOfObservingElement. Finally, it calls
IMEStateManager::OnRemoveContent to emulate "blur" (and refocus if it's
required).
Differential Revision: https://phabricator.services.mozilla.com/D218696
bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1911010
gecko-commit: 94b450b0b48767bdd10d69d952ac942a8f9a6168
gecko-reviewers: smaug