Bug 1377672 - part5: IMEStateManager::OnChangeFocusInternal() should notify IME of blur when focus is moving from a remote process to another process r?m_kato
When focus is moving from a remote process to different process (including to the main process), destroying IMEContentObserver in the focused remote process occurs later. I.e., NOTIFY_IME_OF_BLUR will be notified later. However, it may be too late for new focused process especially when destroying the focused widget.
Therefore, this patch makes IMEStateManager notifies IME of blur in such case.
MozReview-Commit-ID: GkypubVjn3H
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -476,16 +476,32 @@ IMEStateManager::OnChangeFocusInternal(n
}
}
// 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();
}
+ } else {
+ // If there is no active IMEContentObserver, it means that focused content
+ // may be in another process.
+
+ // If focus is moving from current focused remote process to different
+ // process while the process has IME focus too, we need to notify IME of
+ // blur here because it may be too late the blur notification to reach
+ // this process especially when closing active window.
+ if (sFocusedIMETabParent &&
+ !IsSameProcess(sFocusedIMETabParent, newTabParent)) {
+ MOZ_LOG(sISMLog, LogLevel::Info,
+ (" OnChangeFocusInternal(), notifying IME of blur of previous focused "
+ "remote process because it may be too late actual notification to "
+ "reach this process"));
+ NotifyIME(NOTIFY_IME_OF_BLUR, sFocusedIMEWidget, sFocusedIMETabParent);
+ }
}
if (!aPresContext) {
MOZ_LOG(sISMLog, LogLevel::Debug,
(" OnChangeFocusInternal(), "
"no nsPresContext is being activated"));
return NS_OK;
}