Bug 1379448 - ContentCacheInParent::FlushPendingNotifications() should do nothing if aWidget is nullptr r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 10 Jul 2017 17:33:26 +0900
changeset 606625 79e20040e07764728bdc55fea7863c507ff3f053
parent 606624 9a21d339da7eb8cafd86e38d280e8500143b4f8a
child 636808 f295d12ba6f7af2a327e1fe9d88f3d08ea5afedd
push id67745
push usermasayuki@d-toybox.com
push dateTue, 11 Jul 2017 06:41:00 +0000
reviewersm_kato
bugs1379448, 1376424
milestone56.0a1
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
widget/ContentCache.cpp
--- 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