Mute audio immediately on tab closure (bug 1355242). r=florian draft
authorPanos Astithas <past@mozilla.com>
Thu, 11 May 2017 17:39:45 -0400
changeset 586068 aba51e75c4f4ce20962d149fd4ea850911d8611f
parent 586049 34ac1a5d6576d6775491c8a882710a1520551da6
child 630874 dfcffe97064fc4b6c97a876c54bb94d6ddf12945
push id61279
push userbmo:past@mozilla.com
push dateMon, 29 May 2017 16:26:55 +0000
reviewersflorian
bugs1355242
milestone55.0a1
Mute audio immediately on tab closure (bug 1355242). r=florian MozReview-Commit-ID: BO161kV2UWE
browser/base/content/tabbrowser.xml
toolkit/content/widgets/browser.xml
--- 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>