Bug 1018486 - Part 7: Changes in widget/gtk/, r=masayuki

MozReview-Commit-ID: 2uJ9flIaCEY
This commit is contained in:
Michael Layzell 2016-07-18 14:14:10 -04:00
Родитель b2047d9636
Коммит 0c311dc0f9
1 изменённых файлов: 5 добавлений и 6 удалений

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

@ -1336,6 +1336,9 @@ IMContextWrapper::DispatchCompositionStart(GtkIMContext* aContext)
return false;
}
// Keep the last focused window alive
RefPtr<nsWindow> lastFocusedWindow(mLastFocusedWindow);
// XXX The composition start point might be changed by composition events
// even though we strongly hope it doesn't happen.
// Every composition event should have the start offset for the result
@ -1347,7 +1350,6 @@ IMContextWrapper::DispatchCompositionStart(GtkIMContext* aContext)
mProcessingKeyEvent->type == GDK_KEY_PRESS) {
// If this composition is started by a native keydown event, we need to
// dispatch our keydown event here (before composition start).
nsCOMPtr<nsIWidget> kungFuDeathGrip = mLastFocusedWindow;
bool isCancelled;
mLastFocusedWindow->DispatchKeyDownEvent(mProcessingKeyEvent,
&isCancelled);
@ -1355,8 +1357,8 @@ IMContextWrapper::DispatchCompositionStart(GtkIMContext* aContext)
("0x%p DispatchCompositionStart(), FAILED, keydown event "
"is dispatched",
this));
if (static_cast<nsWindow*>(kungFuDeathGrip.get())->IsDestroyed() ||
kungFuDeathGrip != mLastFocusedWindow) {
if (lastFocusedWindow->IsDestroyed() ||
lastFocusedWindow != mLastFocusedWindow) {
MOZ_LOG(gGtkIMLog, LogLevel::Error,
("0x%p DispatchCompositionStart(), FAILED, the focused "
"widget was destroyed/changed by keydown event",
@ -1381,7 +1383,6 @@ IMContextWrapper::DispatchCompositionStart(GtkIMContext* aContext)
this, mCompositionStart));
mCompositionState = eCompositionState_CompositionStartDispatched;
nsEventStatus status;
RefPtr<nsWindow> lastFocusedWindow = mLastFocusedWindow;
dispatcher->StartComposition(status);
if (lastFocusedWindow->IsDestroyed() ||
lastFocusedWindow != mLastFocusedWindow) {
@ -1417,7 +1418,6 @@ IMContextWrapper::DispatchCompositionChangeEvent(
("0x%p DispatchCompositionChangeEvent(), the composition "
"wasn't started, force starting...",
this));
nsCOMPtr<nsIWidget> kungFuDeathGrip = mLastFocusedWindow;
if (!DispatchCompositionStart(aContext)) {
return false;
}
@ -1522,7 +1522,6 @@ IMContextWrapper::DispatchCompositionCommitEvent(
("0x%p DispatchCompositionCommitEvent(), "
"the composition wasn't started, force starting...",
this));
nsCOMPtr<nsIWidget> kungFuDeathGrip(mLastFocusedWindow);
if (!DispatchCompositionStart(aContext)) {
return false;
}