Bug 316638 Sould not use obsoleted API(WINNLSEnableIME) patch by Masatoshi Kimura (emk) <VYV03354@nifty.ne.jp> r=masayuki+timeless, sr=neil
git-svn-id: svn://10.0.0.236/trunk@184821 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
852be695f7
commit
a231837325
@ -1129,6 +1129,11 @@ nsIMM::nsIMM(const char* aModuleName /* = "IMM32.DLL" */)
|
|||||||
(SetOpenStatusPtr)GetProcAddress(mInstance,"ImmSetOpenStatus");
|
(SetOpenStatusPtr)GetProcAddress(mInstance,"ImmSetOpenStatus");
|
||||||
NS_ASSERTION(mSetOpenStatus != NULL,
|
NS_ASSERTION(mSetOpenStatus != NULL,
|
||||||
"nsIMM.ImmSetOpenStatus failed.");
|
"nsIMM.ImmSetOpenStatus failed.");
|
||||||
|
|
||||||
|
mAssociateContext =
|
||||||
|
(AssociateContextPtr)GetProcAddress(mInstance,"ImmAssociateContext");
|
||||||
|
NS_ASSERTION(mAssociateContext != NULL,
|
||||||
|
"nsIMM.ImmAssociateContext failed.");
|
||||||
} else {
|
} else {
|
||||||
mGetCompositionStringA=NULL;
|
mGetCompositionStringA=NULL;
|
||||||
mGetCompositionStringW=NULL;
|
mGetCompositionStringW=NULL;
|
||||||
@ -1142,6 +1147,7 @@ nsIMM::nsIMM(const char* aModuleName /* = "IMM32.DLL" */)
|
|||||||
mGetDefaultIMEWnd=NULL;
|
mGetDefaultIMEWnd=NULL;
|
||||||
mGetOpenStatus=NULL;
|
mGetOpenStatus=NULL;
|
||||||
mSetOpenStatus=NULL;
|
mSetOpenStatus=NULL;
|
||||||
|
mAssociateContext=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // WinCE
|
#else // WinCE
|
||||||
@ -1159,6 +1165,7 @@ nsIMM::nsIMM(const char* aModuleName /* = "IMM32.DLL" */)
|
|||||||
mGetDefaultIMEWnd=(GetDefaultIMEWndPtr)ImmGetDefaultIMEWnd;
|
mGetDefaultIMEWnd=(GetDefaultIMEWndPtr)ImmGetDefaultIMEWnd;
|
||||||
mGetOpenStatus=(GetOpenStatusPtr)ImmGetOpenStatus;
|
mGetOpenStatus=(GetOpenStatusPtr)ImmGetOpenStatus;
|
||||||
mSetOpenStatus=(SetOpenStatusPtr)ImmSetOpenStatus;
|
mSetOpenStatus=(SetOpenStatusPtr)ImmSetOpenStatus;
|
||||||
|
mAssociateContext=(AssociateContextPtr)ImmAssociateContext;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1183,6 +1190,7 @@ nsIMM::~nsIMM()
|
|||||||
mGetDefaultIMEWnd=NULL;
|
mGetDefaultIMEWnd=NULL;
|
||||||
mGetOpenStatus=NULL;
|
mGetOpenStatus=NULL;
|
||||||
mSetOpenStatus=NULL;
|
mSetOpenStatus=NULL;
|
||||||
|
mAssociateContext=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -1314,109 +1322,11 @@ nsIMM::SetOpenStatus(HIMC aIMC, BOOL aStatus)
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// nsWinNLS class(Native WinNLS wrapper)
|
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
nsWinNLS&
|
HIMC
|
||||||
nsWinNLS::LoadModule()
|
nsIMM::AssociateContext(HWND aWnd, HIMC aIMC)
|
||||||
{
|
{
|
||||||
static nsWinNLS gWinNLS;
|
return (mAssociateContext) ? mAssociateContext(aWnd, aIMC) : NULL;
|
||||||
return gWinNLS;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
nsWinNLS::nsWinNLS(const char* aModuleName /* = "USER32.DLL" */)
|
|
||||||
{
|
|
||||||
#ifndef WINCE
|
|
||||||
mInstance=::LoadLibrary(aModuleName);
|
|
||||||
|
|
||||||
if (mInstance) {
|
|
||||||
mWINNLSEnableIME =
|
|
||||||
(WINNLSEnableIMEPtr)GetProcAddress(mInstance, "WINNLSEnableIME");
|
|
||||||
NS_ASSERTION(mWINNLSEnableIME != NULL,
|
|
||||||
"nsWinNLS.WINNLSEnableIME failed.");
|
|
||||||
|
|
||||||
mWINNLSGetEnableStatus =
|
|
||||||
(WINNLSGetEnableStatusPtr)GetProcAddress(mInstance,
|
|
||||||
"WINNLSGetEnableStatus");
|
|
||||||
NS_ASSERTION(mWINNLSGetEnableStatus != NULL,
|
|
||||||
"nsWinNLS.WINNLSGetEnableStatus failed.");
|
|
||||||
} else {
|
|
||||||
mWINNLSEnableIME = NULL;
|
|
||||||
mWINNLSGetEnableStatus = NULL;
|
|
||||||
}
|
|
||||||
#else // WinCE
|
|
||||||
mInstance = NULL;
|
|
||||||
|
|
||||||
mWINNLSEnableIME = NULL;
|
|
||||||
mWINNLSGetEnableStatus = NULL;
|
|
||||||
|
|
||||||
// XXX If WINNLSEnableIME and WINNLSGetEnableStatus can be used on WinCE,
|
|
||||||
// Should use these.
|
|
||||||
//
|
|
||||||
// mWINNLSGetEnableStatus = (WINNLSGetEnableStatusPtr)WINNLSGetEnableStatus;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
nsWinNLS::~nsWinNLS()
|
|
||||||
{
|
|
||||||
if(mInstance)
|
|
||||||
::FreeLibrary(mInstance);
|
|
||||||
|
|
||||||
mWINNLSEnableIME = NULL;
|
|
||||||
mWINNLSGetEnableStatus = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
PRBool
|
|
||||||
nsWinNLS::SetIMEEnableStatus(HWND aWnd, PRBool aState)
|
|
||||||
{
|
|
||||||
// If mWINNLSEnableIME wasn't loaded, we should return PR_TRUE.
|
|
||||||
// If we cannot load it, we cannot disable the IME. So, the IME enable state
|
|
||||||
// is *always* TRUE.
|
|
||||||
return (mWINNLSEnableIME) ? !!mWINNLSEnableIME(aWnd, aState) : PR_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
PRBool
|
|
||||||
nsWinNLS::GetIMEEnableStatus(HWND aWnd)
|
|
||||||
{
|
|
||||||
// If mWINNLSGetEnableStatus wasn't loaded, we should return PR_TRUE.
|
|
||||||
// If we cannot load it, maybe we cannot load mWINNLSEnableIME too.
|
|
||||||
// So, if mWINNLSEnableIME wasn't loaded, the IME enable state is always TRUE.
|
|
||||||
return (mWINNLSGetEnableStatus) ? !!mWINNLSGetEnableStatus(aWnd) : PR_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
PRBool
|
|
||||||
nsWinNLS::CanUseSetIMEEnableStatus()
|
|
||||||
{
|
|
||||||
return (mWINNLSEnableIME) ? PR_TRUE : PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
PRBool
|
|
||||||
nsWinNLS::CanUseGetIMEEnableStatus()
|
|
||||||
{
|
|
||||||
return (mWINNLSGetEnableStatus) ? PR_TRUE : PR_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -210,6 +210,7 @@ class nsIMM
|
|||||||
typedef LONG (CALLBACK *GetDefaultIMEWndPtr) (HWND);
|
typedef LONG (CALLBACK *GetDefaultIMEWndPtr) (HWND);
|
||||||
typedef BOOL (CALLBACK *GetOpenStatusPtr) (HIMC);
|
typedef BOOL (CALLBACK *GetOpenStatusPtr) (HIMC);
|
||||||
typedef BOOL (CALLBACK *SetOpenStatusPtr) (HIMC, BOOL);
|
typedef BOOL (CALLBACK *SetOpenStatusPtr) (HIMC, BOOL);
|
||||||
|
typedef HIMC (CALLBACK *AssociateContextPtr) (HWND, HIMC);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static nsIMM& LoadModule();
|
static nsIMM& LoadModule();
|
||||||
@ -231,6 +232,7 @@ public:
|
|||||||
LONG GetDefaultIMEWnd(HWND aWnd);
|
LONG GetDefaultIMEWnd(HWND aWnd);
|
||||||
BOOL GetOpenStatus(HIMC aIMC);
|
BOOL GetOpenStatus(HIMC aIMC);
|
||||||
BOOL SetOpenStatus(HIMC aIMC, BOOL aStatus);
|
BOOL SetOpenStatus(HIMC aIMC, BOOL aStatus);
|
||||||
|
HIMC AssociateContext(HWND aWnd, HIMC aIMC);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
HINSTANCE mInstance;
|
HINSTANCE mInstance;
|
||||||
@ -246,36 +248,7 @@ private:
|
|||||||
GetDefaultIMEWndPtr mGetDefaultIMEWnd;
|
GetDefaultIMEWndPtr mGetDefaultIMEWnd;
|
||||||
GetOpenStatusPtr mGetOpenStatus;
|
GetOpenStatusPtr mGetOpenStatus;
|
||||||
SetOpenStatusPtr mSetOpenStatus;
|
SetOpenStatusPtr mSetOpenStatus;
|
||||||
};
|
AssociateContextPtr mAssociateContext;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Native WinNLS wrapper
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
class nsWinNLS
|
|
||||||
{
|
|
||||||
//prototypes for DLL function calls...
|
|
||||||
typedef LONG (CALLBACK *WINNLSEnableIMEPtr) (HWND, BOOL);
|
|
||||||
typedef LONG (CALLBACK *WINNLSGetEnableStatusPtr) (HWND);
|
|
||||||
public:
|
|
||||||
|
|
||||||
static nsWinNLS& LoadModule();
|
|
||||||
|
|
||||||
nsWinNLS(const char* aModuleName = "USER32.DLL");
|
|
||||||
~nsWinNLS();
|
|
||||||
|
|
||||||
PRBool SetIMEEnableStatus(HWND aWnd, PRBool aState);
|
|
||||||
PRBool GetIMEEnableStatus(HWND aWnd);
|
|
||||||
|
|
||||||
PRBool CanUseSetIMEEnableStatus();
|
|
||||||
PRBool CanUseGetIMEEnableStatus();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
HINSTANCE mInstance;
|
|
||||||
WINNLSEnableIMEPtr mWINNLSEnableIME;
|
|
||||||
WINNLSGetEnableStatusPtr mWINNLSGetEnableStatus;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -391,7 +364,7 @@ private:
|
|||||||
#define NS_IMM_GETDEFAULTIMEWND(hWnd, phDefWnd) \
|
#define NS_IMM_GETDEFAULTIMEWND(hWnd, phDefWnd) \
|
||||||
{ \
|
{ \
|
||||||
if (nsToolkit::gAIMMApp) \
|
if (nsToolkit::gAIMMApp) \
|
||||||
return nsToolkit::gAIMMApp->GetDefaultIMEWnd(hWnd, phDefWnd); \
|
nsToolkit::gAIMMApp->GetDefaultIMEWnd(hWnd, phDefWnd); \
|
||||||
else { \
|
else { \
|
||||||
nsIMM& theIMM = nsIMM::LoadModule(); \
|
nsIMM& theIMM = nsIMM::LoadModule(); \
|
||||||
*(phDefWnd) = (HWND)theIMM.GetDefaultIMEWnd(hWnd); \
|
*(phDefWnd) = (HWND)theIMM.GetDefaultIMEWnd(hWnd); \
|
||||||
@ -418,6 +391,16 @@ private:
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define NS_IMM_ASSOCIATECONTEXT(hWnd, hIMC, phOldIMC) \
|
||||||
|
{ \
|
||||||
|
if (nsToolkit::gAIMMApp) \
|
||||||
|
nsToolkit::gAIMMApp->AssociateContext(hWnd, hIMC, phOldIMC); \
|
||||||
|
else { \
|
||||||
|
nsIMM& theIMM = nsIMM::LoadModule(); \
|
||||||
|
*(phOldIMC) = theIMM.AssociateContext(hWnd, hIMC); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Macro for Input Method A/W conversion.
|
// Macro for Input Method A/W conversion.
|
||||||
|
|||||||
@ -836,6 +836,7 @@ nsWindow::nsWindow() : nsBaseWidget()
|
|||||||
mOldStyle = 0;
|
mOldStyle = 0;
|
||||||
mOldExStyle = 0;
|
mOldExStyle = 0;
|
||||||
mPainting = 0;
|
mPainting = 0;
|
||||||
|
mOldIMC = NULL;
|
||||||
|
|
||||||
mLeadByte = '\0';
|
mLeadByte = '\0';
|
||||||
mBlurEventSuppressionLevel = 0;
|
mBlurEventSuppressionLevel = 0;
|
||||||
@ -1631,6 +1632,12 @@ NS_METHOD nsWindow::Destroy()
|
|||||||
if (gAttentionTimerMonitor)
|
if (gAttentionTimerMonitor)
|
||||||
gAttentionTimerMonitor->KillTimer(mWnd);
|
gAttentionTimerMonitor->KillTimer(mWnd);
|
||||||
|
|
||||||
|
// if IME is disabled, restore it.
|
||||||
|
if (mOldIMC) {
|
||||||
|
NS_IMM_ASSOCIATECONTEXT(mWnd, mOldIMC, &mOldIMC);
|
||||||
|
NS_ASSERTION(!mOldIMC, "Another IMC was associated");
|
||||||
|
}
|
||||||
|
|
||||||
HICON icon;
|
HICON icon;
|
||||||
icon = (HICON) nsToolkit::mSendMessage(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM) 0);
|
icon = (HICON) nsToolkit::mSendMessage(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM) 0);
|
||||||
if (icon)
|
if (icon)
|
||||||
@ -4623,15 +4630,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
|||||||
result = PR_TRUE;
|
result = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_ENABLE:
|
|
||||||
if (!wParam) {
|
|
||||||
// We must enable IME for common dialogs.
|
|
||||||
// NOTE: we don't need to recover IME status in nsWindow.
|
|
||||||
// Because when this window will be enabled, we will get focus event.
|
|
||||||
SetIMEEnabled(PR_TRUE);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
if (mEventCallback) {
|
if (mEventCallback) {
|
||||||
PRInt32 fActive = LOWORD(wParam);
|
PRInt32 fActive = LOWORD(wParam);
|
||||||
@ -7358,14 +7356,10 @@ NS_IMETHODIMP nsWindow::SetIMEEnabled(PRBool aState)
|
|||||||
{
|
{
|
||||||
if (sIMEIsComposing)
|
if (sIMEIsComposing)
|
||||||
ResetInputState();
|
ResetInputState();
|
||||||
nsWinNLS &theWinNLS = nsWinNLS::LoadModule();
|
if (!aState != !mOldIMC)
|
||||||
if (!theWinNLS.CanUseSetIMEEnableStatus()) {
|
return NS_OK;
|
||||||
NS_WARNING("WINNLSEnableIME API is not loaded.");
|
NS_IMM_ASSOCIATECONTEXT(mWnd, aState ? mOldIMC : NULL, &mOldIMC);
|
||||||
return NS_ERROR_FAILURE;
|
NS_ASSERTION(!aState || !mOldIMC, "Another IMC was associated");
|
||||||
}
|
|
||||||
PRBool lastStatus = theWinNLS.SetIMEEnableStatus(mWnd, aState);
|
|
||||||
if (aState && !lastStatus)
|
|
||||||
::SendMessage(mWnd, WM_IME_NOTIFY, IMN_OPENSTATUSWINDOW, 0L);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -7373,12 +7367,7 @@ NS_IMETHODIMP nsWindow::SetIMEEnabled(PRBool aState)
|
|||||||
//==========================================================================
|
//==========================================================================
|
||||||
NS_IMETHODIMP nsWindow::GetIMEEnabled(PRBool* aState)
|
NS_IMETHODIMP nsWindow::GetIMEEnabled(PRBool* aState)
|
||||||
{
|
{
|
||||||
nsWinNLS &theWinNLS = nsWinNLS::LoadModule();
|
*aState = !mOldIMC;
|
||||||
if (!theWinNLS.CanUseGetIMEEnableStatus()) {
|
|
||||||
NS_WARNING("WINNLSGetEnableStatus API is not loaded.");
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
*aState = !!theWinNLS.GetIMEEnableStatus(mWnd);
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -428,10 +428,13 @@ protected:
|
|||||||
|
|
||||||
PRInt32 mMenuCmdId;
|
PRInt32 mMenuCmdId;
|
||||||
|
|
||||||
// Window styles used by this window before chrome was hidden
|
// Window styles used by this window before chrome was hidden
|
||||||
DWORD mOldStyle;
|
DWORD mOldStyle;
|
||||||
DWORD mOldExStyle;
|
DWORD mOldExStyle;
|
||||||
|
|
||||||
|
// To enable/disable IME
|
||||||
|
HIMC mOldIMC;
|
||||||
|
|
||||||
static UINT gCurrentKeyboardCP;
|
static UINT gCurrentKeyboardCP;
|
||||||
static HKL gKeyboardLayout;
|
static HKL gKeyboardLayout;
|
||||||
static PRBool gSwitchKeyboardLayout;
|
static PRBool gSwitchKeyboardLayout;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user