Bug 1377672 - part5: IMEStateManager::OnChangeFocusInternal() should notify IME of blur when focus is moving from a remote process to another process r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 05 Jul 2017 16:26:41 +0900
changeset 605196 327ed1047ead86797267a971a9c2758b318f0424
parent 605195 caba59e091625c356bc0098fff2bf942cfc2bbef
child 636409 cd8091676ce7ba89b90153df484c2a0672ebd2da
push id67319
push usermasayuki@d-toybox.com
push dateFri, 07 Jul 2017 05:35:43 +0000
reviewersm_kato
bugs1377672
milestone56.0a1
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
dom/events/IMEStateManager.cpp
--- 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;
   }