Bug 840409 part.8 Implement widget::IMEHandler::NotifyIMEOfTextChange() r=jimm
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 25 Feb 2013 13:00:06 +0900
changeset 122865 59038ecbd55b236de6ae21b001e53da0daf4eb99
parent 122864 7a50a2b48d03a6d8f43adf05700d5b03bd032ecc
child 122866 398295b6d0e4397aaf0b5f4f3437a57a2a763396
push id1387
push userphilringnalda@gmail.com
push dateTue, 26 Feb 2013 22:32:56 +0000
treeherderfx-team@ad4cc4e97774 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs840409
milestone22.0a1
Bug 840409 part.8 Implement widget::IMEHandler::NotifyIMEOfTextChange() r=jimm
widget/windows/WinIMEHandler.cpp
widget/windows/WinIMEHandler.h
widget/windows/nsTextStore.h
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/widget/windows/WinIMEHandler.cpp
+++ b/widget/windows/WinIMEHandler.cpp
@@ -135,16 +135,31 @@ IMEHandler::NotifyIME(nsWindow* aWindow,
     case REQUEST_TO_CANCEL_COMPOSITION:
       nsIMM32Handler::CancelComposition(aWindow);
       return NS_OK;
     default:
       return NS_ERROR_NOT_IMPLEMENTED;
   }
 }
 
+// static
+nsresult
+IMEHandler::NotifyIMEOfTextChange(uint32_t aStart,
+                                  uint32_t aOldEnd,
+                                  uint32_t aNewEnd)
+{
+#ifdef NS_ENABLE_TSF
+  if (sIsInTSFMode) {
+    return nsTextStore::OnTextChange(aStart, aOldEnd, aNewEnd);
+  }
+#endif //NS_ENABLE_TSF
+
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
 #ifdef DEBUG
 // static
 bool
 IMEHandler::CurrentKeyboardLayoutHasIME()
 {
 #ifdef NS_ENABLE_TSF
   if (sIsInTSFMode) {
     return nsTextStore::CurrentKeyboardLayoutHasIME();
--- a/widget/windows/WinIMEHandler.h
+++ b/widget/windows/WinIMEHandler.h
@@ -50,16 +50,23 @@ public:
 
   /**
    * Notifies IME of the notification (a request or an event).
    */
   static nsresult NotifyIME(nsWindow* aWindow,
                             NotificationToIME aNotification);
 
   /**
+   * Notifies IME of text change in the focused editable content.
+   */
+  static nsresult NotifyIMEOfTextChange(uint32_t aStart,
+                                        uint32_t aOldEnd,
+                                        uint32_t aNewEnd);
+
+  /**
    * "Kakutei-Undo" of ATOK or WXG (both of them are Japanese IME) causes
    * strange WM_KEYDOWN/WM_KEYUP/WM_CHAR message pattern.  So, when this
    * returns true, the caller needs to be careful for processing the messages.
    */
   static bool IsDoingKakuteiUndo(HWND aWnd);
 
 #ifdef DEBUG
   /**
--- a/widget/windows/nsTextStore.h
+++ b/widget/windows/nsTextStore.h
@@ -114,23 +114,23 @@ public:
 
   static nsresult OnFocusChange(bool aGotFocus,
                                 nsWindowBase* aFocusedWidget,
                                 IMEState::Enabled aIMEEnabled);
   static nsresult OnTextChange(uint32_t aStart,
                                uint32_t aOldEnd,
                                uint32_t aNewEnd)
   {
-    if (!sTsfTextStore) return NS_OK;
+    NS_ENSURE_TRUE(sTsfTextStore, NS_ERROR_NOT_AVAILABLE);
     return sTsfTextStore->OnTextChangeInternal(aStart, aOldEnd, aNewEnd);
   }
 
   static void     OnTextChangeMsg(void)
   {
-    if (!sTsfTextStore) return;
+    NS_ENSURE_TRUE_VOID(sTsfTextStore);
     // Notify TSF text change
     // (see comments on WM_USER_TSF_TEXTCHANGE in nsTextStore.h)
     sTsfTextStore->OnTextChangeMsgInternal();
   }
 
   static nsresult OnSelectionChange(void)
   {
     NS_ENSURE_TRUE(sTsfTextStore, NS_ERROR_NOT_AVAILABLE);
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -7469,25 +7469,23 @@ nsWindow::GetToggledKeyState(uint32_t aK
 
 NS_IMETHODIMP
 nsWindow::OnIMEFocusChange(bool aFocus)
 {
   return IMEHandler::NotifyIME(this, aFocus ? NOTIFY_IME_OF_FOCUS :
                                               NOTIFY_IME_OF_BLUR);
 }
 
-#ifdef NS_ENABLE_TSF
 NS_IMETHODIMP
 nsWindow::OnIMETextChange(uint32_t aStart,
                           uint32_t aOldEnd,
                           uint32_t aNewEnd)
 {
-  return nsTextStore::OnTextChange(aStart, aOldEnd, aNewEnd);
-}
-#endif // #ifdef NS_ENABLE_TSF
+  return IMEHandler::NotifyIMEOfTextChange(aStart, aOldEnd, aNewEnd);
+}
 
 NS_IMETHODIMP
 nsWindow::OnIMESelectionChange(void)
 {
   return IMEHandler::NotifyIME(this, NOTIFY_IME_OF_SELECTION_CHANGE);
 }
 
 #ifdef NS_ENABLE_TSF
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -172,19 +172,17 @@ public:
   NS_IMETHOD              RegisterTouchWindow();
   NS_IMETHOD              UnregisterTouchWindow();
 #ifdef MOZ_XUL
   virtual void            SetTransparencyMode(nsTransparencyMode aMode);
   virtual nsTransparencyMode GetTransparencyMode();
   virtual void            UpdateOpaqueRegion(const nsIntRegion& aOpaqueRegion);
 #endif // MOZ_XUL
   NS_IMETHOD              OnIMEFocusChange(bool aFocus);
-#ifdef NS_ENABLE_TSF
   NS_IMETHOD              OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd);
-#endif // NS_ENABLE_TSF
   NS_IMETHOD              OnIMESelectionChange(void);
 #ifdef NS_ENABLE_TSF
   virtual nsIMEUpdatePreference GetIMEUpdatePreference();
 #endif // NS_ENABLE_TSF
   NS_IMETHOD              GetNonClientMargins(nsIntMargin &margins);
   NS_IMETHOD              SetNonClientMargins(nsIntMargin &margins);
   void                    SetDrawsInTitlebar(bool aState);