fix the delete last IME text problem. bug13494 . There are another fix in nsHTMLEditRules.cpp related this but I forget to put the bug # there. r=tague

This commit is contained in:
ftang%netscape.com 1999-10-27 23:05:24 +00:00
parent 8765b06796
commit 7b8cfeb611
2 changed files with 28 additions and 29 deletions

View File

@ -2947,6 +2947,30 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
#endif
mIMECursorPosition = ::ImmGetCompositionString(hIMEContext,GCS_CURSORPOS,NULL,0);
}
//
// This catches a fixed result
//
if (lParam & GCS_RESULTSTR) {
#if defined(DEBUG_tague) || defined(DEBUG_ftang)
fprintf(stderr,"nsWindow::WM_IME_COMPOSITION: handling GCS_RESULTSTR\n");
#endif
long compStrLen = ::ImmGetCompositionString(hIMEContext,GCS_RESULTSTR,NULL,0);
if (compStrLen+1>mIMECompositionStringSize) {
delete [] mIMECompositionString;
mIMECompositionString = new char[compStrLen+32];
mIMECompositionStringSize = compStrLen+32;
}
::ImmGetCompositionString(hIMEContext,GCS_RESULTSTR,mIMECompositionString,mIMECompositionStringSize);
mIMECompositionStringLength = compStrLen;
mIMECompositionString[compStrLen]='\0';
result = PR_TRUE;
HandleTextEvent(hIMEContext, PR_FALSE);
HandleEndComposition();
HandleStartComposition(hIMEContext);
bSendEvent = PR_TRUE;
}
//
// This provides us with a composition string
//
@ -2968,38 +2992,13 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
result = PR_TRUE;
bSendEvent = PR_TRUE;
}
//
// This catches a fixed result
//
if (lParam & GCS_RESULTSTR) {
#if defined(DEBUG_tague) || defined(DEBUG_ftang)
fprintf(stderr,"nsWindow::WM_IME_COMPOSITION: handling GCS_RESULTSTR\n");
#endif
long compStrLen = ::ImmGetCompositionString(hIMEContext,GCS_RESULTSTR,NULL,0);
if (compStrLen+1>mIMECompositionStringSize) {
delete [] mIMECompositionString;
mIMECompositionString = new char[compStrLen+32];
mIMECompositionStringSize = compStrLen+32;
}
::ImmGetCompositionString(hIMEContext,GCS_RESULTSTR,mIMECompositionString,mIMECompositionStringSize);
mIMECompositionStringLength = compStrLen;
mIMECompositionString[compStrLen]='\0';
result = PR_TRUE;
mIMEIsComposing = PR_FALSE;
HandleTextEvent(hIMEContext);
HandleEndComposition();
HandleStartComposition(hIMEContext);
bSendEvent = PR_TRUE;
}
if(! bSendEvent)
{
#if defined(DEBUG_tague) || defined(DEBUG_ftang)
fprintf(stderr,"nsWindow::WM_IME_COMPOSITION: haandle 0 length TextEvent. \n");
#endif
mIMECompositionStringLength = 0;
HandleTextEvent(hIMEContext);
HandleTextEvent(hIMEContext,PR_FALSE);
bSendEvent = PR_TRUE;
}
@ -3752,7 +3751,7 @@ NS_METHOD nsWindow::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight)
}
void
nsWindow::HandleTextEvent(HIMC hIMEContext)
nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr)
{
nsTextEvent event;
nsPoint point;
@ -3783,7 +3782,7 @@ nsWindow::HandleTextEvent(HIMC hIMEContext)
// mapped to the unicode text
//
if(mIMEIsComposing) {
if(aCheckAttr) {
MapDBCSAtrributeArrayToUnicodeOffsets(&(event.rangeCount),&(event.rangeArray));
} else {
event.rangeCount = 0;

View File

@ -192,7 +192,7 @@ protected:
void RelayMouseEvent(UINT aMsg, WPARAM wParam, LPARAM lParam);
void GetNonClientBounds(nsRect &aRect);
void HandleTextEvent(HIMC hIMEContext);
void HandleTextEvent(HIMC hIMEContext, PRBool aCheckAttr=PR_TRUE);
void HandleStartComposition(HIMC hIMEContext);
void HandleEndComposition(void);
void MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthResult, nsTextRangeArray* textRangeListResult);