Bug 891316 part.8 Refactor other nsIMM32Handler::On*() r=jimm

This commit is contained in:
Masayuki Nakano 2013-07-18 17:12:31 +09:00
Родитель d7330fa349
Коммит 0e0d6169b5
2 изменённых файлов: 27 добавлений и 21 удалений

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

@ -246,8 +246,7 @@ nsIMM32Handler::ProcessInputLangChangeMessage(nsWindow* aWindow,
aResult.mConsumed = false; aResult.mConsumed = false;
// We don't need to create the instance of the handler here. // We don't need to create the instance of the handler here.
if (gIMM32Handler) { if (gIMM32Handler) {
aResult.mConsumed = gIMM32Handler->OnInputLangChange(aWindow, wParam, lParam, aResult);
gIMM32Handler->OnInputLangChange(aWindow, wParam, lParam);
} }
InitKeyboardLayout(reinterpret_cast<HKL>(lParam)); InitKeyboardLayout(reinterpret_cast<HKL>(lParam));
// We can release the instance here, because the instance may be never // We can release the instance here, because the instance may be never
@ -316,11 +315,7 @@ nsIMM32Handler::ProcessMessage(nsWindow* aWindow, UINT msg,
if (!gIMM32Handler) { if (!gIMM32Handler) {
return false; return false;
} }
aResult.mConsumed = gIMM32Handler->OnChar(aWindow, wParam, lParam); return gIMM32Handler->OnChar(aWindow, wParam, lParam, aResult);
// If we consume this message, we should return "processed", otherwise,
// the message should be handled on nsWindow, so, we should return
// "not processed" at that time.
return aResult.mConsumed;
default: default:
return false; return false;
}; };
@ -359,9 +354,7 @@ nsIMM32Handler::ProcessMessageForPlugin(nsWindow* aWindow, UINT msg,
if (!gIMM32Handler) { if (!gIMM32Handler) {
return false; return false;
} }
aResult.mConsumed = return gIMM32Handler->OnCharOnPlugin(aWindow, wParam, lParam, aResult);
gIMM32Handler->OnCharOnPlugin(aWindow, wParam, lParam);
return false; // is going to be handled by nsWindow.
case WM_IME_COMPOSITIONFULL: case WM_IME_COMPOSITIONFULL:
case WM_IME_CONTROL: case WM_IME_CONTROL:
case WM_IME_KEYDOWN: case WM_IME_KEYDOWN:
@ -379,10 +372,11 @@ nsIMM32Handler::ProcessMessageForPlugin(nsWindow* aWindow, UINT msg,
* message handlers * message handlers
****************************************************************************/ ****************************************************************************/
bool void
nsIMM32Handler::OnInputLangChange(nsWindow* aWindow, nsIMM32Handler::OnInputLangChange(nsWindow* aWindow,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam,
MSGResult& aResult)
{ {
PR_LOG(gIMM32Log, PR_LOG_ALWAYS, PR_LOG(gIMM32Log, PR_LOG_ALWAYS,
("IMM32: OnInputLangChange, hWnd=%08x, wParam=%08x, lParam=%08x\n", ("IMM32: OnInputLangChange, hWnd=%08x, wParam=%08x, lParam=%08x\n",
@ -395,7 +389,7 @@ nsIMM32Handler::OnInputLangChange(nsWindow* aWindow,
HandleEndComposition(aWindow); HandleEndComposition(aWindow);
} }
return false; aResult.mConsumed = false;
} }
bool bool
@ -718,10 +712,15 @@ nsIMM32Handler::OnIMESetContext(nsWindow* aWindow,
bool bool
nsIMM32Handler::OnChar(nsWindow* aWindow, nsIMM32Handler::OnChar(nsWindow* aWindow,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam,
MSGResult& aResult)
{ {
// The return value must be same as aResult.mConsumed because only when we
// consume the message, the caller shouldn't do anything anymore but
// otherwise, the caller should handle the message.
aResult.mConsumed = false;
if (IsIMECharRecordsEmpty()) { if (IsIMECharRecordsEmpty()) {
return false; return aResult.mConsumed;
} }
WPARAM recWParam; WPARAM recWParam;
LPARAM recLParam; LPARAM recLParam;
@ -736,12 +735,13 @@ nsIMM32Handler::OnChar(nsWindow* aWindow,
// of course, this shouldn't happen. // of course, this shouldn't happen.
if (recWParam != wParam || recLParam != lParam) { if (recWParam != wParam || recLParam != lParam) {
ResetIMECharRecords(); ResetIMECharRecords();
return false; return aResult.mConsumed;
} }
// Eat the char message which is caused by WM_IME_CHAR because we should // Eat the char message which is caused by WM_IME_CHAR because we should
// have processed the IME messages, so, this message could be come from // have processed the IME messages, so, this message could be come from
// a windowless plug-in. // a windowless plug-in.
return true; aResult.mConsumed = true;
return aResult.mConsumed;
} }
/**************************************************************************** /****************************************************************************
@ -877,8 +877,11 @@ nsIMM32Handler::OnIMESetContextOnPlugin(nsWindow* aWindow,
bool bool
nsIMM32Handler::OnCharOnPlugin(nsWindow* aWindow, nsIMM32Handler::OnCharOnPlugin(nsWindow* aWindow,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam,
MSGResult& aResult)
{ {
// We should never consume char message on windowless plugin.
aResult.mConsumed = false;
if (IsIMECharRecordsEmpty()) { if (IsIMECharRecordsEmpty()) {
return false; return false;
} }

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

@ -192,9 +192,12 @@ protected:
MSGResult& aResult); MSGResult& aResult);
bool OnIMECharOnPlugin(nsWindow* aWindow, WPARAM wParam, LPARAM lParam, bool OnIMECharOnPlugin(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
MSGResult& aResult); MSGResult& aResult);
bool OnChar(nsWindow* aWindow, WPARAM wParam, LPARAM lParam); bool OnChar(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
bool OnCharOnPlugin(nsWindow* aWindow, WPARAM wParam, LPARAM lParam); MSGResult& aResult);
bool OnInputLangChange(nsWindow* aWindow, WPARAM wParam, LPARAM lParam); bool OnCharOnPlugin(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
MSGResult& aResult);
void OnInputLangChange(nsWindow* aWindow, WPARAM wParam, LPARAM lParam,
MSGResult& aResult);
// These message handlers don't use instance members, we should not create // These message handlers don't use instance members, we should not create
// the instance by the messages. So, they should be static. // the instance by the messages. So, they should be static.