Skip to content

Commit c4480f2

Browse files
committed
Enhance tab management by tracking removal of tabs initiated by the startup page
1 parent 4352051 commit c4480f2

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

Diff for: src/browser/base/zen-components/ZenWorkspaces.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
614614
currentTab.hasAttribute('zen-empty-tab')
615615
) {
616616
this.selectEmptyTab();
617+
this._removedByStartupPage = true;
617618
gBrowser.removeTab(currentTab);
618619
showed = true;
619620
}
@@ -638,7 +639,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
638639
}
639640

640641
handleTabBeforeClose(tab) {
641-
if (!this.workspaceEnabled || this.__contextIsDelete) {
642+
if (!this.workspaceEnabled || this.__contextIsDelete || this._removedByStartupPage) {
642643
return null;
643644
}
644645

Diff for: src/browser/components/tabbrowser/content/tabbrowser-js.patch

+22-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
2-
index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9bebc79c6c 100644
2+
index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..04056ab93316968babcf32921591731291f8e9db 100644
33
--- a/browser/components/tabbrowser/content/tabbrowser.js
44
+++ b/browser/components/tabbrowser/content/tabbrowser.js
55
@@ -406,11 +406,52 @@
@@ -347,11 +347,19 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
347347
? closeWindowWithLastTab
348348
: !window.toolbar.visible ||
349349
- Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab");
350-
+ Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab") && !ZenWorkspaces._isClosingWindow;
350+
+ Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab") && !ZenWorkspaces._isClosingWindow && !ZenWorkspaces._removedByStartupPage;
351351

352352
if (closeWindow) {
353353
// We've already called beforeunload on all the relevant tabs if we get here,
354-
@@ -4681,9 +4794,7 @@
354+
@@ -4641,6 +4754,7 @@
355+
356+
newTab = true;
357+
}
358+
+ ZenWorkspaces._removedByStartupPage = false;
359+
aTab._endRemoveArgs = [closeWindow, newTab];
360+
361+
// swapBrowsersAndCloseOther will take care of closing the window without animation.
362+
@@ -4681,9 +4795,7 @@
355363
aTab._mouseleave();
356364

357365
if (newTab) {
@@ -362,7 +370,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
362370
} else {
363371
TabBarVisibility.update();
364372
}
365-
@@ -4812,6 +4923,8 @@
373+
@@ -4812,6 +4924,8 @@
366374
this.tabs[i]._tPos = i;
367375
}
368376

@@ -371,7 +379,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
371379
if (!this._windowIsClosing) {
372380
if (wasPinned) {
373381
this.tabContainer._positionPinnedTabs();
374-
@@ -5025,7 +5138,7 @@
382+
@@ -5025,7 +5139,7 @@
375383
!excludeTabs.has(aTab.owner) &&
376384
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
377385
) {
@@ -380,7 +388,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
380388
}
381389

382390
// Try to find a remaining tab that comes after the given tab
383-
@@ -5047,7 +5160,7 @@
391+
@@ -5047,7 +5161,7 @@
384392
}
385393

386394
if (tab) {
@@ -389,7 +397,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
389397
}
390398

391399
// If no qualifying visible tab was found, see if there is a tab in
392-
@@ -5465,10 +5578,10 @@
400+
@@ -5465,10 +5579,10 @@
393401
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
394402
}
395403

@@ -402,7 +410,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
402410
aTab.selected ||
403411
aTab.closing ||
404412
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
405-
@@ -5706,9 +5819,9 @@
413+
@@ -5706,9 +5820,9 @@
406414

407415
// Don't allow mixing pinned and unpinned tabs.
408416
if (aTab.pinned) {
@@ -414,7 +422,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
414422
}
415423
if (aTab._tPos == aIndex) {
416424
return;
417-
@@ -5717,7 +5830,7 @@
425+
@@ -5717,7 +5831,7 @@
418426
this._lastRelatedTabMap = new WeakMap();
419427

420428
this._handleTabMove(aTab, () => {
@@ -423,7 +431,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
423431
if (forceStandaloneTab && neighbor.group) {
424432
neighbor = neighbor.group;
425433
}
426-
@@ -5802,7 +5915,7 @@
434+
@@ -5802,7 +5916,7 @@
427435
createLazyBrowser,
428436
};
429437

@@ -432,15 +440,15 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
432440
if (aIndex < numPinned || (aTab.pinned && aIndex == numPinned)) {
433441
params.pinned = true;
434442
}
435-
@@ -7443,6 +7556,7 @@
443+
@@ -7443,6 +7557,7 @@
436444
aWebProgress.isTopLevel
437445
) {
438446
this.mTab.setAttribute("busy", "true");
439447
+ if (!this.mTab.selected) this.mTab.setAttribute("unread", "true");
440448
gBrowser._tabAttrModified(this.mTab, ["busy"]);
441449
this.mTab._notselectedsinceload = !this.mTab.selected;
442450
gBrowser.syncThrobberAnimations(this.mTab);
443-
@@ -8411,7 +8525,7 @@ var TabContextMenu = {
451+
@@ -8411,7 +8526,7 @@ var TabContextMenu = {
444452
);
445453
contextUnpinSelectedTabs.hidden =
446454
!this.contextTab.pinned || !multiselectionContext;
@@ -449,7 +457,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
449457
// Move Tab items
450458
let contextMoveTabOptions = document.getElementById(
451459
"context_moveTabOptions"
452-
@@ -8444,7 +8558,7 @@ var TabContextMenu = {
460+
@@ -8444,7 +8559,7 @@ var TabContextMenu = {
453461
let contextMoveTabToStart = document.getElementById("context_moveToStart");
454462
let isFirstTab =
455463
tabsToMove[0] == visibleTabs[0] ||
@@ -458,7 +466,7 @@ index ff90a70bdad6c94ec4b90027ff102972d0eb28e5..f52457bfbce52b255a26eedd04f36e9b
458466
contextMoveTabToStart.disabled = isFirstTab && allSelectedTabsAdjacent;
459467

460468
document.getElementById("context_openTabInWindow").disabled =
461-
@@ -8677,6 +8791,7 @@ var TabContextMenu = {
469+
@@ -8677,6 +8792,7 @@ var TabContextMenu = {
462470
if (this.contextTab.multiselected) {
463471
gBrowser.removeMultiSelectedTabs();
464472
} else {

0 commit comments

Comments
 (0)