mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Bug 1130356: Support the screensharing doorhanger in Social API chat windows and allow for mutiple independent notification icons per type. r=florian
This commit is contained in:
parent
7572460b47
commit
81214c3a36
@ -12,8 +12,14 @@
|
||||
<xul:image class="chat-status-icon" xbl:inherits="src=image"/>
|
||||
<xul:label class="chat-title" flex="1" xbl:inherits="value=label" crop="center"/>
|
||||
</xul:hbox>
|
||||
<xul:toolbarbutton anonid="webRTC-shareScreen-icon"
|
||||
class="notification-anchor-icon chat-toolbarbutton"
|
||||
oncommand="document.getBindingParent(this).showNotifications(this); event.stopPropagation();"/>
|
||||
<xul:toolbarbutton anonid="webRTC-sharingScreen-icon"
|
||||
class="notification-anchor-icon chat-toolbarbutton"
|
||||
oncommand="document.getBindingParent(this).showNotifications(this); event.stopPropagation();"/>
|
||||
<xul:toolbarbutton anonid="notification-icon" class="notification-anchor-icon chat-toolbarbutton"
|
||||
oncommand="document.getBindingParent(this).showNotifications(); event.stopPropagation();"/>
|
||||
oncommand="document.getBindingParent(this).showNotifications(this); event.stopPropagation();"/>
|
||||
<xul:toolbarbutton anonid="minimize" class="chat-minimize-button chat-toolbarbutton"
|
||||
oncommand="document.getBindingParent(this).toggle();"/>
|
||||
<xul:toolbarbutton anonid="swap" class="chat-swap-button chat-toolbarbutton"
|
||||
@ -30,8 +36,20 @@
|
||||
|
||||
<implementation implements="nsIDOMEventListener">
|
||||
<constructor><![CDATA[
|
||||
this.content.__defineGetter__("popupnotificationanchor",
|
||||
() => document.getAnonymousElementByAttribute(this, "anonid", "notification-icon"));
|
||||
const kAnchorMap = new Map([
|
||||
["", "notification-"],
|
||||
["webRTC-shareScreen-", ""],
|
||||
["webRTC-sharingScreen-", ""]
|
||||
]);
|
||||
for (let [getterPrefix, idPrefix] of kAnchorMap) {
|
||||
let getter = getterPrefix + "popupnotificationanchor";
|
||||
let anonid = (idPrefix || getterPrefix) + "icon";
|
||||
this.content.__defineGetter__(getter, () => {
|
||||
delete this.content[getter];
|
||||
return this.content[getter] = document.getAnonymousElementByAttribute(
|
||||
this, "anonid", anonid);
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.chatbar) {
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "minimize").hidden = true;
|
||||
@ -136,8 +154,9 @@
|
||||
</property>
|
||||
|
||||
<method name="showNotifications">
|
||||
<parameter name="aAnchor"/>
|
||||
<body><![CDATA[
|
||||
PopupNotifications._reshowNotifications(this.content.popupnotificationanchor,
|
||||
PopupNotifications._reshowNotifications(aAnchor,
|
||||
this.content);
|
||||
]]></body>
|
||||
</method>
|
||||
|
@ -17,15 +17,19 @@ const NOTIFICATION_EVENT_SWAPPING = "swapping";
|
||||
|
||||
const ICON_SELECTOR = ".notification-anchor-icon";
|
||||
const ICON_ATTRIBUTE_SHOWING = "showing";
|
||||
const ICON_ANCHOR_ATTRIBUTE = "popupnotificationanchor";
|
||||
|
||||
const PREF_SECURITY_DELAY = "security.notification_enable_delay";
|
||||
|
||||
let popupNotificationsMap = new WeakMap();
|
||||
let gNotificationParents = new WeakMap;
|
||||
|
||||
function getAnchorFromBrowser(aBrowser) {
|
||||
let anchor = aBrowser.getAttribute("popupnotificationanchor") ||
|
||||
aBrowser.popupnotificationanchor;
|
||||
function getAnchorFromBrowser(aBrowser, aAnchorID) {
|
||||
let attrPrefix = aAnchorID ? aAnchorID.replace("notification-icon", "") : "";
|
||||
let anchor = aBrowser.getAttribute(attrPrefix + ICON_ANCHOR_ATTRIBUTE) ||
|
||||
aBrowser[attrPrefix + ICON_ANCHOR_ATTRIBUTE] ||
|
||||
aBrowser.getAttribute(ICON_ANCHOR_ATTRIBUTE) ||
|
||||
aBrowser[ICON_ANCHOR_ATTRIBUTE];
|
||||
if (anchor) {
|
||||
if (anchor instanceof Ci.nsIDOMXULElement) {
|
||||
return anchor;
|
||||
@ -74,8 +78,7 @@ Notification.prototype = {
|
||||
get anchorElement() {
|
||||
let iconBox = this.owner.iconBox;
|
||||
|
||||
let anchorElement = getAnchorFromBrowser(this.browser);
|
||||
|
||||
let anchorElement = getAnchorFromBrowser(this.browser, this.anchorID);
|
||||
if (!iconBox)
|
||||
return anchorElement;
|
||||
|
||||
@ -728,8 +731,18 @@ PopupNotifications.prototype = {
|
||||
// remove previous icon classes
|
||||
let className = anchorElement.className.replace(/([-\w]+-notification-icon\s?)/g,"")
|
||||
className = "default-notification-icon " + className;
|
||||
if (notifications.length == 1) {
|
||||
className = notifications[0].anchorID + " " + className;
|
||||
if (notifications.length > 0) {
|
||||
// Find the first notification this anchor belongs to.
|
||||
let notification = notifications[0];
|
||||
for (let n of notifications) {
|
||||
if (n.anchorElement == anchorElement) {
|
||||
notification = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// With this notification we can better approximate the most fitting
|
||||
// style.
|
||||
className = notification.anchorID + " " + className;
|
||||
}
|
||||
anchorElement.className = className;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user