Bug 1254104: use docShellIsActive instead of introducing logic that relies on tabbrowser implementation specifics. r=evilpies a=ritu
authorMike de Boer <mdeboer@mozilla.com>
Wed, 16 Mar 2016 12:51:50 +0100
changeset 310212 774b367ca02d061883d06deded7ccf837bba4467
parent 310211 fcb8fe0f0090a6a20e98360582f0f26c600e65e4
child 310213 1cdcf38a2a57c943c5838c561617db8370c53331
push id9297
push userkwierso@gmail.com
push dateWed, 23 Mar 2016 23:13:23 +0000
treeherdermozilla-aurora@b424b3c0b111 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpies, ritu
bugs1254104
milestone47.0a2
Bug 1254104: use docShellIsActive instead of introducing logic that relies on tabbrowser implementation specifics. r=evilpies a=ritu MozReview-Commit-ID: Am706xBPQ0B
toolkit/modules/PopupNotifications.jsm
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -379,17 +379,17 @@ PopupNotifications.prototype = {
 
     let existingNotification = this.getNotification(id, browser);
     if (existingNotification)
       this._remove(existingNotification);
 
     let notifications = this._getNotificationsForBrowser(browser);
     notifications.push(notification);
 
-    let isActiveBrowser = this._isActiveBrowser(browser);
+    let isActiveBrowser = browser.docShellIsActive;
     let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
     let isActiveWindow = fm.activeWindow == this.window;
 
     if (isActiveBrowser) {
       if (isActiveWindow) {
         // show panel now
         this._update(notifications, new Set([notification.anchorElement]), true);
       } else {
@@ -455,34 +455,34 @@ PopupNotifications.prototype = {
       }
 
       this._fireCallback(notification, NOTIFICATION_EVENT_REMOVED);
       return false;
     }, this);
 
     this._setNotificationsForBrowser(aBrowser, notifications);
 
-    if (this._isActiveBrowser(aBrowser)) {
+    if (aBrowser.docShellIsActive) {
       // get the anchor element if the browser has defined one so it will
       // _update will handle both the tabs iconBox and non-tab permission
       // anchors.
       this._update(notifications, this._getAnchorsForNotifications(notifications,
         getAnchorFromBrowser(aBrowser)));
     }
   },
 
   /**
    * Removes a Notification.
    * @param notification
    *        The Notification object to remove.
    */
   remove: function PopupNotifications_remove(notification) {
     this._remove(notification);
 
-    if (this._isActiveBrowser(notification.browser)) {
+    if (notification.browser.docShellIsActive) {
       let notifications = this._getNotificationsForBrowser(notification.browser);
       this._update(notifications);
     }
   },
 
   handleEvent: function (aEvent) {
     switch (aEvent.type) {
       case "popuphidden":
@@ -530,17 +530,17 @@ PopupNotifications.prototype = {
     let notifications = this._getNotificationsForBrowser(notification.browser);
     if (!notifications)
       return;
 
     var index = notifications.indexOf(notification);
     if (index == -1)
       return;
 
-    if (this._isActiveBrowser(notification.browser))
+    if (notification.browser.docShellIsActive)
       notification.anchorElement.removeAttribute(ICON_ATTRIBUTE_SHOWING);
 
     // remove the notification
     notifications.splice(index, 1);
     this._fireCallback(notification, NOTIFICATION_EVENT_REMOVED);
   },
 
   /**
@@ -936,24 +936,16 @@ PopupNotifications.prototype = {
       if (notification.anchorElement)
         anchors.add(notification.anchorElement)
     }
     if (defaultAnchor && !anchors.size)
       anchors.add(defaultAnchor);
     return anchors;
   },
 
-  _isActiveBrowser: function (browser) {
-    // Note: This helper only exists, because in e10s builds,
-    // we can't access the docShell of a browser from chrome.
-    return browser.docShell
-      ? browser.docShell.isActive
-      : (this.window.gBrowser.selectedBrowser == browser);
-  },
-
   _onIconBoxCommand: function PopupNotifications_onIconBoxCommand(event) {
     // Left click, space or enter only
     let type = event.type;
     if (type == "click" && event.button != 0)
       return;
 
     if (type == "keypress" &&
         !(event.charCode == Ci.nsIDOMKeyEvent.DOM_VK_SPACE ||