Bug 1194706 - make sure that the notification icons and doorhangers are shown in undocked chat windows too. r=Mossop, a=lizzard
authorMike de Boer <mdeboer@mozilla.com>
Mon, 12 Oct 2015 23:03:23 +0200
changeset 289541 655607703bb1
parent 289540 b35d2786d527
child 289542 2f828f5ec27c
push id5177
push usercbook@mozilla.com
push date2015-10-15 09:10 +0000
treeherdermozilla-beta@2f828f5ec27c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMossop, lizzard
bugs1194706
milestone42.0
Bug 1194706 - make sure that the notification icons and doorhangers are shown in undocked chat windows too. r=Mossop, a=lizzard
toolkit/modules/PopupNotifications.jsm
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -686,53 +686,56 @@ PopupNotifications.prototype = {
    *                       currently displayed notifications will be left alone.
    */
   _update: function PopupNotifications_update(notifications, anchors = new Set(), dismissShowing = false) {
     if (anchors instanceof Ci.nsIDOMXULElement)
       anchors = new Set([anchors]);
 
     if (!notifications)
       notifications = this._currentNotifications;
-    let notificationsToShow = [];
-    // Filter out notifications that have been dismissed.
-    notificationsToShow = notifications.filter(function (n) {
-      return !n.dismissed && !n.options.neverShow;
-    });
 
-    if (!anchors.size && notificationsToShow.length)
-      anchors = this._getAnchorsForNotifications(notificationsToShow);
+    let haveNotifications = notifications.length > 0;
+    if (!anchors.size && haveNotifications)
+      anchors = this._getAnchorsForNotifications(notifications);
 
     let useIconBox = !!this.iconBox;
     if (useIconBox && anchors.size) {
       for (let anchor of anchors) {
         if (anchor.parentNode == this.iconBox)
           continue;
         useIconBox = false;
         break;
       }
     }
 
+    // Filter out notifications that have been dismissed.
+    let notificationsToShow = notifications.filter(function (n) {
+      return !n.dismissed && !n.options.neverShow;
+    });
+
     if (useIconBox) {
-      // hide icons of the previous tab.
+      // Hide icons of the previous tab.
       this._hideIcons();
     }
 
-    let haveNotifications = notifications.length > 0;
     if (haveNotifications) {
-      if (useIconBox) {
-        this._showIcons(notifications);
-        this.iconBox.hidden = false;
-      } else if (anchors.size) {
-        this._updateAnchorIcons(notifications, anchors);
-      }
-
       // Also filter out notifications that are for a different anchor.
       notificationsToShow = notificationsToShow.filter(function (n) {
         return anchors.has(n.anchorElement);
       });
+
+      if (useIconBox) {
+        this._showIcons(notifications);
+        this.iconBox.hidden = false;
+        // Make sure that panels can only be attached to anchors of shown
+        // notifications inside an iconBox.
+        anchors = this._getAnchorsForNotifications(notificationsToShow);
+      } else if (anchors.size) {
+        this._updateAnchorIcons(notifications, anchors);
+      }
     }
 
     if (notificationsToShow.length > 0) {
       for (let anchorElement of anchors) {
         this._showPanel(notificationsToShow, anchorElement);
         break;
       }
     } else {