Bug 449012 – Remove legacy Reconversion/QueryCaretRect Events r=ere+roc, sr=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 09 Aug 2008 11:46:30 +0900
changeset 16525 44089683e77dc62d631b36d231c3a0564d4650d4
parent 16524 29f2c16ef6e2b91975b6e9277d9e4e7b99c6aa95
child 16526 a7b2f76a6ab8bae160d508f9f5b33ab7952ed53e
push id1108
push usermasayuki@d-toybox.com
push dateSat, 09 Aug 2008 02:47:37 +0000
treeherdermozilla-central@44089683e77d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersere, roc
bugs449012
milestone1.9.1a2pre
Bug 449012 – Remove legacy Reconversion/QueryCaretRect Events r=ere+roc, sr=roc
content/events/public/nsIPrivateCompositionEvent.h
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMUIEvent.cpp
content/events/src/nsDOMUIEvent.h
content/events/src/nsEventDispatcher.cpp
content/events/src/nsEventListenerManager.cpp
dom/public/coreEvents/nsIDOMCompositionListener.h
editor/idl/nsIEditorIMESupport.idl
editor/libeditor/base/nsEditor.cpp
editor/libeditor/text/nsEditorEventListeners.cpp
editor/libeditor/text/nsEditorEventListeners.h
editor/libeditor/text/nsPlaintextEditor.cpp
editor/libeditor/text/nsPlaintextEditor.h
toolkit/components/satchel/src/nsFormFillController.cpp
toolkit/components/satchel/src/nsFormFillController.h
view/src/nsViewManager.cpp
widget/public/nsEvent.h
widget/public/nsGUIEvent.h
widget/src/windows/nsWindow.cpp
widget/src/windows/nsWindow.h
--- a/content/events/public/nsIPrivateCompositionEvent.h
+++ b/content/events/public/nsIPrivateCompositionEvent.h
@@ -36,28 +36,26 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsIPrivateCompositionEvent_h__
 #define nsIPrivateCompositionEvent_h__
 
 #include "nsEvent.h"
 #include "nsISupports.h"
 
-// {889792DC-22D8-4d1a-AC3D-58AD7DEBA17B}
+// {901B82D5-67C0-45ad-86AE-AB9A6BD74111}
 #define NS_IPRIVATECOMPOSITIONEVENT_IID	\
-{ 0x889792dc, 0x22d8, 0x4d1a, \
-{ 0xac, 0x3d, 0x58, 0xad, 0x7d, 0xeb, 0xa1, 0x7b }}
+{ 0x901b82d5, 0x67c0, 0x45ad, \
+{ 0x86, 0xae, 0xab, 0x9a, 0x6b, 0xd7, 0x41, 0x11 } }
 
 class nsIPrivateCompositionEvent : public nsISupports {
 
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRIVATECOMPOSITIONEVENT_IID)
 
   NS_IMETHOD GetCompositionReply(struct nsTextEventReply** aReply) = 0;
-  NS_IMETHOD GetReconversionReply(nsReconversionEventReply** aReply) = 0;
-  NS_IMETHOD GetQueryCaretRectReply(nsQueryCaretRectEventReply** aReply) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrivateCompositionEvent,
                               NS_IPRIVATECOMPOSITIONEVENT_IID)
 
 #endif // nsIPrivateCompositionEvent_h__
 
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -783,22 +783,16 @@ NS_METHOD nsDOMEvent::DuplicatePrivateDa
       break;
     }
     case NS_COMPOSITION_EVENT:
     {
       newEvent = new nsCompositionEvent(PR_FALSE, msg, nsnull);
       isInputEvent = PR_TRUE;
       break;
     }
-    case NS_RECONVERSION_EVENT:
-    {
-      newEvent = new nsReconversionEvent(PR_FALSE, msg, nsnull);
-      isInputEvent = PR_TRUE;
-      break;
-    }
     case NS_MOUSE_SCROLL_EVENT:
     {
       nsMouseScrollEvent* mouseScrollEvent =
         new nsMouseScrollEvent(PR_FALSE, msg, nsnull);
       NS_ENSURE_TRUE(mouseScrollEvent, NS_ERROR_OUT_OF_MEMORY);
       isInputEvent = PR_TRUE;
       nsMouseScrollEvent* oldMouseScrollEvent =
         static_cast<nsMouseScrollEvent*>(mEvent);
@@ -880,22 +874,16 @@ NS_METHOD nsDOMEvent::DuplicatePrivateDa
       break;
     }
     case NS_UI_EVENT:
     {
       newEvent = new nsUIEvent(PR_FALSE, msg,
                                static_cast<nsUIEvent*>(mEvent)->detail);
       break;
     }
-    case NS_QUERYCARETRECT_EVENT:
-    {
-      newEvent = new nsQueryCaretRectEvent(PR_FALSE, msg, nsnull);
-      isInputEvent = PR_TRUE;
-      break;
-    }
     case NS_PAGETRANSITION_EVENT:
     {
       newEvent =
         new nsPageTransitionEvent(PR_FALSE, msg,
                                   ((nsPageTransitionEvent*) mEvent)->persisted);
       break;
     }
 #ifdef MOZ_SVG
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -365,52 +365,27 @@ nsDOMUIEvent::GetPreventDefault(PRBool* 
   NS_ENSURE_ARG_POINTER(aReturn);
   *aReturn = mEvent && (mEvent->flags & NS_EVENT_FLAG_NO_DEFAULT);
 
   return NS_OK;
 }
 
 NS_METHOD nsDOMUIEvent::GetCompositionReply(nsTextEventReply** aReply)
 {
-  if((mEvent->eventStructType == NS_RECONVERSION_EVENT) ||
-     (mEvent->message == NS_COMPOSITION_START) ||
+  if((mEvent->message == NS_COMPOSITION_START) ||
      (mEvent->message == NS_COMPOSITION_QUERY))
   {
     *aReply = &(static_cast<nsCompositionEvent*>(mEvent)->theReply);
     return NS_OK;
   }
   *aReply = nsnull;
   return NS_ERROR_FAILURE;
 }
 
 NS_METHOD
-nsDOMUIEvent::GetReconversionReply(nsReconversionEventReply** aReply)
-{
-  if (mEvent->eventStructType == NS_RECONVERSION_EVENT)
-  {
-    *aReply = &(static_cast<nsReconversionEvent*>(mEvent)->theReply);
-    return NS_OK;
-  }
-  *aReply = nsnull;
-  return NS_ERROR_FAILURE;
-}
-
-NS_METHOD
-nsDOMUIEvent::GetQueryCaretRectReply(nsQueryCaretRectEventReply** aReply)
-{
-  if (mEvent->eventStructType == NS_QUERYCARETRECT_EVENT)
-  {
-    *aReply = &(static_cast<nsQueryCaretRectEvent*>(mEvent)->theReply);
-    return NS_OK;
-  }
-  *aReply = nsnull;
-  return NS_ERROR_FAILURE;
-}
-
-NS_METHOD
 nsDOMUIEvent::DuplicatePrivateData()
 {
   mClientPoint = GetClientPoint();
   mLayerPoint = GetLayerPoint();
   mPagePoint = GetPagePoint();
   // GetScreenPoint converts mEvent->refPoint to right coordinates.
   nsPoint screenPoint = GetScreenPoint();
   nsresult rv = nsDOMEvent::DuplicatePrivateData();
--- a/content/events/src/nsDOMUIEvent.h
+++ b/content/events/src/nsDOMUIEvent.h
@@ -62,18 +62,16 @@ public:
   // nsIDOMNSUIEvent Interface
   NS_DECL_NSIDOMNSUIEVENT
 
   // nsIPrivateDOMEvent interface
   NS_IMETHOD DuplicatePrivateData();
   
   // nsIPrivateCompositionEvent interface
   NS_IMETHOD GetCompositionReply(nsTextEventReply** aReply);
-  NS_IMETHOD GetReconversionReply(nsReconversionEventReply** aReply);
-  NS_IMETHOD GetQueryCaretRectReply(nsQueryCaretRectEventReply** aReply);
   
   // Forward to nsDOMEvent
   NS_FORWARD_TO_NSDOMEVENT
 
 protected:
 
   // Internal helper functions
   nsPoint GetClientPoint();
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -557,18 +557,16 @@ nsEventDispatcher::CreateEvent(nsPresCon
 
   if (aEvent) {
     switch(aEvent->eventStructType) {
     case NS_MUTATION_EVENT:
       return NS_NewDOMMutationEvent(aDOMEvent, aPresContext,
                                     static_cast<nsMutationEvent*>(aEvent));
     case NS_GUI_EVENT:
     case NS_COMPOSITION_EVENT:
-    case NS_RECONVERSION_EVENT:
-    case NS_QUERYCARETRECT_EVENT:
     case NS_SCROLLPORT_EVENT:
       return NS_NewDOMUIEvent(aDOMEvent, aPresContext,
                               static_cast<nsGUIEvent*>(aEvent));
     case NS_KEY_EVENT:
       return NS_NewDOMKeyboardEvent(aDOMEvent, aPresContext,
                                     static_cast<nsKeyEvent*>(aEvent));
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -220,21 +220,17 @@ static const EventDispatchData sContextM
 };
 
 static const EventDispatchData sCompositionEvents[] = {
   { NS_COMPOSITION_START,
     HANDLER(&nsIDOMCompositionListener::HandleStartComposition)  },
   { NS_COMPOSITION_END,
     HANDLER(&nsIDOMCompositionListener::HandleEndComposition)    },
   { NS_COMPOSITION_QUERY,
-    HANDLER(&nsIDOMCompositionListener::HandleQueryComposition)  },
-  { NS_RECONVERSION_QUERY,
-    HANDLER(&nsIDOMCompositionListener::HandleQueryReconversion) },
-  { NS_QUERYCARETRECT,
-    HANDLER(&nsIDOMCompositionListener::HandleQueryCaretRect)    }
+    HANDLER(&nsIDOMCompositionListener::HandleQueryComposition)  }
 };
 
 static const EventDispatchData sTextEvents[] = {
   { NS_TEXT_TEXT, HANDLER(&nsIDOMTextListener::HandleText) }
 };
 
 static const EventDispatchData sKeyEvents[] = {
   { NS_KEY_UP,    HANDLER(&nsIDOMKeyListener::KeyUp)    },
--- a/dom/public/coreEvents/nsIDOMCompositionListener.h
+++ b/dom/public/coreEvents/nsIDOMCompositionListener.h
@@ -39,31 +39,29 @@
 #define nsIDOMCompositionListener_h__
 
 #include "nsIDOMEvent.h"
 #include "nsIDOMEventListener.h"
 
 /*
  * Key pressed / released / typed listener interface.
  */
-// {F14B6491-E95B-11d2-9E85-0060089FE59B}
+// {93A5A335-AA51-4d32-977D-3680B7722AD5}
 #define NS_IDOMCOMPOSITIONLISTENER_IID	\
-{ 0xf14b6491, 0xe95b, 0x11d2, \
-{ 0x9e, 0x85, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } }
+{ 0x93a5a335, 0xaa51, 0x4d32, \
+{ 0x97, 0x7d, 0x36, 0x80, 0xb7, 0x72, 0x2a, 0xd5 } }
 
 
 class nsIDOMCompositionListener : public nsIDOMEventListener {
 
 public:
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMCOMPOSITIONLISTENER_IID)
 
   NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent) = 0;
   NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent) = 0;
   NS_IMETHOD HandleQueryComposition(nsIDOMEvent* aCompositionEvent) = 0;
-  NS_IMETHOD HandleQueryReconversion(nsIDOMEvent* aCompositionEvent) = 0;
-  NS_IMETHOD HandleQueryCaretRect(nsIDOMEvent* aCompositionEvent) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMCompositionListener,
                               NS_IDOMCOMPOSITIONLISTENER_IID)
 
 #endif // nsIDOMCompositionListener_h__
--- a/editor/idl/nsIEditorIMESupport.idl
+++ b/editor/idl/nsIEditorIMESupport.idl
@@ -37,27 +37,23 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 #include "domstubs.idl"
 
 %{C++
 class nsIPrivateTextRangeList;
 struct nsTextEventReply;
-struct nsReconversionEventReply;
-struct nsQueryCaretRectEventReply;
 %}
 
 [ptr] native nsIPrivateTextRangeListPtr(nsIPrivateTextRangeList);
 [ptr] native nsTextEventReplyPtr(nsTextEventReply);
-[ptr] native nsReconversionEventReplyPtr(nsReconversionEventReply);
-[ptr] native nsQueryCaretRectEventReplyPtr(nsQueryCaretRectEventReply);
 
 
-[scriptable, uuid(ce1c0424-c3c0-44b0-97d6-df12deb19d45)]
+[scriptable, uuid(57032dcb-e8c7-4eb6-8ec6-a0f8e300809d)]
 
 interface nsIEditorIMESupport : nsISupports
 {
 
 
   /**
    * beginComposition(nsTextEventReply* aReply) Handles the start of inline input composition.
    */
@@ -85,40 +81,16 @@ interface nsIEditorIMESupport : nsISuppo
 
   /**
    * forceCompositionEnd() force the composition end
    */
 
   void forceCompositionEnd();
 
   /**
-   * getReconversionString()  Get the reconvertion string
-   */
-
-  [noscript] void getReconversionString(in nsReconversionEventReplyPtr aReply);
-
-  /**
-   * Notify for IME when the editor got focus.
-   */
-
-  void notifyIMEOnFocus();
-
-  /**
-   * Notify for IME when the editor lost focus.
-   */
-
-  void notifyIMEOnBlur();
-
-  /**
-   * getQueryCaretRect()  Get the query caret rect
-   */
-
-  [noscript] void getQueryCaretRect(in nsQueryCaretRectEventReplyPtr aReply);
-
-  /**
    * Get preferred IME status of current widget.
    */
 
   [noscript] void getPreferredIMEState(out unsigned long aState);
 
   /**
    * whether this editor has active IME transaction
    */
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -2143,28 +2143,16 @@ nsEditor::ForceCompositionEnd()
     if (NS_FAILED(res)) 
       return res;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEditor::NotifyIMEOnFocus()
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsEditor::NotifyIMEOnBlur()
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsEditor::GetPreferredIMEState(PRUint32 *aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
   *aState = nsIContent::IME_STATUS_ENABLE;
 
   PRUint32 flags;
   nsresult rv = GetFlags(&flags);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -2208,51 +2196,16 @@ nsEditor::GetPreferredIMEState(PRUint32 
 NS_IMETHODIMP
 nsEditor::GetComposing(PRBool* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = IsIMEComposing();
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsEditor::GetReconversionString(nsReconversionEventReply* aReply)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-nsEditor::GetQueryCaretRect(nsQueryCaretRectEventReply* aReply)
-{
-  nsCOMPtr<nsISelection> selection;
-  nsresult rv = GetSelection(getter_AddRefs(selection));
-  if (NS_FAILED(rv))
-    return rv;
-
-  if (!mPresShellWeak)
-    return NS_ERROR_NOT_INITIALIZED;
-
-  nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
-  if (!ps)
-    return NS_ERROR_NOT_INITIALIZED;
-
-  nsRefPtr<nsCaret> caretP;
-  rv = ps->GetCaret(getter_AddRefs(caretP));
-
-  if (NS_FAILED(rv) || !caretP)
-    return rv;
-
-  PRBool cursorIsCollapsed;
-  rv = caretP->GetCaretCoordinates(nsCaret::eIMECoordinates, selection,
-                                   &aReply->mCaretRect, &cursorIsCollapsed, nsnull);
-  if (NS_SUCCEEDED(rv))
-    aReply->mRectIsValid = PR_TRUE;
-  return rv;
-}
-
 #ifdef XP_MAC
 #pragma mark -
 #pragma mark  public nsEditor methods 
 #pragma mark -
 #endif
 /* Non-interface, public methods */
 
 
--- a/editor/libeditor/text/nsEditorEventListeners.cpp
+++ b/editor/libeditor/text/nsEditorEventListeners.cpp
@@ -865,53 +865,16 @@ nsresult
 nsTextEditorCompositionListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
 {
 #ifdef DEBUG_IME
    printf("nsTextEditorCompositionListener::HandleEndComposition\n");
 #endif
    return mEditor->EndComposition();
 }
 
-
-nsresult
-nsTextEditorCompositionListener::HandleQueryReconversion(nsIDOMEvent* aReconversionEvent)
-{
-#ifdef DEBUG_IME
-  printf("nsTextEditorCompositionListener::HandleQueryReconversion\n");
-#endif
-  nsCOMPtr<nsIPrivateCompositionEvent> pCompositionEvent = do_QueryInterface(aReconversionEvent);
-  if (!pCompositionEvent)
-    return NS_ERROR_FAILURE;
-
-  nsReconversionEventReply* eventReply;
-  nsresult rv = pCompositionEvent->GetReconversionReply(&eventReply);
-  if (NS_FAILED(rv))
-    return rv;
-
-  return mEditor->GetReconversionString(eventReply);
-}
-
-nsresult
-nsTextEditorCompositionListener::HandleQueryCaretRect(nsIDOMEvent* aQueryCaretRectEvent)
-{
-#ifdef DEBUG_IME
-  printf("nsTextEditorCompositionListener::HandleQueryCaretRect\n");
-#endif
-  nsCOMPtr<nsIPrivateCompositionEvent> pCompositionEvent = do_QueryInterface(aQueryCaretRectEvent);
-  if (!pCompositionEvent)
-    return NS_ERROR_FAILURE;
-
-  nsQueryCaretRectEventReply* eventReply;
-  nsresult rv = pCompositionEvent->GetQueryCaretRectReply(&eventReply);
-  if (NS_FAILED(rv))
-    return rv;
-
-  return mEditor->GetQueryCaretRect(eventReply);
-}
-
 /*
  * Factory functions
  */
 
 
 
 nsresult 
 NS_NewEditorKeyListener(nsIDOMEventListener ** aInstancePtrResult, 
@@ -1124,17 +1087,16 @@ nsTextEditorFocusListener::Focus(nsIDOME
   if (!IsTargetFocused(target))
     return NS_OK;
 
   mIsFocused = PR_TRUE;
 
   // turn on selection and caret
   if (mEditor)
   {
-    nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
     PRUint32 flags;
     mEditor->GetFlags(&flags);
     if (! (flags & nsIPlaintextEditor::eEditorDisabledMask))
     { // only enable caret and selection if the editor is not disabled
       nsCOMPtr<nsIContent> content = do_QueryInterface(target);
 
       PRBool targetIsEditableDoc = PR_FALSE;
       nsCOMPtr<nsIContent> editableRoot;
@@ -1183,37 +1145,27 @@ nsTextEditorFocusListener::Focus(nsIDOME
           PRInt32 rangeCount;
           selection->GetRangeCount(&rangeCount);
           if (rangeCount == 0) {
             mEditor->BeginningOfDocument();
           }
         }
       }
     }
-
-    if (imeEditor)
-      imeEditor->NotifyIMEOnFocus();
   }
   return NS_OK;
 }
 
 nsresult
 nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
 {
   NS_ENSURE_ARG(aEvent);
   // turn off selection and caret
   if (mEditor && mIsFocused)
   {
-    // when imeEditor exists, call ForceCompositionEnd() to tell
-    // the input focus is leaving first
-    nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
-    if (imeEditor) {
-      imeEditor->NotifyIMEOnBlur();
-    }
-
     nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
     if (editor)
     {
       nsCOMPtr<nsISelectionController>selCon;
       editor->GetSelectionController(getter_AddRefs(selCon));
       if (selCon)
       {
         nsCOMPtr<nsISelection> selection;
--- a/editor/libeditor/text/nsEditorEventListeners.h
+++ b/editor/libeditor/text/nsEditorEventListeners.h
@@ -143,18 +143,16 @@ public:
 /*interfaces for addref and release and queryinterface*/
   NS_DECL_ISUPPORTS
 
 /*BEGIN implementations of textevent handler interface*/
   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
   NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
   NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent);
   NS_IMETHOD HandleQueryComposition(nsIDOMEvent* aCompositionEvent);
-  NS_IMETHOD HandleQueryReconversion(nsIDOMEvent* aReconvertionEvent);
-  NS_IMETHOD HandleQueryCaretRect(nsIDOMEvent* aQueryCaretRectEvent);
 /*END implementations of textevent handler interface*/
 
 protected:
   nsIEditorIMESupport*     mEditor;		// weak reference
 };
 
 
 /** editor Implementation of the MouseListener interface
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -1745,50 +1745,16 @@ nsPlaintextEditor::SetCompositionString(
     NS_ASSERTION(NS_SUCCEEDED(result), "cannot get caret position");
     if (NS_SUCCEEDED(result) && view)
       aReply->mReferenceWidget = view->GetWidget();
   }
 
   return result;
 }
 
-NS_IMETHODIMP 
-nsPlaintextEditor::GetReconversionString(nsReconversionEventReply* aReply)
-{
-  nsCOMPtr<nsISelection> selection;
-  nsresult res = GetSelection(getter_AddRefs(selection));
-  if (NS_FAILED(res)) return res;
-  if (!selection) return NS_ERROR_FAILURE;
-
-  // XXX get the first range in the selection.  Since it is
-  // unclear what to do if reconversion happens with a 
-  // multirange selection, we will ignore any additional ranges.
-  
-  nsCOMPtr<nsIDOMRange> range;
-  res = selection->GetRangeAt(0, getter_AddRefs(range));
-  if (NS_FAILED(res)) return res;
-  if (!range) return NS_ERROR_FAILURE;
-  
-  nsAutoString textValue;
-  res = range->ToString(textValue);
-  if (NS_FAILED(res))
-    return res;
-  
-  aReply->mReconversionString = (PRUnichar*) nsMemory::Clone(textValue.get(),
-                                                                (textValue.Length() + 1) * sizeof(PRUnichar));
-  if (!aReply->mReconversionString)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  if (textValue.IsEmpty())
-    return NS_OK;
-
-  // delete the selection
-  return DeleteSelection(eNone);
-}
-
 #ifdef XP_MAC
 #pragma mark -
 #pragma mark  nsEditor overrides 
 #pragma mark -
 #endif
 
 
 /** All editor operations which alter the doc should be prefaced
--- a/editor/libeditor/text/nsPlaintextEditor.h
+++ b/editor/libeditor/text/nsPlaintextEditor.h
@@ -81,19 +81,19 @@ public:
 
   /* ------------ nsIPlaintextEditor methods -------------- */
   NS_DECL_NSIPLAINTEXTEDITOR
 
   /* ------------ nsIEditorMailSupport overrides -------------- */
   NS_DECL_NSIEDITORMAILSUPPORT
 
   /* ------------ nsIEditorIMESupport overrides -------------- */
-  
-  NS_IMETHOD SetCompositionString(const nsAString & aCompositionString, nsIPrivateTextRangeList * aTextRange, nsTextEventReply * aReply);
-  NS_IMETHOD GetReconversionString(nsReconversionEventReply* aReply);
+  NS_IMETHOD SetCompositionString(const nsAString &aCompositionString,
+                                  nsIPrivateTextRangeList *aTextRange,
+                                  nsTextEventReply *aReply);
 
   /* ------------ Overrides of nsEditor interface methods -------------- */
   NS_IMETHOD BeginComposition(nsTextEventReply* aReply);
   NS_IMETHOD SetAttributeOrEquivalent(nsIDOMElement * aElement,
                                       const nsAString & aAttribute,
                                       const nsAString & aValue,
                                       PRBool aSuppressTransaction);
   NS_IMETHOD RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
--- a/toolkit/components/satchel/src/nsFormFillController.cpp
+++ b/toolkit/components/satchel/src/nsFormFillController.cpp
@@ -753,28 +753,16 @@ nsFormFillController::HandleEndCompositi
 }
 
 NS_IMETHODIMP
 nsFormFillController::HandleQueryComposition(nsIDOMEvent* aCompositionEvent)
 {
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsFormFillController::HandleQueryReconversion(nsIDOMEvent* aCompositionEvent)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsFormFillController::HandleQueryCaretRect(nsIDOMEvent* aCompostionEvent)
-{
-  return NS_OK;
-}
-
 ////////////////////////////////////////////////////////////////////////
 //// nsIDOMFormListener
 
 NS_IMETHODIMP
 nsFormFillController::Submit(nsIDOMEvent* aEvent)
 {
   if (mFocusedInput)
     StopControllingInput();
--- a/toolkit/components/satchel/src/nsFormFillController.h
+++ b/toolkit/components/satchel/src/nsFormFillController.h
@@ -86,18 +86,16 @@ public:
   NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
   NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
   NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
 
   // nsIDOMCompositionListener
   NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
   NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent);
   NS_IMETHOD HandleQueryComposition(nsIDOMEvent* aCompositionEvent);
-  NS_IMETHOD HandleQueryReconversion(nsIDOMEvent* aCompositionEvent);
-  NS_IMETHOD HandleQueryCaretRect(nsIDOMEvent* aCompositionEvent);
 
   // nsIDOMFormListener
   NS_IMETHOD Submit(nsIDOMEvent* aEvent);
   NS_IMETHOD Reset(nsIDOMEvent* aEvent);
   NS_IMETHOD Change(nsIDOMEvent* aEvent);
   NS_IMETHOD Select(nsIDOMEvent* aEvent);
   NS_IMETHOD Input(nsIDOMEvent* aEvent);
 
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -1346,20 +1346,16 @@ NS_IMETHODIMP nsViewManager::DispatchEve
               ConvertRectAppUnitsToIntPixels(
                 ((nsTextEvent*)aEvent)->theReply.mCursorPosition, p2a);
               break;
             case NS_COMPOSITION_START:
             case NS_COMPOSITION_QUERY:
               ConvertRectAppUnitsToIntPixels(
                 ((nsCompositionEvent*)aEvent)->theReply.mCursorPosition, p2a);
               break;
-            case NS_QUERYCARETRECT:
-              ConvertRectAppUnitsToIntPixels(
-                ((nsQueryCaretRectEvent*)aEvent)->theReply.mCaretRect, p2a);
-              break;
             case NS_QUERY_CHARACTER_RECT:
             case NS_QUERY_CARET_RECT:
               ConvertRectAppUnitsToIntPixels(
                 ((nsQueryContentEvent*)aEvent)->mReply.mRect, p2a);
               break;
           }
         }
     
--- a/widget/public/nsEvent.h
+++ b/widget/public/nsEvent.h
@@ -73,12 +73,10 @@ class nsKeyEvent;
 class nsTextEvent;
 class nsCompositionEvent;
 class nsMouseScrollEvent;
 class nsReconversionEvent;
 class nsTooltipEvent;
 class nsMenuEvent;
 
 struct nsTextEventReply;
-struct nsReconversionEventReply;
-struct nsQueryCaretRectEventReply;
 
 #endif // nsEvent_h__
--- a/widget/public/nsGUIEvent.h
+++ b/widget/public/nsGUIEvent.h
@@ -80,29 +80,27 @@ class nsHashKey;
 #define NS_SCROLLBAR_EVENT                 7
 #define NS_INPUT_EVENT                     8
 #define NS_KEY_EVENT                       9
 #define NS_MOUSE_EVENT                    10
 #define NS_MENU_EVENT                     11
 #define NS_SCRIPT_ERROR_EVENT             12
 #define NS_TEXT_EVENT                     13
 #define NS_COMPOSITION_EVENT              14
-#define NS_RECONVERSION_EVENT             15
 #define NS_MOUSE_SCROLL_EVENT             16
 #define NS_SCROLLPORT_EVENT               18
 #define NS_MUTATION_EVENT                 19 // |nsMutationEvent| in content
 #define NS_ACCESSIBLE_EVENT               20
 #define NS_FORM_EVENT                     21
 #define NS_FOCUS_EVENT                    22
 #define NS_POPUP_EVENT                    23
 #define NS_COMMAND_EVENT                  24
 #define NS_POPUPBLOCKED_EVENT             25
 #define NS_BEFORE_PAGE_UNLOAD_EVENT       26
 #define NS_UI_EVENT                       27
-#define NS_QUERYCARETRECT_EVENT           28
 #define NS_PAGETRANSITION_EVENT           29
 #ifdef MOZ_SVG
 #define NS_SVG_EVENT                      30
 #define NS_SVGZOOM_EVENT                  31
 #endif // MOZ_SVG
 #define NS_XUL_COMMAND_EVENT              32
 #define NS_QUERY_CONTENT_EVENT            33
 #ifdef MOZ_MEDIA
@@ -291,35 +289,27 @@ class nsHashKey;
 #define NS_USER_DEFINED_EVENT         2000
  
 // composition events
 #define NS_COMPOSITION_EVENT_START    2200
 #define NS_COMPOSITION_START          (NS_COMPOSITION_EVENT_START)
 #define NS_COMPOSITION_END            (NS_COMPOSITION_EVENT_START + 1)
 #define NS_COMPOSITION_QUERY          (NS_COMPOSITION_EVENT_START + 2)
 
-// reconversion events
-#define NS_RECONVERSION_START         2300
-#define NS_RECONVERSION_QUERY         (NS_RECONVERSION_START)
-
 // text events
 #define NS_TEXT_START                 2400
 #define NS_TEXT_TEXT                  (NS_TEXT_START)
 
 // UI events
 #define NS_UI_EVENT_START          2500
 // this is not to be confused with NS_ACTIVATE!
 #define NS_UI_ACTIVATE             (NS_UI_EVENT_START)
 #define NS_UI_FOCUSIN              (NS_UI_EVENT_START + 1)
 #define NS_UI_FOCUSOUT             (NS_UI_EVENT_START + 2)
 
-// query caret rect events
-#define NS_QUERYCARETRECT_START    2600
-#define NS_QUERYCARETRECT          (NS_QUERYCARETRECT_START)
-
 // pagetransition events
 #define NS_PAGETRANSITION_START    2700
 #define NS_PAGE_SHOW               (NS_PAGETRANSITION_START + 1)
 #define NS_PAGE_HIDE               (NS_PAGETRANSITION_START + 2)
 
 #ifdef MOZ_SVG
 // SVG events
 #define NS_SVG_EVENT_START              2800
@@ -843,58 +833,16 @@ public:
       scrollFlags(0), delta(0)
   {
   }
 
   PRInt32               scrollFlags;
   PRInt32               delta;
 };
 
-struct nsReconversionEventReply {
-  nsReconversionEventReply()
-    : mReconversionString(nsnull)
-  {
-  }
-
-  PRUnichar *mReconversionString;
-};
-
-class nsReconversionEvent : public nsInputEvent
-{
-public:
-  nsReconversionEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
-    : nsInputEvent(isTrusted, msg, w, NS_RECONVERSION_EVENT)
-  {
-  }
-
-  nsReconversionEventReply  theReply;
-};
-
-struct nsQueryCaretRectEventReply
-{
-  nsQueryCaretRectEventReply()
-    : mRectIsValid(PR_FALSE)
-  {
-  }
-
-  PRBool mRectIsValid;
-  nsRect mCaretRect;
-};
-
-class nsQueryCaretRectEvent : public nsInputEvent
-{
-public:
-  nsQueryCaretRectEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
-    : nsInputEvent(isTrusted, msg, w, NS_QUERYCARETRECT_EVENT)
-  {
-  }
-
-  nsQueryCaretRectEventReply theReply;
-};
-
 class nsQueryContentEvent : public nsGUIEvent
 {
 public:
   nsQueryContentEvent(PRBool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget) :
     nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_QUERY_CONTENT_EVENT),
     mSucceeded(PR_FALSE)
   {
   }
@@ -1118,18 +1066,16 @@ enum nsDragDropEventStatus {
        (((evnt)->message == NS_KEY_DOWN) ||  \
         ((evnt)->message == NS_KEY_PRESS) || \
         ((evnt)->message == NS_KEY_UP))
 
 #define NS_IS_IME_EVENT(evnt) \
        (((evnt)->message == NS_TEXT_TEXT) ||  \
         ((evnt)->message == NS_COMPOSITION_START) ||  \
         ((evnt)->message == NS_COMPOSITION_END) || \
-        ((evnt)->message == NS_RECONVERSION_QUERY) || \
-        ((evnt)->message == NS_QUERYCARETRECT) || \
         ((evnt)->message == NS_COMPOSITION_QUERY))
 
 #define NS_IS_FOCUS_EVENT(evnt) \
        (((evnt)->message == NS_GOTFOCUS) ||  \
         ((evnt)->message == NS_LOSTFOCUS) ||  \
         ((evnt)->message == NS_ACTIVATE) || \
         ((evnt)->message == NS_DEACTIVATE) || \
         ((evnt)->message == NS_PLUGIN_ACTIVATE))
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -287,20 +287,18 @@ DWORD      nsWindow::sIMEProperty       
 nsString*  nsWindow::sIMECompUnicode           = NULL;
 PRUint8*   nsWindow::sIMEAttributeArray        = NULL;
 PRInt32    nsWindow::sIMEAttributeArrayLength  = 0;
 PRInt32    nsWindow::sIMEAttributeArraySize    = 0;
 PRUint32*  nsWindow::sIMECompClauseArray       = NULL;
 PRInt32    nsWindow::sIMECompClauseArrayLength = 0;
 PRInt32    nsWindow::sIMECompClauseArraySize   = 0;
 long       nsWindow::sIMECursorPosition        = 0;
-PRUnichar* nsWindow::sIMEReconvertUnicode      = NULL;
 
 RECT*      nsWindow::sIMECompCharPos           = nsnull;
-PRInt32    nsWindow::sIMECaretHeight           = 0;
 
 PRBool nsWindow::sIsInEndSession = PR_FALSE;
 
 BOOL nsWindow::sIsRegistered       = FALSE;
 BOOL nsWindow::sIsPopupClassRegistered = FALSE;
 BOOL nsWindow::sIsOleInitialized = FALSE;
 UINT nsWindow::uWM_MSIME_MOUSE     = 0; // mouse message for MSIME
 UINT nsWindow::uWM_HEAP_DUMP       = 0; // Heap Dump to a file
@@ -741,18 +739,16 @@ nsWindow::~nsWindow()
   sInstanceCount--;
   if (sInstanceCount == 0) {
     if (sIMECompUnicode) 
       delete sIMECompUnicode;
     if (sIMEAttributeArray) 
       delete [] sIMEAttributeArray;
     if (sIMECompClauseArray) 
       delete [] sIMECompClauseArray;
-    if (sIMEReconvertUnicode)
-      nsMemory::Free(sIMEReconvertUnicode);
 
     NS_IF_RELEASE(gCursorImgContainer);
 
     if (sIsOleInitialized) {
       ::OleFlushClipboard();
       ::OleUninitialize();
       sIsOleInitialized = FALSE;
     }
@@ -6478,17 +6474,16 @@ nsWindow::HandleTextEvent(HIMC hIMEConte
       if (sIMECompCharPos[sIMECursorPosition-1].top != cursorPosition.y) {
         // wrapping, invalidate left position
         sIMECompCharPos[sIMECursorPosition-1].left = -1;
       }
       sIMECompCharPos[sIMECursorPosition].left = cursorPosition.x;
       sIMECompCharPos[sIMECursorPosition].top = cursorPosition.y;
       sIMECompCharPos[sIMECursorPosition].bottom = cursorPosition.YMost();
     }
-    sIMECaretHeight = cursorPosition.height;
   } else {
     // for some reason we don't know yet, theReply may contain invalid result
     // need more debugging in nsCaret to find out the reason
     // the best we can do now is to ignore the invalid result
   }
 }
 
 BOOL
@@ -6497,21 +6492,16 @@ nsWindow::HandleStartComposition(HIMC hI
   // ATOK send the messages following order at starting composition.
   // 1. WM_IME_COMPOSITION
   // 2. WM_IME_STARTCOMPOSITION
   // We call this function at both step #1 and #2.
   // However, the composition start event should occur only once.
   if (sIMEIsComposing)
     return PR_TRUE;
 
-  if (sIMEReconvertUnicode) {
-    nsMemory::Free(sIMEReconvertUnicode);
-    sIMEReconvertUnicode = NULL;
-  }
-
   nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_START, this);
   nsPoint point(0, 0);
   CANDIDATEFORM candForm;
 
   InitEvent(event, &point);
   DispatchWindowEvent(&event);
 
   //
@@ -6544,17 +6534,16 @@ nsWindow::HandleStartComposition(HIMC hI
 
     sIMECompCharPos = (RECT*)PR_MALLOC(IME_MAX_CHAR_POS*sizeof(RECT));
     if (sIMECompCharPos) {
       memset(sIMECompCharPos, -1, sizeof(RECT)*IME_MAX_CHAR_POS);
       sIMECompCharPos[0].left = cursorPosition.x;
       sIMECompCharPos[0].top = cursorPosition.y;
       sIMECompCharPos[0].bottom = cursorPosition.YMost();
     }
-    sIMECaretHeight = cursorPosition.height;
   } else {
     // for some reason we don't know yet, theReply may contain invalid result
     // need more debugging in nsCaret to find out the reason
     // the best we can do now is to ignore the invalid result
   }
 
   if (!sIMECompUnicode)
     sIMECompUnicode = new nsAutoString();
@@ -6577,17 +6566,16 @@ nsWindow::HandleEndComposition(void)
     DestroyCaret();
     gPinYinIMECaretCreated = PR_FALSE;
   }
 
   InitEvent(event,&point);
   DispatchWindowEvent(&event);
   PR_FREEIF(sIMECompCharPos);
   sIMECompCharPos = nsnull;
-  sIMECaretHeight = 0;
   sIMEIsComposing = PR_FALSE;
 }
 
 static PRUint32 PlatformToNSAttr(PRUint8 aAttr)
 {
   switch (aAttr)
   {
     case ATTR_INPUT_ERROR:
@@ -7037,154 +7025,117 @@ BOOL nsWindow::OnIMERequest(WPARAM aIMR,
 
 //==========================================================================
 PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult)
 {
 #ifdef DEBUG_IME
   printf("OnIMEReconvert\n");
 #endif
 
-  PRBool           result  = PR_FALSE;
+  *oResult = 0;
   RECONVERTSTRING* pReconv = (RECONVERTSTRING*) aData;
-  int              len = 0;
+
+  nsQueryContentEvent selection(PR_TRUE, NS_QUERY_SELECTED_TEXT, this);
+  nsPoint point(0, 0);
+  InitEvent(selection, &point);
+  DispatchWindowEvent(&selection);
+  if (!selection.mSucceeded)
+    return PR_FALSE;
 
   if (!pReconv) {
-
-    //
-    // When reconvert, it must return need size to reconvert.
-    //
-    if (sIMEReconvertUnicode) {
-      nsMemory::Free(sIMEReconvertUnicode);
-      sIMEReconvertUnicode = NULL;
-    }
-
-    // Get reconversion string
-    nsReconversionEvent event(PR_TRUE, NS_RECONVERSION_QUERY, this);
-    nsPoint point(0, 0);
-
-    InitEvent(event, &point);
-    event.theReply.mReconversionString = NULL;
-    DispatchWindowEvent(&event);
-
-    sIMEReconvertUnicode = event.theReply.mReconversionString;
-
-    // Return need size
-
-    if (sIMEReconvertUnicode) {
-      len = nsCRT::strlen(sIMEReconvertUnicode);
-      *oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
-
-      result = PR_TRUE;
-    }
-  } else {
-
-    //
-    // Fill reconvert struct
-    //
-
-    len = nsCRT::strlen(sIMEReconvertUnicode);
+    // Return need size to reconvert.
+    if (selection.mReply.mString.IsEmpty())
+      return PR_FALSE;
+    PRUint32 len = selection.mReply.mString.Length();
     *oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
-
-    if (pReconv->dwSize < *oResult) {
-      *oResult = 0;
-      return PR_FALSE;
-    }
-
-    DWORD tmpSize = pReconv->dwSize;
-    ::ZeroMemory(pReconv, tmpSize);
-    pReconv->dwSize            = tmpSize;
-    pReconv->dwVersion         = 0;
-    pReconv->dwStrLen          = len;
-    pReconv->dwStrOffset       = sizeof(RECONVERTSTRING);
-    pReconv->dwCompStrLen      = len;
-    pReconv->dwCompStrOffset   = 0;
-    pReconv->dwTargetStrLen    = len;
-    pReconv->dwTargetStrOffset = 0;
-
-    ::CopyMemory((LPVOID) (aData + sizeof(RECONVERTSTRING)),
-                 sIMEReconvertUnicode, len * sizeof(WCHAR));
-
-    result = PR_TRUE;
-  }
-
-  return result;
+    return PR_TRUE;
+  }
+
+  // Fill reconvert struct
+  PRUint32 len = selection.mReply.mString.Length();
+  PRUint32 needSize = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
+
+  if (pReconv->dwSize < needSize)
+    return PR_FALSE;
+
+  *oResult = needSize;
+
+  DWORD tmpSize = pReconv->dwSize;
+  ::ZeroMemory(pReconv, tmpSize);
+  pReconv->dwSize            = tmpSize;
+  pReconv->dwVersion         = 0;
+  pReconv->dwStrLen          = len;
+  pReconv->dwStrOffset       = sizeof(RECONVERTSTRING);
+  pReconv->dwCompStrLen      = len;
+  pReconv->dwCompStrOffset   = 0;
+  pReconv->dwTargetStrLen    = len;
+  pReconv->dwTargetStrOffset = 0;
+
+  ::CopyMemory((LPVOID) (aData + sizeof(RECONVERTSTRING)),
+               selection.mReply.mString.get(), len * sizeof(WCHAR));
+  return PR_TRUE;
 }
 
 //==========================================================================
 PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult)
 {
 #ifdef DEBUG_IME
   printf("OnIMEQueryCharPosition\n");
 #endif
+
+  PRUint32 len = sIMEIsComposing ? sIMECompUnicode->Length() : 0;
+  *oResult = FALSE;
   IMECHARPOSITION* pCharPosition = (IMECHARPOSITION*)aData;
   if (!pCharPosition ||
       pCharPosition->dwSize < sizeof(IMECHARPOSITION) ||
-      ::GetFocus() != mWnd) {
-    *oResult = FALSE;
+      ::GetFocus() != mWnd ||
+      pCharPosition->dwCharPos > len)
+    return PR_FALSE;
+
+  nsPoint point(0, 0);
+
+  nsQueryContentEvent selection(PR_TRUE, NS_QUERY_SELECTED_TEXT, this);
+  InitEvent(selection, &point);
+  DispatchWindowEvent(&selection);
+  if (!selection.mSucceeded)
     return PR_FALSE;
-  }
-
-  if (!sIMEIsComposing) {  // Including |!sIMECompUnicode| and |!sIMECompUnicode->IsEmpty|.
-    if (pCharPosition->dwCharPos != 0) {
-      *oResult = FALSE;
-      return PR_FALSE;
-    }
-    nsPoint point(0, 0);
-    nsQueryCaretRectEvent event(PR_TRUE, NS_QUERYCARETRECT, this);
-    InitEvent(event, &point);
-    DispatchWindowEvent(&event);
-    // The active widget doesn't support this event.
-    if (!event.theReply.mRectIsValid) {
-      *oResult = FALSE;
+
+  PRUint32 offset = selection.mReply.mOffset + pCharPosition->dwCharPos;
+  PRBool useCaretRect = selection.mReply.mString.IsEmpty();
+
+  nsRect r;
+  if (!useCaretRect) {
+    nsQueryContentEvent charRect(PR_TRUE, NS_QUERY_CHARACTER_RECT, this);
+    charRect.InitForQueryCharacterRect(offset);
+    InitEvent(charRect, &point);
+    DispatchWindowEvent(&charRect);
+    if (charRect.mSucceeded)
+      r = charRect.mReply.mRect;
+    else
+      useCaretRect = PR_TRUE;
+  }
+
+  if (useCaretRect) {
+    nsQueryContentEvent caretRect(PR_TRUE, NS_QUERY_CARET_RECT, this);
+    caretRect.InitForQueryCaretRect(offset);
+    InitEvent(caretRect, &point);
+    DispatchWindowEvent(&caretRect);
+    if (!caretRect.mSucceeded)
       return PR_FALSE;
-    }
-
-    nsRect screenRect;
-    ResolveIMECaretPos(nsnull, event.theReply.mCaretRect, screenRect);
-    pCharPosition->pt.x = screenRect.x;
-    pCharPosition->pt.y = screenRect.y;
-
-    pCharPosition->cLineHeight = event.theReply.mCaretRect.height;
-
-    ::GetWindowRect(mWnd, &pCharPosition->rcDocument);
-
-    *oResult = TRUE;
-    return PR_TRUE;
-  }
-
-  // If the char positions are not cached, we should not return the values by LPARAM.
-  // Because in this case, the active widget is not editor.
-  if (!sIMECompCharPos) {
-    *oResult = FALSE;
-    return PR_FALSE;
-  }
-
-  long charPosition;
-  if (pCharPosition->dwCharPos > sIMECompUnicode->Length()) {
-    *oResult = FALSE;
-    return PR_FALSE;
-  }
-  charPosition = pCharPosition->dwCharPos;
-
-  // We only support insertion at the cursor position or at the leftmost position.
-  // Because sIMECompCharPos may be broken by user converting the string.
-  // But leftmost position and cursor position is always correctly.
-  if ((charPosition != 0 && charPosition != sIMECursorPosition) ||
-      charPosition > IME_MAX_CHAR_POS) {
-    *oResult = FALSE;
-    return PR_FALSE;
-  }
-  POINT pt;
-  pt.x = sIMECompCharPos[charPosition].left;
-  pt.y = sIMECompCharPos[charPosition].top;
-  ::ClientToScreen(mWnd, &pt);
-  pCharPosition->pt = pt;
-
-  pCharPosition->cLineHeight = sIMECaretHeight;
-
+    r = caretRect.mReply.mRect;
+  }
+
+  nsRect screenRect;
+  ResolveIMECaretPos(nsnull, r, screenRect);
+  pCharPosition->pt.x = screenRect.x;
+  pCharPosition->pt.y = screenRect.y;
+
+  pCharPosition->cLineHeight = r.height;
+
+  // XXX Should we create "query focused content rect event"?
   ::GetWindowRect(mWnd, &pCharPosition->rcDocument);
 
   *oResult = TRUE;
   return PR_TRUE;
 }
 
 //==========================================================================
 void
--- a/widget/src/windows/nsWindow.h
+++ b/widget/src/windows/nsWindow.h
@@ -390,21 +390,19 @@ protected:
   static nsString*  sIMECompUnicode;
   static PRUint8*   sIMEAttributeArray;
   static PRInt32    sIMEAttributeArrayLength;
   static PRInt32    sIMEAttributeArraySize;
   static PRUint32*  sIMECompClauseArray;
   static PRInt32    sIMECompClauseArrayLength;
   static PRInt32    sIMECompClauseArraySize;
   static long       sIMECursorPosition;
-  static PRUnichar* sIMEReconvertUnicode; // reconvert string
 
   // For describing composing frame
   static RECT*      sIMECompCharPos;
-  static PRInt32    sIMECaretHeight;
 
   static PRBool     sIsInEndSession;
 
   nsSize        mLastSize;
   static        nsWindow* gCurrentWindow;
   nsPoint       mLastPoint;
   HWND          mWnd;
   HDC           mPaintDC; // only set during painting