mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-05 19:08:18 +00:00
Fix tab label handling and improve pinned tab state management; ensure static labels are correctly set and cached.
This commit is contained in:
@@ -213,8 +213,9 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pin.title && pin.editedTitle) {
|
||||
gBrowser._setTabLabel(tab, pin.title);
|
||||
if (pin.title && (pin.editedTitle || tab.hasAttribute('zen-has-static-label'))) {
|
||||
tab.removeAttribute('zen-has-static-label'); // So we can set it again
|
||||
gBrowser._setTabLabel(tab, pin.title, { beforeTabOpen: true });
|
||||
tab.setAttribute('zen-has-static-label', 'true');
|
||||
}
|
||||
}
|
||||
@@ -341,7 +342,7 @@
|
||||
tab.position = tab._tPos;
|
||||
|
||||
for (let otherTab of gBrowser.tabs) {
|
||||
if (otherTab.pinned) {
|
||||
if (otherTab.pinned && otherTab.getAttribute('zen-pin-id') !== tab.getAttribute('zen-pin-id')) {
|
||||
const actualPin = this._pinsCache.find((pin) => pin.uuid === otherTab.getAttribute('zen-pin-id'));
|
||||
if (!actualPin) {
|
||||
continue;
|
||||
@@ -358,6 +359,13 @@
|
||||
}
|
||||
actualPin.position = tab.position;
|
||||
actualPin.isEssential = tab.hasAttribute('zen-essential');
|
||||
|
||||
// There was a bug where the title and hasStaticLabel attribute were not being set
|
||||
// This is a workaround to fix that
|
||||
if (tab.hasAttribute('zen-has-static-label')) {
|
||||
actualPin.editedTitle = true;
|
||||
actualPin.title = tab.label;
|
||||
}
|
||||
await this.savePin(actualPin);
|
||||
}
|
||||
|
||||
@@ -846,6 +854,15 @@
|
||||
// update the label for the same pin across all windows
|
||||
for (const browser of browsers) {
|
||||
const tabs = browser.gBrowser.tabs;
|
||||
// Fix pinned cache for the browser
|
||||
const browserCache = browser.gZenPinnedTabManager?._pinsCache;
|
||||
if (browserCache) {
|
||||
const pin = browserCache.find((pin) => pin.uuid === uuid);
|
||||
if (pin) {
|
||||
pin.title = newTitle;
|
||||
pin.editedTitle = isEdited;
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
const tabToEdit = tabs[i];
|
||||
if (tabToEdit.getAttribute('zen-pin-id') === uuid && tabToEdit !== tab) {
|
||||
|
@@ -264,7 +264,7 @@
|
||||
(tab.pinned && !ignoreTimestamp) ||
|
||||
tab.selected ||
|
||||
(tab.multiselected && !ignoreTimestamp) ||
|
||||
tab.hasAttribute('busy') ||
|
||||
(tab.hasAttribute('busy') && !ignoreTimestamp) ||
|
||||
tab.hasAttribute('pending') ||
|
||||
!tab.linkedPanel ||
|
||||
tab.splitView ||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs
|
||||
index 908743177d9f95e2e6549c689e7a493ca8668701..181c4819b052e444e56e75f1cb40b4bc299569fb 100644
|
||||
index f814772114948f87cbb3c3a7231c95ea1f68d776..296cce151690b31a6e136dd5046a2697fb46fe45 100644
|
||||
--- a/browser/components/sessionstore/SessionStore.sys.mjs
|
||||
+++ b/browser/components/sessionstore/SessionStore.sys.mjs
|
||||
@@ -3848,6 +3848,7 @@ var SessionStoreInternal = {
|
||||
@@ -3881,6 +3881,7 @@ var SessionStoreInternal = {
|
||||
aWindow.gBrowser.selectedTab = newTab;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ index 908743177d9f95e2e6549c689e7a493ca8668701..181c4819b052e444e56e75f1cb40b4bc
|
||||
// Restore the state into the new tab.
|
||||
this.restoreTab(newTab, tabState, {
|
||||
restoreImmediately: aRestoreImmediately,
|
||||
@@ -5315,14 +5316,14 @@ var SessionStoreInternal = {
|
||||
@@ -5355,14 +5356,14 @@ var SessionStoreInternal = {
|
||||
}
|
||||
|
||||
let tabbrowser = aWindow.gBrowser;
|
||||
@@ -27,7 +27,7 @@ index 908743177d9f95e2e6549c689e7a493ca8668701..181c4819b052e444e56e75f1cb40b4bc
|
||||
continue;
|
||||
}
|
||||
let tabData = lazy.TabState.collect(tab, TAB_CUSTOM_VALUES.get(tab));
|
||||
@@ -6042,6 +6043,15 @@ var SessionStoreInternal = {
|
||||
@@ -6086,6 +6087,18 @@ var SessionStoreInternal = {
|
||||
|
||||
// Most of tabData has been restored, now continue with restoring
|
||||
// attributes that may trigger external events.
|
||||
@@ -35,7 +35,10 @@ index 908743177d9f95e2e6549c689e7a493ca8668701..181c4819b052e444e56e75f1cb40b4bc
|
||||
+ tab.setAttribute("zen-essential", "true");
|
||||
+ }
|
||||
+ if (tabData.zenIsEmpty) {
|
||||
+ tab.setAttribute("zen-empty-tab", "true");
|
||||
+ 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);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
diff --git a/browser/components/sessionstore/TabState.sys.mjs b/browser/components/sessionstore/TabState.sys.mjs
|
||||
index 8f7ed557e6aa61e7e16ed4a8d785ad5fe651b3d8..8b0781488e8f250666f1d542e3aa0cb34e018f24 100644
|
||||
index 8f7ed557e6aa61e7e16ed4a8d785ad5fe651b3d8..4c9f17408b912a2c51ebc1a670062203bf4994f3 100644
|
||||
--- a/browser/components/sessionstore/TabState.sys.mjs
|
||||
+++ b/browser/components/sessionstore/TabState.sys.mjs
|
||||
@@ -80,10 +80,18 @@ class _TabState {
|
||||
@@ -80,10 +80,19 @@ class _TabState {
|
||||
tabData.muteReason = tab.muteReason;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ index 8f7ed557e6aa61e7e16ed4a8d785ad5fe651b3d8..8b0781488e8f250666f1d542e3aa0cb3
|
||||
+ tabData.zenPinnedEntry = tab.getAttribute("zen-pinned-entry");
|
||||
+ tabData.zenPinnedIcon = tab.getAttribute("zen-pinned-icon");
|
||||
+ tabData.zenIsEmpty = tab.hasAttribute("zen-empty-tab");
|
||||
+ tabData.zenHasStaticLabel = tab.hasAttribute("zen-has-static-label");
|
||||
+
|
||||
tabData.searchMode = tab.ownerGlobal.gURLBar.getSearchMode(browser, true);
|
||||
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user