From becd71a8600c7229f765d8eda21c1843c4f4adf1 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 16 Nov 2018 20:59:11 +0800 Subject: Issue #638 - Part 1: Provide a visual indicator for muting/unmuting tabs --- application/palemoon/base/content/tabbrowser.xml | 140 ++++++++++++++++++++++- 1 file changed, 139 insertions(+), 1 deletion(-) (limited to 'application/palemoon/base/content/tabbrowser.xml') diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index dc6cb0a9d..0a2a1c3f5 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -3347,6 +3347,78 @@ tab.setAttribute("titlechanged", "true"); ]]> + + + + + { + tab.removeAttribute("soundplaying-scheduledremoval"); + tab.removeAttribute("soundplaying"); + this._tabAttrModified(tab, ["soundplaying", "soundplaying-scheduledremoval"]); + }, removalDelay); + } + ]]> + + + + + + + @@ -4762,6 +4834,10 @@ xbl:inherits="value=label,crop,accesskey,fadein,pinned,selected" class="tab-text tab-label" role="presentation"/> + @@ -4782,9 +4858,59 @@ false + + + null false 0 + + + + + + + @@ -4843,7 +4969,8 @@ if (this.selected) { this.style.MozUserFocus = 'ignore'; this.clientTop; // just using this to flush style updates - } else if (this.mOverCloseButton) { + } else if (this.mOverCloseButton || + this._overPlayingIcon) { // Prevent tabbox.xml from selecting the tab. event.stopPropagation(); } @@ -4852,6 +4979,17 @@ this.style.MozUserFocus = ''; + + + -- cgit v1.2.3 From ae48428aa3f5e45db068106e825e23e80f1a1a55 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 16 Nov 2018 21:40:17 +0800 Subject: Issue #638 - Part 2: Add tooltip to mute/unmute buttons --- application/palemoon/base/content/tabbrowser.xml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'application/palemoon/base/content/tabbrowser.xml') diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index 0a2a1c3f5..d73f87bd6 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -3084,9 +3084,25 @@ event.preventDefault(); return; } - event.target.setAttribute("label", tab.mOverCloseButton ? - tab.getAttribute("closetabtext") : - tab.getAttribute("label")); + + var stringID, label; + if (tab.mOverCloseButton) { + stringID = "tabs.closeTab"; + } else if (tab._overPlayingIcon) { + if (tab.linkedBrowser.audioBlocked) { + stringID = "tabs.unblockAudio.tooltip"; + } else { + stringID = tab.linkedBrowser.audioMuted ? + "tabs.unmuteAudio.tooltip" : + "tabs.muteAudio.tooltip"; + } + } else { + label = tab.getAttribute("label"); + } + if (stringID && !label) { + label = this.mStringBundle.getString(stringID); + } + event.target.setAttribute("label", label); ]]> -- cgit v1.2.3 From 719234847ecbab2fe8b4b4c2f153fa0c12bffbc6 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 16 Nov 2018 22:40:59 +0800 Subject: Issue #638 - Part 4: Add tab sound icon to tab drop-down list --- application/palemoon/base/content/tabbrowser.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'application/palemoon/base/content/tabbrowser.xml') diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index d73f87bd6..073a12f16 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -5111,6 +5111,24 @@ aMenuitem.setAttribute("selected", "true"); else aMenuitem.removeAttribute("selected"); + + function addEndImage() { + let endImage = document.createElement("image"); + endImage.setAttribute("class", "alltabs-endimage"); + let endImageContainer = document.createElement("hbox"); + endImageContainer.setAttribute("align", "center"); + endImageContainer.setAttribute("pack", "center"); + endImageContainer.appendChild(endImage); + aMenuitem.appendChild(endImageContainer); + return endImage; + } + + if (aMenuitem.firstChild) + aMenuitem.firstChild.remove(); + if (aTab.hasAttribute("muted")) + addEndImage().setAttribute("muted", "true"); + else if (aTab.hasAttribute("soundplaying")) + addEndImage().setAttribute("soundplaying", "true"); ]]> -- cgit v1.2.3 From d56c1ceac5da31c6e5441369e8840dca73648ced Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 16 Nov 2018 23:22:42 +0800 Subject: Issue #638 - Part 6: Fix up remaining references - Refactor _tabAttrModified to accept two parameters - Modify consumers of _tabAttrModified to pass details - Add missing _soundPlayingAttrRemovalTimer field - Add missing checks for mute/unmute around the tab browser - Tab sound icon should inherit 'selected' attribute instead of 'visuallyselected' --- application/palemoon/base/content/tabbrowser.xml | 66 +++++++++++++++++++----- 1 file changed, 54 insertions(+), 12 deletions(-) (limited to 'application/palemoon/base/content/tabbrowser.xml') diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index 073a12f16..aa9c8adc3 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -616,7 +616,7 @@ if (this.mTab.hasAttribute("busy")) { this.mTab.removeAttribute("busy"); - this.mTabBrowser._tabAttrModified(this.mTab); + this.mTabBrowser._tabAttrModified(this.mTab, ["busy"]); if (!this.mTab.selected) this.mTab.setAttribute("unread", "true"); } @@ -696,6 +696,19 @@ aLocation.spec != "about:blank")) this.mBrowser.userTypedValue = null; + // If the browser was playing audio, we should remove the playing state. + if (this.mTab.hasAttribute("soundplaying") && !isSameDocument) { + clearTimeout(this.mTab._soundPlayingAttrRemovalTimer); + this.mTab._soundPlayingAttrRemovalTimer = 0; + this.mTab.removeAttribute("soundplaying"); + this.mTabBrowser._tabAttrModified(this.mTab, ["soundplaying"]); + } + + // If the browser was previously muted, we should restore the muted state. + if (this.mTab.hasAttribute("muted")) { + this.mTab.linkedBrowser.mute(); + } + // Don't clear the favicon if this onLocationChange was // triggered by a pushState or a replaceState. See bug 550565. if (!gMultiProcessBrowser) { @@ -804,7 +817,7 @@ aTab.setAttribute("image", sizedIconUrl); else aTab.removeAttribute("image"); - this._tabAttrModified(aTab); + this._tabAttrModified(aTab, ["image"]); } this._callProgressListeners(browser, "onLinkIconAvailable", [browser.mIconURL]); @@ -1116,8 +1129,8 @@ }); this.mCurrentTab.dispatchEvent(event); - this._tabAttrModified(oldTab); - this._tabAttrModified(this.mCurrentTab); + this._tabAttrModified(oldTab, ["selected"]); + this._tabAttrModified(this.mCurrentTab, ["selected"]); // Adjust focus oldBrowser._urlbarFocused = (gURLBar && gURLBar.focused); @@ -1187,14 +1200,18 @@ + @@ -1205,7 +1222,7 @@ @@ -1250,7 +1267,7 @@ aTab.label = title; aTab.crop = crop; - this._tabAttrModified(aTab); + this._tabAttrModified(aTab, ["label", "crop"]); if (aTab.selected) this.updateTitlebar(); @@ -2239,6 +2256,14 @@ var remoteBrowser = aOtherTab.ownerDocument.defaultView.gBrowser; var isPending = aOtherTab.hasAttribute("pending"); + // Expedite the removal of the icon if it was already scheduled. + if (aOtherTab._soundPlayingAttrRemovalTimer) { + clearTimeout(aOtherTab._soundPlayingAttrRemovalTimer); + aOtherTab._soundPlayingAttrRemovalTimer = 0; + aOtherTab.removeAttribute("soundplaying"); + remoteBrowser._tabAttrModified(aOtherTab, ["soundplaying"]); + } + // First, start teardown of the other browser. Make sure to not // fire the beforeunload event in the process. Close the other // window if this was its last tab. @@ -2248,6 +2273,18 @@ let ourBrowser = this.getBrowserForTab(aOurTab); let otherBrowser = aOtherTab.linkedBrowser; + let modifiedAttrs = []; + if (aOtherTab.hasAttribute("muted")) { + aOurTab.setAttribute("muted", "true"); + aOurTab.muteReason = aOtherTab.muteReason; + ourBrowser.mute(); + modifiedAttrs.push("muted"); + } + if (aOtherTab.hasAttribute("soundplaying")) { + aOurTab.setAttribute("soundplaying", "true"); + modifiedAttrs.push("soundplaying"); + } + // If the other tab is pending (i.e. has not been restored, yet) // then do not switch docShells but retrieve the other tab's state // and apply it to our tab. @@ -2266,7 +2303,7 @@ var isBusy = aOtherTab.hasAttribute("busy"); if (isBusy) { aOurTab.setAttribute("busy", "true"); - this._tabAttrModified(aOurTab); + modifiedAttrs.push("busy"); if (aOurTab.selected) this.mIsBusy = true; } @@ -2286,6 +2323,10 @@ // of replaceTabWithWindow), notify onLocationChange, etc. if (aOurTab.selected) this.updateCurrentBrowser(true); + + if (modifiedAttrs.length) { + this._tabAttrModified(aOurTab, modifiedAttrs); + } ]]> @@ -3316,6 +3357,7 @@ ]]> + 0 @@ -4850,7 +4892,7 @@ xbl:inherits="value=label,crop,accesskey,fadein,pinned,selected" class="tab-text tab-label" role="presentation"/> - -- cgit v1.2.3 From a6b250b47730cc4751cfc5ca9e96a4b74e4d6572 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Sat, 17 Nov 2018 10:55:10 +0800 Subject: Issue #638 - Part 8: Add overlay sound icon for pinned tabs - This also moves some styles to tabbrowser.css --- application/palemoon/base/content/tabbrowser.xml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'application/palemoon/base/content/tabbrowser.xml') diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index aa9c8adc3..62b2028b4 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -4888,6 +4888,10 @@ class="tab-icon-image" role="presentation" anonid="tab-icon"/> + Date: Sat, 17 Nov 2018 12:11:34 +0800 Subject: Issue #638 - Part 10: Rename all tabs sound icon to be consistent with others - alltabs => allTabs --- application/palemoon/base/content/tabbrowser.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application/palemoon/base/content/tabbrowser.xml') diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index 62b2028b4..9ee7f1b11 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -5160,7 +5160,7 @@ function addEndImage() { let endImage = document.createElement("image"); - endImage.setAttribute("class", "alltabs-endimage"); + endImage.setAttribute("class", "allTabs-endimage"); let endImageContainer = document.createElement("hbox"); endImageContainer.setAttribute("align", "center"); endImageContainer.setAttribute("pack", "center"); -- cgit v1.2.3 From 61b21c8083ec889b900efd78ff9435c441537e38 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Sat, 17 Nov 2018 19:17:20 +0800 Subject: Follow-up: Add missing getTabFromAudioEvent method --- application/palemoon/base/content/tabbrowser.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'application/palemoon/base/content/tabbrowser.xml') diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index 9ee7f1b11..9479db109 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -438,6 +438,22 @@ + + + + + + + -- cgit v1.2.3 From a681891e66255bfc466782ee5714e5cff80e0004 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Sat, 17 Nov 2018 21:49:36 +0800 Subject: Fix undefined isSameDocument --- application/palemoon/base/content/tabbrowser.xml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'application/palemoon/base/content/tabbrowser.xml') diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index 9479db109..929afd057 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -702,6 +702,8 @@ let topLevel = aWebProgress.isTopLevel; if (topLevel) { + let isSameDocument = + !!(aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT); // We need to clear the typed value // if the document failed to load, to make sure the urlbar reflects the // failed URI (particularly for SSL errors). However, don't clear the value -- cgit v1.2.3 From 3411dd5723fdcd7d2b5a8b08a9c2b6bea310b3c3 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 6 Dec 2018 22:23:58 +0100 Subject: Add an option to process favicons. This optimizes the size for UI display and strips animations. Default disabled. This resolves #899. --- application/palemoon/base/content/tabbrowser.xml | 29 +++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'application/palemoon/base/content/tabbrowser.xml') diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index 929afd057..988cae55c 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -831,13 +831,40 @@ "-moz-resolution=" + size + "," + size; } if (sizedIconUrl != aTab.getAttribute("image")) { - if (browser.mIconURL) //PMed + if (browser.mIconURL) aTab.setAttribute("image", sizedIconUrl); else aTab.removeAttribute("image"); this._tabAttrModified(aTab, ["image"]); } + if (Services.prefs.getBoolPref("browser.chrome.favicons.process")) { + let favImage = new Image; + favImage.src = browser.mIconURL; + var tabBrowser = this; + favImage.onload = function () { + try { + // Draw the icon on a hidden canvas + var canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas"); + var tabImg = document.getAnonymousElementByAttribute(aTab, "anonid", "tab-icon"); + var w = tabImg.boxObject.width; + var h = tabImg.boxObject.height; + canvas.width = w; + canvas.height = h; + var ctx = canvas.getContext('2d'); + ctx.drawImage(favImage, 0, 0, w, h); + icon = canvas.toDataURL(); + browser.mIconURL = icon; + aTab.setAttribute("image", icon); + } + catch (e) { + console.warn("Processing of favicon failed."); + // Canvas failed: icon remains as it was + } + tabBrowser._callProgressListeners(browser, "onLinkIconAvailable", [browser.mIconURL]); + } + } + this._callProgressListeners(browser, "onLinkIconAvailable", [browser.mIconURL]); ]]> -- cgit v1.2.3