mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
Bug 771818 - Using WeakMap to store popup notification object. r=MattN
--HG-- extra : rebase_source : 8d798389f01f12a538c99b33d3c45ff50ae55894
This commit is contained in:
parent
745328a524
commit
a4f589abb7
@ -15,6 +15,8 @@ const NOTIFICATION_EVENT_SHOWN = "shown";
|
||||
const ICON_SELECTOR = ".notification-anchor-icon";
|
||||
const ICON_ATTRIBUTE_SHOWING = "showing";
|
||||
|
||||
let popupNotificationsMap = new WeakMap();
|
||||
|
||||
/**
|
||||
* Notification object describes a single popup notification.
|
||||
*
|
||||
@ -351,7 +353,7 @@ PopupNotifications.prototype = {
|
||||
return this._getNotificationsForBrowser(this.tabbrowser.selectedBrowser);
|
||||
},
|
||||
set _currentNotifications(a) {
|
||||
return this.tabbrowser.selectedBrowser.popupNotifications = a;
|
||||
return this._setNotificationsForBrowser(this.tabbrowser.selectedBrowser, a);
|
||||
},
|
||||
|
||||
_remove: function PopupNotifications_removeHelper(notification) {
|
||||
@ -431,7 +433,7 @@ PopupNotifications.prototype = {
|
||||
|
||||
popupnotification.appendChild(item);
|
||||
}, this);
|
||||
|
||||
|
||||
if (n.secondaryActions.length) {
|
||||
let closeItemSeparator = doc.createElementNS(XUL_NS, "menuseparator");
|
||||
popupnotification.appendChild(closeItemSeparator);
|
||||
@ -539,11 +541,21 @@ PopupNotifications.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets and sets notifications for the browser.
|
||||
*/
|
||||
_getNotificationsForBrowser: function PopupNotifications_getNotifications(browser) {
|
||||
if (browser.popupNotifications)
|
||||
return browser.popupNotifications;
|
||||
|
||||
return browser.popupNotifications = [];
|
||||
let notifications = popupNotificationsMap.get(browser);
|
||||
if (!notifications) {
|
||||
// Initialize the WeakMap for the browser so callers can reference/manipulate the array.
|
||||
notifications = [];
|
||||
popupNotificationsMap.set(browser, notifications);
|
||||
}
|
||||
return notifications;
|
||||
},
|
||||
_setNotificationsForBrowser: function PopupNotifications_setNotifications(browser, notifications) {
|
||||
popupNotificationsMap.set(browser, notifications);
|
||||
return notifications;
|
||||
},
|
||||
|
||||
_onIconBoxCommand: function PopupNotifications_onIconBoxCommand(event) {
|
||||
|
Loading…
Reference in New Issue
Block a user