Bug 449012 – Remove legacy Reconversion/QueryCaretRect Events r=ere+roc, sr=roc

This commit is contained in:
Masayuki Nakano 2008-08-09 11:46:30 +09:00
parent 055353d090
commit 446176f140
20 changed files with 88 additions and 421 deletions

View File

@ -41,10 +41,10 @@
#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 {
@ -52,8 +52,6 @@ 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,

View File

@ -788,12 +788,6 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData()
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 =
@ -885,12 +879,6 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData()
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 =

View File

@ -370,8 +370,7 @@ nsDOMUIEvent::GetPreventDefault(PRBool* aReturn)
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);
@ -381,30 +380,6 @@ NS_METHOD nsDOMUIEvent::GetCompositionReply(nsTextEventReply** aReply)
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()
{

View File

@ -67,8 +67,6 @@ public:
// nsIPrivateCompositionEvent interface
NS_IMETHOD GetCompositionReply(nsTextEventReply** aReply);
NS_IMETHOD GetReconversionReply(nsReconversionEventReply** aReply);
NS_IMETHOD GetQueryCaretRectReply(nsQueryCaretRectEventReply** aReply);
// Forward to nsDOMEvent
NS_FORWARD_TO_NSDOMEVENT

View File

@ -562,8 +562,6 @@ nsEventDispatcher::CreateEvent(nsPresContext* 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));

View File

@ -225,11 +225,7 @@ static const EventDispatchData sCompositionEvents[] = {
{ 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[] = {

View File

@ -44,10 +44,10 @@
/*
* 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 {
@ -59,8 +59,6 @@ public:
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,

View File

@ -42,17 +42,13 @@
%{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
{
@ -89,30 +85,6 @@ interface nsIEditorIMESupport : nsISupports
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.
*/

View File

@ -2147,18 +2147,6 @@ nsEditor::ForceCompositionEnd()
return NS_OK;
}
NS_IMETHODIMP
nsEditor::NotifyIMEOnFocus()
{
return NS_OK;
}
NS_IMETHODIMP
nsEditor::NotifyIMEOnBlur()
{
return NS_OK;
}
NS_IMETHODIMP
nsEditor::GetPreferredIMEState(PRUint32 *aState)
{
@ -2213,41 +2201,6 @@ nsEditor::GetComposing(PRBool* aResult)
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

View File

@ -870,43 +870,6 @@ nsTextEditorCompositionListener::HandleEndComposition(nsIDOMEvent* aCompositionE
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
*/
@ -1129,7 +1092,6 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
// turn on selection and caret
if (mEditor)
{
nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
PRUint32 flags;
mEditor->GetFlags(&flags);
if (! (flags & nsIPlaintextEditor::eEditorDisabledMask))
@ -1188,9 +1150,6 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
}
}
}
if (imeEditor)
imeEditor->NotifyIMEOnFocus();
}
return NS_OK;
}
@ -1202,13 +1161,6 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* 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)
{

View File

@ -148,8 +148,6 @@ public:
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:

View File

@ -1750,40 +1750,6 @@ nsPlaintextEditor::SetCompositionString(const nsAString& aCompositionString, nsI
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

View File

@ -86,9 +86,9 @@ public:
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);

View File

@ -758,18 +758,6 @@ 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

View File

@ -91,8 +91,6 @@ public:
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);

View File

@ -1351,10 +1351,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
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(

View File

@ -78,7 +78,5 @@ class nsTooltipEvent;
class nsMenuEvent;
struct nsTextEventReply;
struct nsReconversionEventReply;
struct nsQueryCaretRectEventReply;
#endif // nsEvent_h__

View File

@ -85,7 +85,6 @@ class nsHashKey;
#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
@ -97,7 +96,6 @@ class nsHashKey;
#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
@ -296,10 +294,6 @@ class nsHashKey;
#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)
@ -311,10 +305,6 @@ class nsHashKey;
#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)
@ -848,48 +838,6 @@ public:
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:
@ -1123,8 +1071,6 @@ enum nsDragDropEventStatus {
(((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) \

View File

@ -292,10 +292,8 @@ 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;
@ -746,8 +744,6 @@ nsWindow::~nsWindow()
delete [] sIMEAttributeArray;
if (sIMECompClauseArray)
delete [] sIMECompClauseArray;
if (sIMEReconvertUnicode)
nsMemory::Free(sIMEReconvertUnicode);
NS_IF_RELEASE(gCursorImgContainer);
@ -6483,7 +6479,6 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr)
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
@ -6502,11 +6497,6 @@ nsWindow::HandleStartComposition(HIMC hIMEContext)
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;
@ -6549,7 +6539,6 @@ nsWindow::HandleStartComposition(HIMC hIMEContext)
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
@ -6582,7 +6571,6 @@ nsWindow::HandleEndComposition(void)
DispatchWindowEvent(&event);
PR_FREEIF(sIMECompCharPos);
sIMECompCharPos = nsnull;
sIMECaretHeight = 0;
sIMEIsComposing = PR_FALSE;
}
@ -7042,70 +7030,48 @@ PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult)
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);
*oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
if (pReconv->dwSize < *oResult) {
*oResult = 0;
// Return need size to reconvert.
if (selection.mReply.mString.IsEmpty())
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;
PRUint32 len = selection.mReply.mString.Length();
*oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
return PR_TRUE;
}
return result;
// 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;
}
//==========================================================================
@ -7114,72 +7080,57 @@ 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;
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 (!sIMEIsComposing) { // Including |!sIMECompUnicode| and |!sIMECompUnicode->IsEmpty|.
if (pCharPosition->dwCharPos != 0) {
*oResult = FALSE;
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;
}
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;
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;
r = caretRect.mReply.mRect;
}
// 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;
}
nsRect screenRect;
ResolveIMECaretPos(nsnull, r, screenRect);
pCharPosition->pt.x = screenRect.x;
pCharPosition->pt.y = screenRect.y;
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;
pCharPosition->cLineHeight = r.height;
// XXX Should we create "query focused content rect event"?
::GetWindowRect(mWnd, &pCharPosition->rcDocument);
*oResult = TRUE;

View File

@ -395,11 +395,9 @@ protected:
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;