Fix tab label handling and improve pinned tab state management; ensure static labels are correctly set and cached.

This commit is contained in:
mr. M 2025-03-06 16:06:15 +01:00
parent b93faff771
commit 8ed5b50c3d
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB
5 changed files with 66 additions and 39 deletions

View file

@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe122b7900f1 100644
index 628aa6596627c85efe361fc1ece8fd58f7ee653e..e80828e9e72faa3652cd218810b98867792a2220 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -412,11 +412,50 @@
@ -276,7 +276,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
});
}
@@ -3367,6 +3447,24 @@
@@ -3367,6 +3447,27 @@
) {
tabWasReused = true;
tab = this.selectedTab;
@ -286,6 +286,9 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
+ if (tabData.zenIsEmpty) {
+ tab.setAttribute("zen-empty-tab", "true");
+ }
+ if (tabData.zenHasStaticLabel) {
+ tab.setAttribute("zen-has-static-label", "true");
+ }
+ if (tabData.zenPinnedId) {
+ tab.setAttribute("zen-pin-id", tabData.zenPinnedId);
+ }
@ -301,7 +304,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (!tabData.pinned) {
this.unpinTab(tab);
} else {
@@ -3380,6 +3478,7 @@
@@ -3380,6 +3481,7 @@
restoreTabsLazily && !select && !tabData.pinned;
let url = "about:blank";
@ -309,7 +312,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (tabData.entries?.length) {
let activeIndex = (tabData.index || tabData.entries.length) - 1;
// Ensure the index is in bounds.
@@ -3415,7 +3514,24 @@
@@ -3415,7 +3517,27 @@
skipLoad: true,
preferredRemoteType,
});
@ -323,6 +326,9 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
+ if (tabData.zenIsEmpty) {
+ tab.setAttribute("zen-empty-tab", "true");
+ }
+ if (tabData.zenHasStaticLabel) {
+ tab.setAttribute("zen-has-static-label", "true");
+ }
+ if (tabData.zenEssential) {
+ tab.setAttribute("zen-essential", "true");
+ }
@ -335,7 +341,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (select) {
tabToSelect = tab;
}
@@ -3428,8 +3544,8 @@
@@ -3428,8 +3550,8 @@
// inserted in the DOM. If the tab is not yet in the DOM,
// just insert it in the right place from the start.
if (!tab.parentNode) {
@ -346,7 +352,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
tab.toggleAttribute("pinned", true);
this.tabContainer._invalidateCachedTabs();
// Then ensure all the tab open/pinning information is sent.
@@ -3693,7 +3809,7 @@
@@ -3693,7 +3815,7 @@
// Ensure we have an index if one was not provided.
if (typeof index != "number") {
// Move the new tab after another tab if needed, to the end otherwise.
@ -355,7 +361,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (
!bulkOrderedOpen &&
((openerTab &&
@@ -3736,18 +3852,18 @@
@@ -3736,18 +3858,18 @@
// Ensure index is within bounds.
if (tab.pinned) {
@ -378,7 +384,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (tabAfter && tabAfter.group == tabGroup) {
// Place at the front of, or between tabs in, the same tab group
this.tabContainer.insertBefore(tab, tabAfter);
@@ -4059,6 +4175,9 @@
@@ -4059,6 +4181,9 @@
return;
}
@ -388,7 +394,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
this.removeTabs(selectedTabs);
}
@@ -4391,6 +4510,7 @@
@@ -4391,6 +4516,7 @@
skipSessionStore,
} = {}
) {
@ -396,7 +402,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (UserInteraction.running("browser.tabs.opening", window)) {
UserInteraction.finish("browser.tabs.opening", window);
}
@@ -4407,6 +4527,12 @@
@@ -4407,6 +4533,12 @@
TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
}
@ -409,7 +415,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
// Handle requests for synchronously removing an already
// asynchronously closing tab.
if (!animate && aTab.closing) {
@@ -4421,7 +4547,9 @@
@@ -4421,7 +4553,9 @@
// frame created for it (for example, by updating the visually selected
// state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
@ -420,7 +426,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (
!this._beginRemoveTab(aTab, {
closeWindowFastpath: true,
@@ -4435,7 +4563,6 @@
@@ -4435,7 +4569,6 @@
TelemetryStopwatch.cancel("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
return;
}
@ -428,7 +434,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
let lockTabSizing =
!this.tabContainer.verticalMode &&
!aTab.pinned &&
@@ -4574,14 +4701,14 @@
@@ -4574,14 +4707,14 @@
!!this.tabsInCollapsedTabGroups.length;
if (
aTab.visible &&
@ -445,7 +451,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here,
@@ -4605,6 +4732,7 @@
@@ -4605,6 +4738,7 @@
newTab = true;
}
@ -453,7 +459,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -4645,9 +4773,7 @@
@@ -4645,9 +4779,7 @@
aTab._mouseleave();
if (newTab) {
@ -464,7 +470,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
} else {
TabBarVisibility.update();
}
@@ -4776,6 +4902,8 @@
@@ -4776,6 +4908,8 @@
this.tabs[i]._tPos = i;
}
@ -473,7 +479,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (!this._windowIsClosing) {
if (wasPinned) {
this.tabContainer._positionPinnedTabs();
@@ -4994,7 +5122,7 @@
@@ -4994,7 +5128,7 @@
!excludeTabs.has(aTab.owner) &&
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) {
@ -482,7 +488,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
}
// Try to find a remaining tab that comes after the given tab
@@ -5016,7 +5144,7 @@
@@ -5016,7 +5150,7 @@
}
if (tab) {
@ -491,7 +497,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
}
// If no qualifying visible tab was found, see if there is a tab in
@@ -5434,10 +5562,10 @@
@@ -5434,10 +5568,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
}
@ -504,7 +510,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -5675,7 +5803,7 @@
@@ -5675,7 +5809,7 @@
// Don't allow mixing pinned and unpinned tabs.
if (aTab.pinned) {
@ -513,7 +519,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
} else {
aIndex = Math.max(aIndex, this.pinnedTabCount);
}
@@ -5684,11 +5812,18 @@
@@ -5684,11 +5818,18 @@
}
this._handleTabMove(aTab, () => {
@ -535,7 +541,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
neighbor.after(aTab);
} else {
this.tabContainer.insertBefore(aTab, neighbor);
@@ -5697,7 +5832,7 @@
@@ -5697,7 +5838,7 @@
}
moveTabToGroup(aTab, aGroup) {
@ -544,7 +550,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
return;
}
if (aTab.group && aTab.group.id === aGroup.id) {
@@ -5721,6 +5856,10 @@
@@ -5721,6 +5862,10 @@
moveActionCallback();
@ -555,7 +561,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
// Clear tabs cache after moving nodes because the order of tabs may have
// changed.
this.tabContainer._invalidateCachedTabs();
@@ -5771,7 +5910,7 @@
@@ -5771,7 +5916,7 @@
createLazyBrowser,
};
@ -564,7 +570,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
if (aIndex < numPinned || (aTab.pinned && aIndex == numPinned)) {
params.pinned = true;
}
@@ -7415,6 +7554,7 @@
@@ -7415,6 +7560,7 @@
aWebProgress.isTopLevel
) {
this.mTab.setAttribute("busy", "true");
@ -572,7 +578,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected;
}
@@ -8381,7 +8521,7 @@ var TabContextMenu = {
@@ -8381,7 +8527,7 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !multiselectionContext;
@ -581,7 +587,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
// Move Tab items
let contextMoveTabOptions = document.getElementById(
"context_moveTabOptions"
@@ -8414,7 +8554,7 @@ var TabContextMenu = {
@@ -8414,7 +8560,7 @@ var TabContextMenu = {
let contextMoveTabToStart = document.getElementById("context_moveToStart");
let isFirstTab =
tabsToMove[0] == visibleTabs[0] ||
@ -590,7 +596,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..f3cb04e9034d24752bdf6911e647fe12
contextMoveTabToStart.disabled = isFirstTab && allSelectedTabsAdjacent;
document.getElementById("context_openTabInWindow").disabled =
@@ -8647,6 +8787,7 @@ var TabContextMenu = {
@@ -8647,6 +8793,7 @@ var TabContextMenu = {
if (this.contextTab.multiselected) {
gBrowser.removeMultiSelectedTabs();
} else {