Bug 1379448 - ContentCacheInParent::FlushPendingNotifications() should do nothing if aWidget is nullptr r=m_kato

Due to the fix of bug 1376424, ContentCacheInParent::FlushPendingNotifications() may be called when aWidget is nullptr. In this case, it doesn't need to do anything.  So, it should ignore the call.

MozReview-Commit-ID: Fj3J76v6Xuk

--HG--
extra : rebase_source : 18c722628a3ae8fa50beca3908d5e732cec404d9
This commit is contained in:
Masayuki Nakano 2017-07-10 17:33:26 +09:00
Родитель 728dbbc41f
Коммит f303a1f631
1 изменённых файлов: 17 добавлений и 11 удалений

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

@ -1351,28 +1351,34 @@ ContentCacheInParent::FlushPendingNotifications(nsIWidget* aWidget)
{
MOZ_ASSERT(!mPendingEventsNeedingAck);
// If the TabParent's widget has already gone, this can do nothing since
// widget is necessary to notify IME of something.
if (!aWidget) {
return;
}
// New notifications which are notified during flushing pending notifications
// should be merged again.
mPendingEventsNeedingAck++;
nsCOMPtr<nsIWidget> kungFuDeathGrip(aWidget);
nsCOMPtr<nsIWidget> widget = aWidget;
// First, text change notification should be sent because selection change
// notification notifies IME of current selection range in the latest content.
// So, IME may need the latest content before that.
if (mPendingTextChange.HasNotification()) {
IMENotification notification(mPendingTextChange);
if (!aWidget->Destroyed()) {
if (!widget->Destroyed()) {
mPendingTextChange.Clear();
IMEStateManager::NotifyIME(notification, aWidget, &mTabParent);
IMEStateManager::NotifyIME(notification, widget, &mTabParent);
}
}
if (mPendingSelectionChange.HasNotification()) {
IMENotification notification(mPendingSelectionChange);
if (!aWidget->Destroyed()) {
if (!widget->Destroyed()) {
mPendingSelectionChange.Clear();
IMEStateManager::NotifyIME(notification, aWidget, &mTabParent);
IMEStateManager::NotifyIME(notification, widget, &mTabParent);
}
}
@ -1380,9 +1386,9 @@ ContentCacheInParent::FlushPendingNotifications(nsIWidget* aWidget)
// notification because IME may want to query position of new caret position.
if (mPendingLayoutChange.HasNotification()) {
IMENotification notification(mPendingLayoutChange);
if (!aWidget->Destroyed()) {
if (!widget->Destroyed()) {
mPendingLayoutChange.Clear();
IMEStateManager::NotifyIME(notification, aWidget, &mTabParent);
IMEStateManager::NotifyIME(notification, widget, &mTabParent);
}
}
@ -1390,18 +1396,18 @@ ContentCacheInParent::FlushPendingNotifications(nsIWidget* aWidget)
// finishing handling whole sending events.
if (mPendingCompositionUpdate.HasNotification()) {
IMENotification notification(mPendingCompositionUpdate);
if (!aWidget->Destroyed()) {
if (!widget->Destroyed()) {
mPendingCompositionUpdate.Clear();
IMEStateManager::NotifyIME(notification, aWidget, &mTabParent);
IMEStateManager::NotifyIME(notification, widget, &mTabParent);
}
}
if (!--mPendingEventsNeedingAck && !aWidget->Destroyed() &&
if (!--mPendingEventsNeedingAck && !widget->Destroyed() &&
(mPendingTextChange.HasNotification() ||
mPendingSelectionChange.HasNotification() ||
mPendingLayoutChange.HasNotification() ||
mPendingCompositionUpdate.HasNotification())) {
FlushPendingNotifications(aWidget);
FlushPendingNotifications(widget);
}
}