Bug 1252058 IMEContentObserver::IMENotificationSender shouldn't post notifications when IMEContentObserver which is the owner of it stopped observing contents r?smaug
When IMEContentObserver stopped observing contents, posting pending notifications to current thread may cause infinite loop because it's impossible to send notifications to widget until the IMEContentObserver is reinitialized.
When IMEContentObserver is reinitialized, pending notifications are automatically flushed. So, in such case, IMEContentObserver::IMEnotificationSender shouldn't clear the pending notifications but don't post the notifications to current thread immediately.
MozReview-Commit-ID: 5xXT3VB4Jjb
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -1547,22 +1547,28 @@ IMEContentObserver::IMENotificationSende
SendPositionChange();
}
}
mIMEContentObserver->mQueuedSender = nullptr;
// If notifications caused some new change, we should notify them now.
if (mIMEContentObserver->NeedsToNotifyIMEOfSomething()) {
- MOZ_LOG(sIMECOLog, LogLevel::Debug,
- ("IMECO: 0x%p IMEContentObserver::IMENotificationSender::Run(), "
- "posting IMENotificationSender to current thread", this));
- mIMEContentObserver->mQueuedSender =
- new IMENotificationSender(mIMEContentObserver);
- NS_DispatchToCurrentThread(mIMEContentObserver->mQueuedSender);
+ if (mIMEContentObserver->GetState() == eState_StoppedObserving) {
+ MOZ_LOG(sIMECOLog, LogLevel::Debug,
+ ("IMECO: 0x%p IMEContentObserver::IMENotificationSender::Run(), "
+ "waiting IMENotificationSender to be reinitialized", this));
+ } else {
+ MOZ_LOG(sIMECOLog, LogLevel::Debug,
+ ("IMECO: 0x%p IMEContentObserver::IMENotificationSender::Run(), "
+ "posting IMENotificationSender to current thread", this));
+ mIMEContentObserver->mQueuedSender =
+ new IMENotificationSender(mIMEContentObserver);
+ NS_DispatchToCurrentThread(mIMEContentObserver->mQueuedSender);
+ }
}
return NS_OK;
}
void
IMEContentObserver::IMENotificationSender::SendFocusSet()
{
if (!CanNotifyIME(eChangeEventType_Focus)) {