Refactor ZenPinnedTabManager and ZenUIManager for improved tab closing behavior and URL bar handling

This commit is contained in:
mr. M
2025-02-03 19:42:28 +01:00
parent d9c8609d43
commit 88fbae4bec
7 changed files with 62 additions and 50 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tab.js b/browser/components/tabbrowser/content/tab.js
index d41c486c02a6f09dcff5741a59ad8b617294c481..855152a13afdf58433c228e3675e2e0eebe3892e 100644
index d41c486c02a6f09dcff5741a59ad8b617294c481..44535569b609d9bcd09f10e46e3161ce0a331c30 100644
--- a/browser/components/tabbrowser/content/tab.js
+++ b/browser/components/tabbrowser/content/tab.js
@@ -37,6 +37,7 @@
@@ -33,7 +33,7 @@ index d41c486c02a6f09dcff5741a59ad8b617294c481..855152a13afdf58433c228e3675e2e0e
}
+
+ if (event.target.classList.contains("tab-reset-button")) {
+ gZenPinnedTabManager._resetTabToStoredState(this);
+ gZenPinnedTabManager._onCloseTabShortcut(event, this, 'unload-switch');
+ gBrowser.tabContainer._blockDblClick = true;
+ }
}

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e9240ba35 100644
index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..dfc5d5cc1144a0098508a28de4f1433b9417f545 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -406,11 +406,39 @@
@@ -80,7 +80,17 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
oldTab.updateLastAccessed();
// if this is the foreground window, update the last-seen timestamps.
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
@@ -2387,7 +2421,7 @@
@@ -1477,6 +1511,9 @@
newBrowser &&
gURLBar.getBrowserState(newBrowser).urlbarFocused &&
gURLBar.focused;
+ if (gURLBar._zenHandleUrlbarClose) {
+ gURLBar._zenHandleUrlbarClose(true);
+ }
if (!keepFocusOnUrlBar) {
// Clear focus so that _adjustFocusAfterTabSwitch can detect if
// some element has been focused and respect that.
@@ -2387,7 +2424,7 @@
let panel = this.getPanel(browser);
let uniqueId = this._generateUniquePanelID();
@@ -89,7 +99,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
aTab.linkedPanel = uniqueId;
// Inject the <browser> into the DOM if necessary.
@@ -2447,7 +2481,7 @@
@@ -2447,7 +2484,7 @@
// hasSiblings=false on both the existing browser and the new browser.
if (this.tabs.length == 2) {
this.tabs[0].linkedBrowser.browsingContext.hasSiblings = true;
@@ -98,7 +108,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
} else {
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
}
@@ -2679,6 +2713,12 @@
@@ -2679,6 +2716,12 @@
);
}
@@ -111,7 +121,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
if (!UserInteraction.running("browser.tabs.opening", window)) {
UserInteraction.start("browser.tabs.opening", "initting", window);
}
@@ -2742,6 +2782,12 @@
@@ -2742,6 +2785,12 @@
noInitialLabel,
skipBackgroundNotify,
});
@@ -124,7 +134,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
if (insertTab) {
// insert the tab into the tab container in the correct position
this._insertTabAtIndex(t, {
@@ -2885,6 +2931,9 @@
@@ -2885,6 +2934,9 @@
}
}
@@ -134,7 +144,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
// Additionally send pinned tab events
if (pinned) {
this._notifyPinnedStatus(t);
@@ -3403,6 +3452,21 @@
@@ -3403,6 +3455,21 @@
) {
tabWasReused = true;
tab = this.selectedTab;
@@ -156,7 +166,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
if (!tabData.pinned) {
this.unpinTab(tab);
} else {
@@ -3416,6 +3480,7 @@
@@ -3416,6 +3483,7 @@
restoreTabsLazily && !select && !tabData.pinned;
let url = "about:blank";
@@ -164,7 +174,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
if (tabData.entries?.length) {
let activeIndex = (tabData.index || tabData.entries.length) - 1;
// Ensure the index is in bounds.
@@ -3451,7 +3516,21 @@
@@ -3451,7 +3519,21 @@
skipLoad: true,
preferredRemoteType,
});
@@ -187,7 +197,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
if (select) {
tabToSelect = tab;
}
@@ -3729,7 +3808,7 @@
@@ -3729,7 +3811,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.
@@ -196,7 +206,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
if (
!bulkOrderedOpen &&
((openerTab &&
@@ -3780,7 +3859,7 @@
@@ -3780,7 +3862,7 @@
}
/** @type {MozTabbrowserTab|undefined} */
@@ -205,7 +215,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
this.tabContainer._invalidateCachedTabs();
if (tabGroup) {
@@ -4095,6 +4174,9 @@
@@ -4095,6 +4177,9 @@
return;
}
@@ -215,7 +225,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
this.removeTabs(selectedTabs);
}
@@ -4443,6 +4525,12 @@
@@ -4443,6 +4528,12 @@
TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
}
@@ -228,7 +238,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
// Handle requests for synchronously removing an already
// asynchronously closing tab.
if (!animate && aTab.closing) {
@@ -4457,7 +4545,9 @@
@@ -4457,7 +4548,9 @@
// frame created for it (for example, by updating the visually selected
// state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
@@ -239,7 +249,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
if (
!this._beginRemoveTab(aTab, {
closeWindowFastpath: true,
@@ -4471,7 +4561,6 @@
@@ -4471,7 +4564,6 @@
TelemetryStopwatch.cancel("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
return;
}
@@ -247,7 +257,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
let lockTabSizing =
!this.tabContainer.verticalMode &&
!aTab.pinned &&
@@ -4610,14 +4699,14 @@
@@ -4610,14 +4702,14 @@
!!this.tabsInCollapsedTabGroups.length;
if (
aTab.visible &&
@@ -264,7 +274,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here,
@@ -5465,10 +5554,10 @@
@@ -5465,10 +5557,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
}
@@ -277,7 +287,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -5727,6 +5816,9 @@
@@ -5727,6 +5819,9 @@
this.tabContainer.insertBefore(aTab, neighbor);
}
});
@@ -287,7 +297,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
}
moveTabToGroup(aTab, aGroup) {
@@ -7443,6 +7535,7 @@
@@ -7443,6 +7538,7 @@
aWebProgress.isTopLevel
) {
this.mTab.setAttribute("busy", "true");
@@ -295,7 +305,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected;
gBrowser.syncThrobberAnimations(this.mTab);
@@ -8411,7 +8504,7 @@ var TabContextMenu = {
@@ -8411,7 +8507,7 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !multiselectionContext;
@@ -304,7 +314,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
// Move Tab items
let contextMoveTabOptions = document.getElementById(
"context_moveTabOptions"
@@ -8444,7 +8537,7 @@ var TabContextMenu = {
@@ -8444,7 +8540,7 @@ var TabContextMenu = {
let contextMoveTabToStart = document.getElementById("context_moveToStart");
let isFirstTab =
tabsToMove[0] == visibleTabs[0] ||
@@ -313,7 +323,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..cca93dc8fe6300a5bee22029bbe2369e
contextMoveTabToStart.disabled = isFirstTab && allSelectedTabsAdjacent;
document.getElementById("context_openTabInWindow").disabled =
@@ -8677,6 +8770,7 @@ var TabContextMenu = {
@@ -8677,6 +8773,7 @@ var TabContextMenu = {
if (this.contextTab.multiselected) {
gBrowser.removeMultiSelectedTabs();
} else {