bug 163572 : converted string is inserted every time space key is pressed patch by masayuki@d-toybox.com (r=pinkerton,bryner,amardare,emaijala,sfraser,roc, sr=bryner,sfraser,roc)

This commit is contained in:
jshin%mailaps.org 2004-11-13 11:27:09 +00:00
Родитель ac7e4ac4f6
Коммит ffd7ee363f
12 изменённых файлов: 63 добавлений и 16 удалений

Просмотреть файл

@ -2104,30 +2104,35 @@ nsEditor::NotifyIMEOnFocus()
{
mNeedRecoverIMEOpenState = PR_FALSE;
if(gDontCareForIMEOnFocusPassword
|| !(mFlags & nsIPlaintextEditor::eEditorPasswordMask))
return NS_OK;
nsCOMPtr<nsIKBStateControl> kb;
nsresult res = GetKBStateControl(getter_AddRefs(kb));
if (NS_FAILED(res))
return res;
if (kb) {
PRBool isOpen;
res = kb->GetIMEOpenState(&isOpen);
if (!kb)
return NS_OK;
res = kb->CancelIMEComposition();
if (NS_FAILED(res))
kb->ResetInputState();
if(gDontCareForIMEOnFocusPassword
|| !(mFlags & nsIPlaintextEditor::eEditorPasswordMask))
return NS_OK;
PRBool isOpen;
res = kb->GetIMEOpenState(&isOpen);
if (NS_FAILED(res))
return res;
if (isOpen) {
res = kb->SetIMEOpenState(PR_FALSE);
if (NS_FAILED(res))
return res;
if (isOpen) {
res = kb->SetIMEOpenState(PR_FALSE);
if (NS_FAILED(res))
return res;
}
mNeedRecoverIMEOpenState = isOpen;
}
mNeedRecoverIMEOpenState = isOpen;
return NS_OK;
}

Просмотреть файл

@ -85,6 +85,10 @@ class nsIKBStateControl : public nsISupports {
*/
NS_IMETHOD GetIMEOpenState(PRBool* aState) = 0;
/*
* Destruct and don't commit the IME composition string.
*/
NS_IMETHOD CancelIMEComposition() = 0;
};
#endif // nsIKBStateControl_h__

Просмотреть файл

@ -247,6 +247,7 @@ public:
NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(PRBool aState);
NS_IMETHOD GetIMEOpenState(PRBool* aState);
NS_IMETHOD CancelIMEComposition();
protected:

Просмотреть файл

@ -2047,6 +2047,11 @@ NS_IMETHODIMP nsChildView::GetIMEOpenState(PRBool* aState)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsChildView::CancelIMEComposition()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
//
// GetQuickDrawPort

Просмотреть файл

@ -2355,6 +2355,10 @@ NS_IMETHODIMP nsWidget::GetIMEOpenState(PRBool* aState) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsWidget::CancelIMEComposition() {
return NS_ERROR_NOT_IMPLEMENTED;
}
/* virtual */
GtkWindow *nsWidget::GetTopLevelWindow(void)
{

Просмотреть файл

@ -172,6 +172,7 @@ public:
NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(PRBool aState);
NS_IMETHOD GetIMEOpenState(PRBool* aState);
NS_IMETHOD CancelIMEComposition();
void InitEvent(nsGUIEvent& event, nsPoint* aPoint = nsnull);

Просмотреть файл

@ -2653,6 +2653,10 @@ NS_IMETHODIMP nsWindow::GetIMEOpenState(PRBool* aState) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsWindow::CancelIMEComposition() {
return NS_ERROR_NOT_IMPLEMENTED;
}
#if !TARGET_CARBON

Просмотреть файл

@ -227,6 +227,7 @@ public:
NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(PRBool aState);
NS_IMETHOD GetIMEOpenState(PRBool* aState);
NS_IMETHOD CancelIMEComposition();
protected:

Просмотреть файл

@ -229,6 +229,10 @@ NS_IMETHODIMP nsWidget::GetIMEOpenState(PRBool* aState) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsWidget::CancelIMEComposition() {
return NS_ERROR_NOT_IMPLEMENTED;
}
//-------------------------------------------------------------------------
//
// Hide or show this component

Просмотреть файл

@ -215,6 +215,7 @@ public:
NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(PRBool aState);
NS_IMETHOD GetIMEOpenState(PRBool* aState);
NS_IMETHOD CancelIMEComposition();
inline void InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint = nsnull)
{

Просмотреть файл

@ -6554,7 +6554,7 @@ NS_IMETHODIMP nsWindow::ResetInputState()
NS_IMETHODIMP nsWindow::SetIMEOpenState(PRBool aState)
{
#ifdef DEBUG_KBSTATE
printf("SetImeOpenState %s\n", (aState ? "Open" : "Close"));
printf("SetIMEOpenState %s\n", (aState ? "Open" : "Close"));
#endif
HIMC hIMC;
NS_IMM_GETCONTEXT(mWnd, hIMC);
@ -6580,6 +6580,22 @@ NS_IMETHODIMP nsWindow::GetIMEOpenState(PRBool* aState)
return NS_OK;
}
//==========================================================================
NS_IMETHODIMP nsWindow::CancelIMEComposition()
{
#ifdef DEBUG_KBSTATE
printf("CancelIMEComposition\n");
#endif
HIMC hIMC;
NS_IMM_GETCONTEXT(mWnd, hIMC);
if (hIMC) {
BOOL ret = FALSE;
NS_IMM_NOTIFYIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, NULL, ret);
NS_IMM_RELEASECONTEXT(mWnd, hIMC);
}
return NS_OK;
}
#define PT_IN_RECT(pt, rc) ((pt).x>(rc).left && (pt).x <(rc).right && (pt).y>(rc).top && (pt).y<(rc).bottom)

Просмотреть файл

@ -362,6 +362,7 @@ public:
NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(PRBool aState);
NS_IMETHOD GetIMEOpenState(PRBool* aState);
NS_IMETHOD CancelIMEComposition();
PRBool IMEMouseHandling(PRUint32 aEventType, PRInt32 aAction, LPARAM lParam);
PRBool IMECompositionHitTest(PRUint32 aEventType, POINT * ptPos);