--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5126,27 +5126,33 @@
</handler>
<handler event="DOMAudioPlaybackBlockStarted">
<![CDATA[
var tab = getTabFromAudioEvent(event)
if (!tab) {
return;
}
- // TODO : implement media-blocking icon in next patch.
+ if (!tab.hasAttribute("blocked")) {
+ tab.setAttribute("blocked", true);
+ this._tabAttrModified(tab, ["blocked"]);
+ }
]]>
</handler>
<handler event="DOMAudioPlaybackBlockStopped">
<![CDATA[
var tab = getTabFromAudioEvent(event)
if (!tab) {
return;
}
- // TODO : implement media-blocking icon in next patch.
+ if (tab.hasAttribute("blocked")) {
+ tab.removeAttribute("blocked");
+ this._tabAttrModified(tab, ["blocked"]);
+ }
]]>
</handler>
</handlers>
</binding>
<binding id="tabbrowser-tabbox"
extends="chrome://global/content/bindings/tabbox.xml#tabbox">
<implementation>
@@ -6579,25 +6585,25 @@
anonid="tab-icon-image"
class="tab-icon-image"
validate="never"
role="presentation"/>
<xul:image xbl:inherits="sharing,selected=visuallyselected"
anonid="sharing-icon"
class="tab-sharing-icon-overlay"
role="presentation"/>
- <xul:image xbl:inherits="crashed,busy,soundplaying,soundplaying-scheduledremoval,pinned,muted,selected=visuallyselected"
+ <xul:image xbl:inherits="crashed,busy,soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected"
anonid="overlay-icon"
class="tab-icon-overlay"
role="presentation"/>
<xul:label flex="1"
xbl:inherits="value=label,crop,accesskey,fadein,pinned,selected=visuallyselected,attention"
class="tab-text tab-label"
role="presentation"/>
- <xul:image xbl:inherits="soundplaying,soundplaying-scheduledremoval,pinned,muted,selected=visuallyselected"
+ <xul:image xbl:inherits="soundplaying,soundplaying-scheduledremoval,pinned,muted,blocked,selected=visuallyselected"
anonid="soundplaying-icon"
class="tab-icon-sound"
role="presentation"/>
<xul:toolbarbutton anonid="close-button"
xbl:inherits="fadein,pinned,selected=visuallyselected"
class="tab-close-button close-icon"/>
</xul:hbox>
</xul:stack>
@@ -6660,16 +6666,21 @@
return this.getAttribute("hidden") == "true";
</getter>
</property>
<property name="muted" readonly="true">
<getter>
return this.getAttribute("muted") == "true";
</getter>
</property>
+ <property name="blocked" readonly="true">
+ <getter>
+ return this.getAttribute("blocked") == "true";
+ </getter>
+ </property>
<!--
Describes how the tab ended up in this mute state. May be any of:
- undefined: The tabs mute state has never changed.
- null: The mute state was last changed through the UI.
- Any string: The ID was changed through an extension API. The string
must be the ID of the extension which changed it.
-->
@@ -6702,17 +6713,18 @@
</method>
<field name="cachePosition">Infinity</field>
<field name="mOverCloseButton">false</field>
<property name="_overPlayingIcon" readonly="true">
<getter><![CDATA[
let iconVisible = this.hasAttribute("soundplaying") ||
- this.hasAttribute("muted");
+ this.hasAttribute("muted") ||
+ this.hasAttribute("blocked");
let soundPlayingIcon =
document.getAnonymousElementByAttribute(this, "anonid", "soundplaying-icon");
let overlayIcon =
document.getAnonymousElementByAttribute(this, "anonid", "overlay-icon");
return soundPlayingIcon && soundPlayingIcon.matches(":hover") ||
(overlayIcon && overlayIcon.matches(":hover") && iconVisible);
]]></getter>
@@ -6775,27 +6787,44 @@
</method>
<method name="toggleMuteAudio">
<parameter name="aMuteReason"/>
<body>
<![CDATA[
let tabContainer = this.parentNode;
let browser = this.linkedBrowser;
- if (browser.audioMuted) {
- browser.unmute();
- this.removeAttribute("muted");
- BrowserUITelemetry.countTabMutingEvent("unmute", aMuteReason);
+ let modifiedAttrs = [];
+ if (browser.audioBlocked) {
+ this.removeAttribute("blocked");
+ modifiedAttrs.push("blocked");
+
+ // We don't want sound icon flickering between "blocked", "none" and
+ // "sound-playing", here adding the "soundplaying" is to keep the
+ // transition smoothly.
+ if (!this.hasAttribute("soundplaying")) {
+ this.setAttribute("soundplaying", true);
+ modifiedAttrs.push("soundplaying");
+ }
+
+ browser.resumeMedia();
} else {
- browser.mute();
- this.setAttribute("muted", "true");
- BrowserUITelemetry.countTabMutingEvent("mute", aMuteReason);
+ if (browser.audioMuted) {
+ browser.unmute();
+ this.removeAttribute("muted");
+ BrowserUITelemetry.countTabMutingEvent("unmute", aMuteReason);
+ } else {
+ browser.mute();
+ this.setAttribute("muted", "true");
+ BrowserUITelemetry.countTabMutingEvent("mute", aMuteReason);
+ }
+ this.muteReason = aMuteReason || null;
+ modifiedAttrs.push("muted");
}
- this.muteReason = aMuteReason || null;
- tabContainer.tabbrowser._tabAttrModified(this, ["muted"]);
+ tabContainer.tabbrowser._tabAttrModified(this, modifiedAttrs);
]]>
</body>
</method>
<method name="setUserContextId">
<parameter name="aUserContextId"/>
<body>
<![CDATA[