Bug 1377672 - part1: IMEStateManager in the main process should destroy active IME content observer when a tab parent takes focus r?m_kato
When focus is moved from the main process to a remote process and there is active IME content observer (i.e., an editor in the main process has focus), IMEStateManager should destroy the active IME content observer because it may cause notifying NOTIFY_IME_OF_BLUR when the main process takes focus again.
MozReview-Commit-ID: BG3eZhxoWBW
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -435,20 +435,37 @@ IMEStateManager::OnChangeFocusInternal(n
if (oldWidget && focusActuallyChanging) {
// If we're deactivating, we shouldn't commit composition forcibly because
// the user may want to continue the composition.
if (aPresContext) {
NotifyIME(REQUEST_TO_COMMIT_COMPOSITION, oldWidget);
}
}
- if (sActiveIMEContentObserver &&
- (aPresContext || !sActiveIMEContentObserver->KeepAliveDuringDeactive()) &&
- !sActiveIMEContentObserver->IsManaging(aPresContext, aContent)) {
- DestroyIMEContentObserver();
+ if (sActiveIMEContentObserver) {
+ // If there is active IMEContentObserver, it means that focused content was
+ // in this process. So, if a tab parent gets focus, it means that the
+ // focused editor in this process is being blurred.
+ if (newTabParent) {
+ DestroyIMEContentObserver();
+ }
+ // If the process is being inactivated, then, IMEContentObserver should
+ // stop observing the contents unless native IME requests to keep
+ // composition even during deactivated.
+ else if (!aPresContext) {
+ if (!sActiveIMEContentObserver->KeepAliveDuringDeactive()) {
+ DestroyIMEContentObserver();
+ }
+ }
+ // Otherwise, i.e., new focused content is in this process, let's check
+ // whether the new focused content is already being managed by the
+ // active IME content observer.
+ else if (!sActiveIMEContentObserver->IsManaging(aPresContext, aContent)) {
+ DestroyIMEContentObserver();
+ }
}
if (!aPresContext) {
MOZ_LOG(sISMLog, LogLevel::Debug,
(" OnChangeFocusInternal(), "
"no nsPresContext is being activated"));
return NS_OK;
}