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
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -1346,67 +1346,73 @@ ContentCacheInParent::MaybeNotifyIME(nsI
}
}
void
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);
}
}
// Layout change notification should be notified after selection change
// 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);
}
}
// Finally, send composition update notification because it notifies IME of
// 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);
}
}
/*****************************************************************************
* mozilla::ContentCache::TextRectArray
*****************************************************************************/
LayoutDeviceIntRect