mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 125573
Call IME-W APIs instead of IME-A APIs to prevent moz from crashing only in Win2K-Chinese Simplified and WinXP-Chinese Simplified /r=shanjian, /sr=brendan, /a=asa
This commit is contained in:
parent
ad65ab1530
commit
8df9321a5d
@ -54,7 +54,7 @@ NS_IMPL_ISUPPORTS1(nsToolkit, nsIToolkit)
|
|||||||
static PRUintn gToolkitTLSIndex = 0;
|
static PRUintn gToolkitTLSIndex = 0;
|
||||||
|
|
||||||
HINSTANCE nsToolkit::mDllInstance = 0;
|
HINSTANCE nsToolkit::mDllInstance = 0;
|
||||||
PRBool nsToolkit::mIsNT = PR_FALSE;
|
PRBool nsToolkit::mUseImeApiW = PR_FALSE;
|
||||||
|
|
||||||
#ifdef MOZ_AIMM
|
#ifdef MOZ_AIMM
|
||||||
IActiveIMMApp* nsToolkit::gAIMMApp = NULL;
|
IActiveIMMApp* nsToolkit::gAIMMApp = NULL;
|
||||||
@ -224,14 +224,35 @@ nsToolkit::Startup(HMODULE hModule)
|
|||||||
VERIFY(::RegisterClass(&wc));
|
VERIFY(::RegisterClass(&wc));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set flag of nsToolkit::mIsNT due to using Unicode API.
|
// Set flag of nsToolkit::mUseImeApiW due to using Unicode API.
|
||||||
//
|
//
|
||||||
|
|
||||||
OSVERSIONINFO osversion;
|
OSVERSIONINFOEX osversion;
|
||||||
::ZeroMemory(&osversion, sizeof(OSVERSIONINFO));
|
BOOL osVersionInfoEx;
|
||||||
|
|
||||||
|
::ZeroMemory(&osversion, sizeof(OSVERSIONINFOEX));
|
||||||
|
osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||||
|
|
||||||
|
if (!(osVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osversion))) {
|
||||||
|
// if OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
|
||||||
osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
::GetVersionEx(&osversion);
|
if (!GetVersionEx((OSVERSIONINFO *)&osversion)) {
|
||||||
nsToolkit::mIsNT = (osversion.dwPlatformId == VER_PLATFORM_WIN32_NT) ? PR_TRUE : PR_FALSE;
|
// maybe we are running on very old Windows OS. Assign FALSE.
|
||||||
|
nsToolkit::mUseImeApiW = PR_FALSE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nsToolkit::mUseImeApiW = (osversion.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||||
|
if (nsToolkit::mUseImeApiW) {
|
||||||
|
// XXX Hack for stopping the crash (125573)
|
||||||
|
if (osversion.dwMajorVersion == 5 && (osversion.dwMinorVersion == 0 || osversion.dwMinorVersion == 1)) {
|
||||||
|
// "Microsoft Windows 2000 " or "Microsoft Windows XP "
|
||||||
|
if (936 == ::GetACP()) // Chinese (PRC, Singapore)
|
||||||
|
nsToolkit::mUseImeApiW = PR_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static HINSTANCE mDllInstance;
|
static HINSTANCE mDllInstance;
|
||||||
// OS flag
|
// OS flag
|
||||||
static PRBool mIsNT;
|
static PRBool mUseImeApiW;
|
||||||
|
|
||||||
static void Startup(HINSTANCE hModule);
|
static void Startup(HINSTANCE hModule);
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
@ -5132,7 +5132,7 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr)
|
|||||||
// convert the composition string text into unicode before it is sent to xp-land
|
// convert the composition string text into unicode before it is sent to xp-land
|
||||||
// but, on Windows NT / 2000, need not convert.
|
// but, on Windows NT / 2000, need not convert.
|
||||||
//
|
//
|
||||||
if (!nsToolkit::mIsNT) {
|
if (!nsToolkit::mUseImeApiW) {
|
||||||
unicharSize = ::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,
|
unicharSize = ::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,
|
||||||
mIMECompString->get(),
|
mIMECompString->get(),
|
||||||
mIMECompString->Length(),
|
mIMECompString->Length(),
|
||||||
@ -5302,7 +5302,7 @@ nsWindow::MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthRes
|
|||||||
// IME strings already store to mIMECompUnicode.
|
// IME strings already store to mIMECompUnicode.
|
||||||
//
|
//
|
||||||
|
|
||||||
long maxlen = nsToolkit::mIsNT ? mIMECompUnicode->Length() : mIMECompString->Length();
|
long maxlen = nsToolkit::mUseImeApiW ? mIMECompUnicode->Length() : mIMECompString->Length();
|
||||||
long cursor = mIMECursorPosition;
|
long cursor = mIMECursorPosition;
|
||||||
NS_ASSERTION(cursor <= maxlen, "wrong cursor positoin");
|
NS_ASSERTION(cursor <= maxlen, "wrong cursor positoin");
|
||||||
if(cursor > maxlen)
|
if(cursor > maxlen)
|
||||||
@ -5315,12 +5315,12 @@ nsWindow::MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthRes
|
|||||||
*textRangeListLengthResult = 2;
|
*textRangeListLengthResult = 2;
|
||||||
*textRangeListResult = new nsTextRange[2];
|
*textRangeListResult = new nsTextRange[2];
|
||||||
(*textRangeListResult)[0].mStartOffset=0;
|
(*textRangeListResult)[0].mStartOffset=0;
|
||||||
substringLength = nsToolkit::mIsNT ? mIMECompUnicode->Length() :
|
substringLength = nsToolkit::mUseImeApiW ? mIMECompUnicode->Length() :
|
||||||
::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,
|
::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,
|
||||||
mIMECompString->get(), maxlen,NULL,0);
|
mIMECompString->get(), maxlen,NULL,0);
|
||||||
(*textRangeListResult)[0].mEndOffset = substringLength;
|
(*textRangeListResult)[0].mEndOffset = substringLength;
|
||||||
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_RAWINPUT;
|
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_RAWINPUT;
|
||||||
substringLength = nsToolkit::mIsNT ? cursor :
|
substringLength = nsToolkit::mUseImeApiW ? cursor :
|
||||||
::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,mIMECompString->get(),
|
::MultiByteToWideChar(gCurrentKeyboardCP,MB_PRECOMPOSED,mIMECompString->get(),
|
||||||
cursor,NULL,0);
|
cursor,NULL,0);
|
||||||
(*textRangeListResult)[1].mStartOffset=substringLength;
|
(*textRangeListResult)[1].mStartOffset=substringLength;
|
||||||
@ -5341,7 +5341,7 @@ nsWindow::MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthRes
|
|||||||
// figure out the cursor position
|
// figure out the cursor position
|
||||||
//
|
//
|
||||||
|
|
||||||
substringLength = nsToolkit::mIsNT ? cursor :
|
substringLength = nsToolkit::mUseImeApiW ? cursor :
|
||||||
::MultiByteToWideChar(gCurrentKeyboardCP,
|
::MultiByteToWideChar(gCurrentKeyboardCP,
|
||||||
MB_PRECOMPOSED,mIMECompString->get(),cursor,NULL,0);
|
MB_PRECOMPOSED,mIMECompString->get(),cursor,NULL,0);
|
||||||
(*textRangeListResult)[0].mStartOffset=substringLength;
|
(*textRangeListResult)[0].mStartOffset=substringLength;
|
||||||
@ -5364,7 +5364,7 @@ nsWindow::MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthRes
|
|||||||
PlatformToNSAttr(mIMEAttributeString[lastMBCSOffset]);
|
PlatformToNSAttr(mIMEAttributeString[lastMBCSOffset]);
|
||||||
(*textRangeListResult)[rangePointer].mStartOffset = lastUnicodeOffset;
|
(*textRangeListResult)[rangePointer].mStartOffset = lastUnicodeOffset;
|
||||||
|
|
||||||
lastUnicodeOffset += nsToolkit::mIsNT ? current - lastMBCSOffset :
|
lastUnicodeOffset += nsToolkit::mUseImeApiW ? current - lastMBCSOffset :
|
||||||
::MultiByteToWideChar(gCurrentKeyboardCP,
|
::MultiByteToWideChar(gCurrentKeyboardCP,
|
||||||
MB_PRECOMPOSED,mIMECompString->get()+lastMBCSOffset,
|
MB_PRECOMPOSED,mIMECompString->get()+lastMBCSOffset,
|
||||||
current-lastMBCSOffset,NULL,0);
|
current-lastMBCSOffset,NULL,0);
|
||||||
@ -5462,7 +5462,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
|||||||
//
|
//
|
||||||
|
|
||||||
long compStrLen;
|
long compStrLen;
|
||||||
if (nsToolkit::mIsNT) {
|
if (nsToolkit::mUseImeApiW) {
|
||||||
// Imm* Unicode API works on Windows NT / 2000.
|
// Imm* Unicode API works on Windows NT / 2000.
|
||||||
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext, GCS_RESULTSTR, NULL, 0, compStrLen);
|
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext, GCS_RESULTSTR, NULL, 0, compStrLen);
|
||||||
|
|
||||||
@ -5511,7 +5511,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
|||||||
// This provides us with the attribute string necessary
|
// This provides us with the attribute string necessary
|
||||||
// for doing hiliting
|
// for doing hiliting
|
||||||
long attrStrLen;
|
long attrStrLen;
|
||||||
if (nsToolkit::mIsNT) {
|
if (nsToolkit::mUseImeApiW) {
|
||||||
// Imm* Unicode API works on Windows NT / 2000.
|
// Imm* Unicode API works on Windows NT / 2000.
|
||||||
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext, GCS_COMPATTR, NULL, 0, attrStrLen);
|
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext, GCS_COMPATTR, NULL, 0, attrStrLen);
|
||||||
if (attrStrLen > mIMEAttributeStringSize) {
|
if (attrStrLen > mIMEAttributeStringSize) {
|
||||||
@ -5541,7 +5541,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
|||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
long compClauseLen;
|
long compClauseLen;
|
||||||
long compClauseLen2;
|
long compClauseLen2;
|
||||||
if (nsToolkit::mIsNT) {
|
if (nsToolkit::mUseImeApiW) {
|
||||||
// Imm* Unicode API works on Windows NT / 2000.
|
// Imm* Unicode API works on Windows NT / 2000.
|
||||||
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext,
|
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext,
|
||||||
GCS_COMPCLAUSE, NULL, 0, compClauseLen);
|
GCS_COMPCLAUSE, NULL, 0, compClauseLen);
|
||||||
@ -5587,7 +5587,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
|||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
// 3. Get GCS_CURSOPOS
|
// 3. Get GCS_CURSOPOS
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
if (nsToolkit::mIsNT) {
|
if (nsToolkit::mUseImeApiW) {
|
||||||
// Imm* Unicode API works on Windows NT / 2000.
|
// Imm* Unicode API works on Windows NT / 2000.
|
||||||
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext, GCS_CURSORPOS, NULL, 0, mIMECursorPosition);
|
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext, GCS_CURSORPOS, NULL, 0, mIMECursorPosition);
|
||||||
} else {
|
} else {
|
||||||
@ -5598,7 +5598,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
|||||||
// 4. Get GCS_COMPSTR
|
// 4. Get GCS_COMPSTR
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
long compStrLen;
|
long compStrLen;
|
||||||
if (nsToolkit::mIsNT) {
|
if (nsToolkit::mUseImeApiW) {
|
||||||
// Imm* Unicode API works on Windows NT / 2000.
|
// Imm* Unicode API works on Windows NT / 2000.
|
||||||
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext, GCS_COMPSTR, NULL, 0, compStrLen);
|
NS_IMM_GETCOMPOSITIONSTRINGW(hIMEContext, GCS_COMPSTR, NULL, 0, compStrLen);
|
||||||
|
|
||||||
@ -5628,7 +5628,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for(int kk=0;kk<mIMECompClauseStringLength;kk++)
|
for(int kk=0;kk<mIMECompClauseStringLength;kk++)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mIMECompClauseString[kk] <= (nsToolkit::mIsNT ? mIMECompUnicode->Length() : mIMECompString->Length()), "illegal pos");
|
NS_ASSERTION(mIMECompClauseString[kk] <= (nsToolkit::mUseImeApiW ? mIMECompUnicode->Length() : mIMECompString->Length()), "illegal pos");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
@ -5645,7 +5645,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
|
|||||||
if(! mIMEIsComposing)
|
if(! mIMEIsComposing)
|
||||||
HandleStartComposition(hIMEContext);
|
HandleStartComposition(hIMEContext);
|
||||||
|
|
||||||
if (nsToolkit::mIsNT) {
|
if (nsToolkit::mUseImeApiW) {
|
||||||
mIMECompUnicode->Truncate();
|
mIMECompUnicode->Truncate();
|
||||||
} else {
|
} else {
|
||||||
mIMECompString->Truncate();
|
mIMECompString->Truncate();
|
||||||
@ -5689,7 +5689,7 @@ BOOL nsWindow::OnIMEEndComposition()
|
|||||||
// first when we hit space in composition mode
|
// first when we hit space in composition mode
|
||||||
// we need to clear out the current composition string
|
// we need to clear out the current composition string
|
||||||
// in that case.
|
// in that case.
|
||||||
if (nsToolkit::mIsNT) {
|
if (nsToolkit::mUseImeApiW) {
|
||||||
mIMECompUnicode->Truncate(0);
|
mIMECompUnicode->Truncate(0);
|
||||||
} else {
|
} else {
|
||||||
mIMECompString->Truncate(0);
|
mIMECompString->Truncate(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user