Bug 1211352 part.3 nsIWidget::GetIMEupdatePreference() for each platform should not request any notifications while a plugin has focus r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 10 Oct 2015 10:21:02 +0900
changeset 300580 4724d4f02b571d73c3571823b53c3ed97794466a
parent 300579 d6fbe14c354aac2711fbd71df40c70901557da03
child 300581 26b4afb254c21a417736ed9215a406eaa4cecf5e
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1211352
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1211352 part.3 nsIWidget::GetIMEupdatePreference() for each platform should not request any notifications while a plugin has focus r=m_kato
widget/android/nsWindow.cpp
widget/cocoa/nsChildView.mm
widget/gtk/IMContextWrapper.cpp
widget/windows/WinIMEHandler.cpp
widget/windows/WinIMEHandler.h
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -2481,16 +2481,21 @@ nsWindow::AddIMETextChange(const IMEChan
         // so we can safely continue the merge starting at dst
         srcIndex = dstIndex;
     }
 }
 
 nsIMEUpdatePreference
 nsWindow::GetIMEUpdatePreference()
 {
+    // While a plugin has focus, nsWindow for Android doesn't need any
+    // notifications.
+    if (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN) {
+      return nsIMEUpdatePreference();
+    }
     return nsIMEUpdatePreference(
         nsIMEUpdatePreference::NOTIFY_SELECTION_CHANGE |
         nsIMEUpdatePreference::NOTIFY_TEXT_CHANGE);
 }
 
 void
 nsWindow::DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect)
 {
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1871,16 +1871,20 @@ nsChildView::ExecuteNativeKeyBinding(Nat
 
   NativeKeyBindings* keyBindings = NativeKeyBindings::GetInstance(aType);
   return keyBindings->Execute(aEvent, aCallback, aCallbackData);
 }
 
 nsIMEUpdatePreference
 nsChildView::GetIMEUpdatePreference()
 {
+  // While a plugin has focus, IMEInputHandler doesn't need any notifications.
+  if (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN) {
+    return nsIMEUpdatePreference();
+  }
   return nsIMEUpdatePreference(nsIMEUpdatePreference::NOTIFY_SELECTION_CHANGE);
 }
 
 NS_IMETHODIMP nsChildView::GetToggledKeyState(uint32_t aKeyCode,
                                               bool* aLEDState)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -272,16 +272,22 @@ IMContextWrapper::~IMContextWrapper()
     }
     MOZ_LOG(gGtkIMLog, LogLevel::Info,
         ("GTKIM: %p ~IMContextWrapper()", this));
 }
 
 nsIMEUpdatePreference
 IMContextWrapper::GetIMEUpdatePreference() const
 {
+    // While a plugin has focus, IMContextWrapper doesn't need any
+    // notifications.
+    if (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN) {
+      return nsIMEUpdatePreference();
+    }
+
     nsIMEUpdatePreference::Notifications notifications =
         nsIMEUpdatePreference::NOTIFY_SELECTION_CHANGE;
     // If it's not enabled, we don't need position change notification.
     if (IsEnabled()) {
         notifications |= nsIMEUpdatePreference::NOTIFY_POSITION_CHANGE;
     }
     nsIMEUpdatePreference updatePreference(notifications);
     // We shouldn't notify IME of selection change caused by changes of
--- a/widget/windows/WinIMEHandler.cpp
+++ b/widget/windows/WinIMEHandler.cpp
@@ -33,20 +33,20 @@ const char* kOskDebugReason = "ui.osk.de
 
 namespace mozilla {
 namespace widget {
 
 /******************************************************************************
  * IMEHandler
  ******************************************************************************/
 
+bool IMEHandler::sPluginHasFocus = false;
 #ifdef NS_ENABLE_TSF
 bool IMEHandler::sIsInTSFMode = false;
 bool IMEHandler::sIsIMMEnabled = true;
-bool IMEHandler::sPluginHasFocus = false;
 bool IMEHandler::sShowingOnScreenKeyboard = false;
 decltype(SetInputScopes)* IMEHandler::sSetInputScopes = nullptr;
 #endif // #ifdef NS_ENABLE_TSF
 
 // static
 void
 IMEHandler::Initialize()
 {
@@ -290,16 +290,22 @@ IMEHandler::NotifyIME(nsWindow* aWindow,
       return NS_ERROR_NOT_IMPLEMENTED;
   }
 }
 
 // static
 nsIMEUpdatePreference
 IMEHandler::GetUpdatePreference()
 {
+  // While a plugin has focus, neither TSFTextStore nor IMMHandler needs
+  // notifications.
+  if (sPluginHasFocus) {
+    return nsIMEUpdatePreference();
+  }
+
 #ifdef NS_ENABLE_TSF
   if (IsTSFAvailable()) {
     return TSFTextStore::GetIMEUpdatePreference();
   }
 #endif //NS_ENABLE_TSF
 
   return IMMHandler::GetIMEUpdatePreference();
 }
--- a/widget/windows/WinIMEHandler.h
+++ b/widget/windows/WinIMEHandler.h
@@ -106,25 +106,26 @@ public:
 #ifdef DEBUG
   /**
    * Returns true when current keyboard layout has IME.  Otherwise, false.
    */
   static bool CurrentKeyboardLayoutHasIME();
 #endif // #ifdef DEBUG
 
 private:
+  static bool sPluginHasFocus;
+
 #ifdef NS_ENABLE_TSF
   static decltype(SetInputScopes)* sSetInputScopes;
   static void SetInputScopeForIMM32(nsWindow* aWindow,
                                     const nsAString& aHTMLInputType);
   static bool sIsInTSFMode;
   // If sIMMEnabled is false, any IME messages are not handled in TSF mode.
   // Additionally, IME context is always disassociated from focused window.
   static bool sIsIMMEnabled;
-  static bool sPluginHasFocus;
   static bool sShowingOnScreenKeyboard;
 
   static bool IsTSFAvailable() { return (sIsInTSFMode && !sPluginHasFocus); }
   static bool IsIMMActive();
 
   static void MaybeShowOnScreenKeyboard();
   static void MaybeDismissOnScreenKeyboard();
   static bool WStringStartsWithCaseInsensitive(const std::wstring& aHaystack,