Bug 1254104: use docShellIsActive instead of introducing logic that relies on tabbrowser implementation specifics. r=evilpies a=ritu

MozReview-Commit-ID: Am706xBPQ0B
This commit is contained in:
Mike de Boer 2016-03-16 12:51:50 +01:00
parent eb266fd5f1
commit 5b52115fcc

View File

@ -384,7 +384,7 @@ PopupNotifications.prototype = {
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;
@ -460,7 +460,7 @@ PopupNotifications.prototype = {
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.
@ -477,7 +477,7 @@ PopupNotifications.prototype = {
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);
}
@ -535,7 +535,7 @@ PopupNotifications.prototype = {
if (index == -1)
return;
if (this._isActiveBrowser(notification.browser))
if (notification.browser.docShellIsActive)
notification.anchorElement.removeAttribute(ICON_ATTRIBUTE_SHOWING);
// remove the notification
@ -941,14 +941,6 @@ PopupNotifications.prototype = {
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;