Bug 558976 part.4 Implement nsIWidget::NotifyIME() on GTK r=karlt

This commit is contained in:
Masayuki Nakano 2013-03-06 15:14:34 +09:00
Родитель ccb7608efe
Коммит 5c0f3e03ce
4 изменённых файлов: 37 добавлений и 24 удалений

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

@ -455,14 +455,15 @@ nsGtkIMModule::ResetIME()
}
nsresult
nsGtkIMModule::ResetInputState(nsWindow* aCaller)
nsGtkIMModule::CommitIMEComposition(nsWindow* aCaller)
{
if (MOZ_UNLIKELY(IsDestroyed())) {
return NS_OK;
}
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
("GtkIMModule(%p): ResetInputState, aCaller=%p, mCompositionState=%s",
("GtkIMModule(%p): CommitIMEComposition, aCaller=%p, "
"mCompositionState=%s",
this, aCaller, GetCompositionStateName()));
if (aCaller != mLastFocusedWindow) {
@ -558,7 +559,7 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller,
// Release current IME focus if IME is enabled.
if (changingEnabledState && IsEditable()) {
ResetInputState(mLastFocusedWindow);
CommitIMEComposition(mLastFocusedWindow);
Blur();
}

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

@ -84,7 +84,7 @@ public:
bool aKeyDownEventWasSent = false);
// IME related nsIWidget methods.
nsresult ResetInputState(nsWindow* aCaller);
nsresult CommitIMEComposition(nsWindow* aCaller);
void SetInputContext(nsWindow* aCaller,
const InputContext* aContext,
const InputContextAction* aAction);

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

@ -5845,9 +5845,38 @@ nsChildWindow::~nsChildWindow()
}
NS_IMETHODIMP
nsWindow::ResetInputState()
nsWindow::NotifyIME(NotificationToIME aNotification)
{
return mIMModule ? mIMModule->ResetInputState(this) : NS_OK;
if (MOZ_UNLIKELY(!mIMModule)) {
switch (aNotification) {
case NOTIFY_IME_OF_CURSOR_POS_CHANGED:
case REQUEST_TO_COMMIT_COMPOSITION:
case REQUEST_TO_CANCEL_COMPOSITION:
case NOTIFY_IME_OF_FOCUS:
case NOTIFY_IME_OF_BLUR:
return NS_ERROR_NOT_AVAILABLE;
default:
break;
}
}
switch (aNotification) {
// TODO: We should replace NOTIFY_IME_OF_CURSOR_POS_CHANGED with
// NOTIFY_IME_OF_SELECTION_CHANGE. The required behavior is
// really different from committing composition.
case NOTIFY_IME_OF_CURSOR_POS_CHANGED:
case REQUEST_TO_COMMIT_COMPOSITION:
return mIMModule->CommitIMEComposition(this);
case REQUEST_TO_CANCEL_COMPOSITION:
return mIMModule->CancelIMEComposition(this);
case NOTIFY_IME_OF_FOCUS:
mIMModule->OnFocusChangeInGecko(true);
return NS_OK;
case NOTIFY_IME_OF_BLUR:
mIMModule->OnFocusChangeInGecko(false);
return NS_OK;
default:
return NS_ERROR_NOT_IMPLEMENTED;
}
}
NS_IMETHODIMP_(void)
@ -5878,21 +5907,6 @@ nsWindow::GetInputContext()
return context;
}
NS_IMETHODIMP
nsWindow::CancelIMEComposition()
{
return mIMModule ? mIMModule->CancelIMEComposition(this) : NS_OK;
}
NS_IMETHODIMP
nsWindow::OnIMEFocusChange(bool aFocus)
{
if (mIMModule) {
mIMModule->OnFocusChangeInGecko(aFocus);
}
return NS_OK;
}
NS_IMETHODIMP
nsWindow::GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState)
{

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

@ -255,12 +255,10 @@ public:
bool DispatchKeyDownEvent(GdkEventKey *aEvent,
bool *aIsCancelled);
NS_IMETHOD ResetInputState();
NS_IMETHOD NotifyIME(NotificationToIME aNotification) MOZ_OVERRIDE;
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
const InputContextAction& aAction);
NS_IMETHOD_(InputContext) GetInputContext();
NS_IMETHOD CancelIMEComposition();
NS_IMETHOD OnIMEFocusChange(bool aFocus);
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState);
// These methods are for toplevel windows only.