From e6eac2480599903c144823fc661aa938dd2bb3a7 Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Thu, 19 Nov 2015 18:30:38 +0900 Subject: [PATCH] Show sound indicator in a tab which have any soundplaying descendant --- modules/browser.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index f84251d0..41f25d2c 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -3006,11 +3006,19 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { case 'DOMAudioPlaybackStarted': - this.setTabValue(this.getTabFromBrowser(aEvent.target), this.kREALLY_SOUND_PLAYING, true); + { + let tab = this.getTabFromBrowser(aEvent.originalTarget); + this.setTabValue(tab, this.kREALLY_SOUND_PLAYING, true); + this.updateTabAsParent(this.getParentTab(tab)); + } return; case 'DOMAudioPlaybackStopped': - this.deleteTabValue(this.getTabFromBrowser(aEvent.target), this.kREALLY_SOUND_PLAYING); + { + let tab = this.getTabFromBrowser(aEvent.originalTarget); + this.deleteTabValue(tab, this.kREALLY_SOUND_PLAYING); + this.updateTabAsParent(this.getParentTab(tab)); + } return; @@ -5929,8 +5937,8 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { return; var descendants = this.getDescendantTabs(aTab); - this.updateTabsCount(aTab, descendants); + this.updateTabSoundIndicator(aTab, descendants); if (!aDontUpdateAncestor) { let parent = this.getParentTab(aTab); @@ -5948,6 +5956,17 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { count.setAttribute('value', value); } }, + updateTabSoundIndicator : function TSTBrowser_updateTabSoundIndicator(aTab, aDescendants) + { + var hasSoundPlayingDescendant = aDescendants.some(function(aDescendant) { + return this.getTabValue(aDescendant, this.kREALLY_SOUND_PLAYING) == 'true'; + }, this); + if (hasSoundPlayingDescendant || + this.getTabValue(aTab, this.kREALLY_SOUND_PLAYING) == 'true') + aTab.setAttribute('soundplaying', true); + else + aTab.removeAttribute('soundplaying', true); + }, updateAllTabsCount : function TSTBrowser_updateAllTabsCount() {