From 2bf7a2cee44b0d0b0eeebcb085542aa0c8fe8f95 Mon Sep 17 00:00:00 2001 From: "masayuki%d-toybox.com" Date: Sat, 25 Jun 2005 04:43:04 +0000 Subject: [PATCH] Bug 296339 No response when I am inputting use the MSPinYin(Chinese) input method r=timeless, sr=rbs, a=asa git-svn-id: svn://10.0.0.236/trunk@175137 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/windows/nsWindow.cpp | 32 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index 20a289f2535..323063df10b 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -6347,7 +6347,9 @@ nsWindow::HandleStartComposition(HIMC hIMEContext) void nsWindow::HandleEndComposition(void) { - NS_ASSERTION(sIMEIsComposing, "conflict state"); + if (!sIMEIsComposing) + return; + nsCompositionEvent event(PR_TRUE, NS_COMPOSITION_END, this); nsPoint point(0, 0); @@ -6592,6 +6594,8 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS) // will change this if an IME message we handle BOOL result = PR_FALSE; + PRBool startCompositionMessageHasBeenSent = sIMEIsComposing; + // // This catches a fixed result // @@ -6631,6 +6635,24 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS) nsCAutoString strIMECompAnsi; GetCompositionString(hIMEContext, GCS_COMPSTR, sIMECompUnicode, &strIMECompAnsi); + // See https://bugzilla.mozilla.org/show_bug.cgi?id=296339 + if (sIMECompUnicode->IsEmpty() && + !startCompositionMessageHasBeenSent) { + // In this case, maybe, the sender is MSPinYin. That sends *only* + // WM_IME_COMPOSITION with GCS_COMP* and GCS_RESULT* when + // user inputted the Chinese full stop. So, that doesn't send + // WM_IME_STARTCOMPOSITION and WM_IME_ENDCOMPOSITION. + // If WM_IME_STARTCOMPOSITION was not sent and the composition + // string is null (it indicates the composition transaction ended), + // WM_IME_ENDCOMPOSITION may not be sent. If so, we cannot run + // HandleEndComposition() in other place. +#ifdef DEBUG_IME + printf("Aborting GCS_COMPSTR\n"); +#endif + HandleEndComposition(); + return result; + } + #ifdef DEBUG_IME printf("GCS_COMPSTR compStrLen = %d\n", sIMECompUnicode->Length()); #endif @@ -6742,10 +6764,10 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS) strIMECompAnsi.get(), sIMECursorPosition, NULL, 0); } -#ifdef DEBUG - for (int kk = 0; kk < sIMECompClauseArrayLength; kk++) { - NS_ASSERTION(sIMECompClauseArray[kk] <= sIMECompUnicode->Length(), "illegal pos"); - } + NS_ASSERTION(sIMECursorPosition <= sIMECompUnicode->Length(), "illegal pos"); + +#ifdef DEBUG_IME + printf("sIMECursorPosition(Unicode): %d\n", sIMECursorPosition); #endif //-------------------------------------------------------- // 5. Send the text event