Bug 1140832 Don't call gtk_im_context_reset() during "delete_surrounding" notification r=m_kato

This commit is contained in:
Masayuki Nakano 2015-03-17 16:07:02 +09:00
parent d560040e6d
commit 23b86c9b04
2 changed files with 16 additions and 2 deletions

View File

@ -9,6 +9,7 @@
#include "nsGtkIMModule.h"
#include "nsWindow.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/Likely.h"
#include "mozilla/MiscEvents.h"
#include "mozilla/Preferences.h"
@ -74,6 +75,7 @@ nsGtkIMModule::nsGtkIMModule(nsWindow* aOwnerWindow)
, mCompositionTargetOffset(UINT32_MAX)
, mCompositionState(eCompositionState_NotComposing)
, mIsIMFocused(false)
, mIsDeletingSurrounding(false)
{
#ifdef PR_LOGGING
if (!gGtkIMLog) {
@ -670,8 +672,9 @@ nsGtkIMModule::OnSelectionChange(nsWindow* aCaller)
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
("GtkIMModule(%p): OnSelectionChange(aCaller=0x%p), "
"mCompositionState=%s",
this, aCaller, GetCompositionStateName()));
"mCompositionState=%s, mIsDeletingSurrounding=%s",
this, aCaller, GetCompositionStateName(),
mIsDeletingSurrounding ? "true" : "false"));
if (aCaller != mLastFocusedWindow) {
PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
@ -681,6 +684,12 @@ nsGtkIMModule::OnSelectionChange(nsWindow* aCaller)
return;
}
// If the selection change is caused by deleting surrounding text,
// we shouldn't need to notify IME of selection change.
if (mIsDeletingSurrounding) {
return;
}
ResetIME();
}
@ -850,6 +859,8 @@ nsGtkIMModule::OnDeleteSurroundingNative(GtkIMContext *aContext,
return FALSE;
}
AutoRestore<bool> saveDeletingSurrounding(mIsDeletingSurrounding);
mIsDeletingSurrounding = true;
if (NS_SUCCEEDED(DeleteText(aContext, aOffset, (uint32_t)aNChars))) {
return TRUE;
}

View File

@ -183,6 +183,9 @@ protected:
// keypress event. If this is true, the keydown event has been dispatched.
// Then, DispatchCompositionStart() doesn't dispatch keydown event.
bool mKeyDownEventWasSent;
// mIsDeletingSurrounding is true while OnDeleteSurroundingNative() is
// trying to delete the surrounding text.
bool mIsDeletingSurrounding;
// sLastFocusedModule is a pointer to the last focused instance of this
// class. When a instance is destroyed and sLastFocusedModule refers it,