Mute audio immediately on tab closure (
bug 1355242). r=florian
MozReview-Commit-ID: BO161kV2UWE
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2846,16 +2846,23 @@
// cancels the operation. We are finished here in both cases.
this._windowIsClosing = window.closeWindow(true, window.warnAboutClosingWindow);
return false;
}
newTab = true;
}
+ // Mute audio immediately to improve perceived speed of tab closure.
+ if (aTab.hasAttribute("soundplaying")) {
+ // Don't persist the muted state as this wasn't a user action.
+ // This lets undo-close-tab return it to an unmuted state.
+ aTab.linkedBrowser.mute(true);
+ }
+
aTab.closing = true;
this._removingTabs.push(aTab);
this._visibleTabs = null; // invalidate cache
// Invalidate hovered tab state tracking for this closing tab.
if (this.tabContainer._hoveredTab == aTab)
aTab._mouseleave();
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -752,19 +752,22 @@
<field name="_audioBlocked">false</field>
<property name="audioBlocked"
onget="return this._audioBlocked;"
readonly="true"/>
<method name="mute">
+ <parameter name="transientState"/>
<body>
<![CDATA[
- this._audioMuted = true;
+ if (!transientState) {
+ this._audioMuted = true;
+ }
this.messageManager.sendAsyncMessage("AudioPlayback",
{type: "mute"});
]]>
</body>
</method>
<method name="unmute">
<body>