Bug 1377672 - part1: IMEStateManager in the main process should destroy active IME content observer when a tab parent takes focus r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Sun, 02 Jul 2017 22:00:18 +0900
changeset 605192 0519b4d9316496de963db53597b28598ec0f3d92
parent 605191 52d81035277456e1efd1f218daa9147e57546f8c
child 605193 2f01e62d6867ae1c79aed7c9fdc9b1087a842092
push id67319
push usermasayuki@d-toybox.com
push dateFri, 07 Jul 2017 05:35:43 +0000
reviewersm_kato
bugs1377672
milestone56.0a1
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
dom/events/IMEStateManager.cpp
--- 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;
   }