mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-13 20:14:57 -10:00
`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