1
1
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
2
- index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a0291b4d8d35 100644
2
+ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..87fb109037d13183e76184201de600a92b6a07d6 100644
3
3
--- a/browser/components/tabbrowser/content/tabbrowser.js
4
4
+++ b/browser/components/tabbrowser/content/tabbrowser.js
5
5
@@ -422,15 +422,49 @@
@@ -307,18 +307,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
307
307
});
308
308
}
309
309
310
- @@ -3570,7 +3659,9 @@
311
- let hiddenTabs = new Map();
312
- /** @type {Map<TabGroupStateData['id'], TabGroupWorkingData>} */
313
- let tabGroupWorkingData = new Map();
314
- -
315
- + if (this._hasAlreadyInitializedZenSessionStore) {
316
- + selectTab += 1; // SessionStoreInternal.restoreTabs expects a 1-based index.
317
- + }
318
- for (const tabGroupData of tabGroupDataList) {
319
- tabGroupWorkingData.set(tabGroupData.id, {
320
- stateData: tabGroupData,
321
- @@ -3613,7 +3704,7 @@
310
+ @@ -3613,7 +3702,7 @@
322
311
// Add a new tab if needed.
323
312
if (!tab) {
324
313
let createLazyBrowser =
@@ -327,7 +316,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
327
316
328
317
let url = "about:blank";
329
318
if (tabData.entries?.length) {
330
- @@ -3651,7 +3742 ,8 @@
319
+ @@ -3651,7 +3740 ,8 @@
331
320
skipLoad: true,
332
321
preferredRemoteType,
333
322
});
@@ -337,7 +326,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
337
326
if (select) {
338
327
tabToSelect = tab;
339
328
}
340
- @@ -3663,7 +3755 ,8 @@
329
+ @@ -3663,7 +3753 ,8 @@
341
330
this.pinTab(tab);
342
331
// Then ensure all the tab open/pinning information is sent.
343
332
this._fireTabOpen(tab, {});
@@ -347,7 +336,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
347
336
let { groupId } = tabData;
348
337
const tabGroup = tabGroupWorkingData.get(groupId);
349
338
// if a tab refers to a tab group we don't know, skip any group
350
- @@ -3677,7 +3770 ,10 @@
339
+ @@ -3677,7 +3768 ,10 @@
351
340
tabGroup.stateData.id,
352
341
tabGroup.stateData.color,
353
342
tabGroup.stateData.collapsed,
@@ -359,7 +348,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
359
348
);
360
349
tabsFragment.appendChild(tabGroup.node);
361
350
}
362
- @@ -3722,9 +3818 ,23 @@
351
+ @@ -3722,9 +3816 ,23 @@
363
352
// to remove the old selected tab.
364
353
if (tabToSelect) {
365
354
let leftoverTab = this.selectedTab;
@@ -369,21 +358,21 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
369
358
+ } else {
370
359
+ gZenWorkspaces._tabToRemoveForEmpty = leftoverTab;
371
360
+ if (Services.prefs.getBoolPref("zen.workspaces.continue-where-left-off")) {
372
- + gZenWorkspaces._tabToSelect = selectTab - 1;
361
+ + gZenWorkspaces._tabToSelect = selectTab - 2; // -1 for the offset, and another -1 for the empty tab.
373
362
+ }
374
363
+ if (gZenWorkspaces._initialTab && !gZenVerticalTabsManager._canReplaceNewTab) {
375
364
+ gZenWorkspaces._initialTab._shouldRemove = true;
376
365
+ }
377
366
+ }
378
- + }
367
+ }
379
368
+ else {
380
369
+ gZenWorkspaces._tabToRemoveForEmpty = this.selectedTab;
381
- }
370
+ + }
382
371
+ this._hasAlreadyInitializedZenSessionStore = true;
383
372
384
373
if (tabs.length > 1 || !tabs[0].selected) {
385
374
this._updateTabsAfterInsert();
386
- @@ -3919,7 +4029 ,7 @@
375
+ @@ -3919,7 +4027 ,7 @@
387
376
// Ensure we have an index if one was not provided.
388
377
if (typeof elementIndex != "number" && typeof tabIndex != "number") {
389
378
// Move the new tab after another tab if needed, to the end otherwise.
@@ -392,7 +381,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
392
381
if (
393
382
!bulkOrderedOpen &&
394
383
((openerTab &&
395
- @@ -3942,7 +4052 ,7 @@
384
+ @@ -3942,7 +4050 ,7 @@
396
385
) {
397
386
elementIndex = Infinity;
398
387
} else if (previousTab.visible) {
@@ -401,7 +390,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
401
390
} else if (previousTab == FirefoxViewHandler.tab) {
402
391
elementIndex = 0;
403
392
}
404
- @@ -3970,14 +4080 ,14 @@
393
+ @@ -3970,14 +4078 ,14 @@
405
394
}
406
395
// Ensure index is within bounds.
407
396
if (tab.pinned) {
@@ -420,7 +409,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
420
409
421
410
// Prevent a flash of unstyled content by setting up the tab content
422
411
// and inherited attributes before appending it (see Bug 1592054):
423
- @@ -3985,7 +4095 ,7 @@
412
+ @@ -3985,7 +4093 ,7 @@
424
413
425
414
this.tabContainer._invalidateCachedTabs();
426
415
@@ -429,15 +418,15 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
429
418
if (this.isTab(itemAfter) && itemAfter.group == tabGroup) {
430
419
// Place at the front of, or between tabs in, the same tab group
431
420
this.tabContainer.insertBefore(tab, itemAfter);
432
- @@ -4018,6 +4128 ,7 @@
421
+ @@ -4018,6 +4126 ,7 @@
433
422
if (pinned) {
434
423
this._updateTabBarForPinnedTabs();
435
424
}
436
425
+ gZenWorkspaces.fixTabInsertLocation(tab, itemAfter);
437
426
438
427
TabBarVisibility.update();
439
428
}
440
- @@ -4307,6 +4418 ,9 @@
429
+ @@ -4307,6 +4416 ,9 @@
441
430
return;
442
431
}
443
432
@@ -447,23 +436,23 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
447
436
this.removeTabs(selectedTabs, { isUserTriggered, telemetrySource });
448
437
}
449
438
450
- @@ -4568,6 +4682 ,7 @@
439
+ @@ -4568,6 +4680 ,7 @@
451
440
telemetrySource,
452
441
} = {}
453
442
) {
454
443
+ tabs = tabs.filter(tab => !tab.hasAttribute("zen-empty-tab"));
455
444
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
456
445
// can be considered equivalent to closing the window.
457
446
if (
458
- @@ -4657,6 +4772 ,7 @@
447
+ @@ -4657,6 +4770 ,7 @@
459
448
if (lastToClose) {
460
449
this.removeTab(lastToClose, aParams);
461
450
}
462
451
+ gZenUIManager.onTabClose(undefined);
463
452
} catch (e) {
464
453
console.error(e);
465
454
}
466
- @@ -4695,6 +4811 ,12 @@
455
+ @@ -4695,6 +4809 ,12 @@
467
456
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
468
457
}
469
458
@@ -476,7 +465,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
476
465
// Handle requests for synchronously removing an already
477
466
// asynchronously closing tab.
478
467
if (!animate && aTab.closing) {
479
- @@ -4709,6 +4831 ,9 @@
468
+ @@ -4709,6 +4829 ,9 @@
480
469
// state).
481
470
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
482
471
let isLastTab = this.#isLastTabInWindow(aTab);
@@ -486,7 +475,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
486
475
if (
487
476
!this._beginRemoveTab(aTab, {
488
477
closeWindowFastpath: true,
489
- @@ -4891,7 +5016 ,7 @@
478
+ @@ -4891,7 +5014 ,7 @@
490
479
closeWindowWithLastTab != null
491
480
? closeWindowWithLastTab
492
481
: !window.toolbar.visible ||
@@ -495,15 +484,15 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
495
484
496
485
if (closeWindow) {
497
486
// We've already called beforeunload on all the relevant tabs if we get here,
498
- @@ -4915,6 +5040 ,7 @@
487
+ @@ -4915,6 +5038 ,7 @@
499
488
500
489
newTab = true;
501
490
}
502
491
+ gZenWorkspaces._removedByStartupPage = false;
503
492
aTab._endRemoveArgs = [closeWindow, newTab];
504
493
505
494
// swapBrowsersAndCloseOther will take care of closing the window without animation.
506
- @@ -4955,9 +5081 ,7 @@
495
+ @@ -4955,9 +5079 ,7 @@
507
496
aTab._mouseleave();
508
497
509
498
if (newTab) {
@@ -514,23 +503,23 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
514
503
} else {
515
504
TabBarVisibility.update();
516
505
}
517
- @@ -5090,6 +5214 ,7 @@
506
+ @@ -5090,6 +5212 ,7 @@
518
507
this.tabs[i]._tPos = i;
519
508
}
520
509
521
510
+ gZenWorkspaces.updateTabsContainers();
522
511
if (!this._windowIsClosing) {
523
512
// update tab close buttons state
524
513
this.tabContainer._updateCloseButtons();
525
- @@ -5302,6 +5427 ,7 @@
514
+ @@ -5302,6 +5425 ,7 @@
526
515
}
527
516
528
517
let excludeTabs = new Set(aExcludeTabs);
529
518
+ gZenWorkspaces.getTabsToExclude(aTab).forEach(tab => excludeTabs.add(tab));
530
519
531
520
// If this tab has a successor, it should be selectable, since
532
521
// hiding or closing a tab removes that tab as a successor.
533
- @@ -5314,13 +5440 ,13 @@
522
+ @@ -5314,13 +5438 ,13 @@
534
523
!excludeTabs.has(aTab.owner) &&
535
524
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
536
525
) {
@@ -546,7 +535,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
546
535
);
547
536
548
537
let tab = this.tabContainer.findNextTab(aTab, {
549
- @@ -5336,7 +5462 ,7 @@
538
+ @@ -5336,7 +5460 ,7 @@
550
539
}
551
540
552
541
if (tab) {
@@ -555,7 +544,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
555
544
}
556
545
557
546
// If no qualifying visible tab was found, see if there is a tab in
558
- @@ -5357,7 +5483 ,7 @@
547
+ @@ -5357,7 +5481 ,7 @@
559
548
});
560
549
}
561
550
@@ -564,7 +553,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
564
553
}
565
554
566
555
_blurTab(aTab) {
567
- @@ -5759,10 +5885 ,10 @@
556
+ @@ -5759,10 +5883 ,10 @@
568
557
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
569
558
}
570
559
@@ -577,7 +566,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
577
566
aTab.selected ||
578
567
aTab.closing ||
579
568
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
580
- @@ -5952,7 +6078 ,7 @@
569
+ @@ -5952,7 +6076 ,7 @@
581
570
* `true` if element is a `<tab-group>`
582
571
*/
583
572
isTabGroup(element) {
@@ -586,7 +575,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
586
575
}
587
576
588
577
/**
589
- @@ -6029,7 +6155 ,7 @@
578
+ @@ -6029,7 +6153 ,7 @@
590
579
591
580
// Don't allow mixing pinned and unpinned tabs.
592
581
if (this.isTab(element) && element.pinned) {
@@ -595,7 +584,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
595
584
} else {
596
585
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
597
586
}
598
- @@ -6055,10 +6181 ,16 @@
587
+ @@ -6055,10 +6179 ,16 @@
599
588
this.#handleTabMove(
600
589
element,
601
590
() => {
@@ -614,7 +603,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
614
603
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
615
604
neighbor.after(element);
616
605
} else {
617
- @@ -6122,7 +6254 ,7 @@
606
+ @@ -6122,7 +6252 ,7 @@
618
607
moveBefore = true;
619
608
}
620
609
}
@@ -623,7 +612,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
623
612
element = element.group;
624
613
if (targetElement?.group) {
625
614
targetElement = targetElement.group;
626
- @@ -6130,8 +6262 ,12 @@
615
+ @@ -6130,8 +6260 ,12 @@
627
616
}
628
617
629
618
// Don't allow mixing pinned and unpinned tabs.
@@ -637,7 +626,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
637
626
moveBefore = false;
638
627
} else if (!element.pinned && targetElement && targetElement.pinned) {
639
628
// If the caller asks to move an unpinned element next to a pinned
640
- @@ -6145,7 +6281 ,7 @@
629
+ @@ -6145,7 +6279 ,7 @@
641
630
// move the tab group right before the first unpinned tab.
642
631
// 4. Moving a tab group and the first unpinned tab is grouped:
643
632
// move the tab group right before the first unpinned tab's tab group.
@@ -646,15 +635,15 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
646
635
if (targetElement.group) {
647
636
targetElement = targetElement.group;
648
637
}
649
- @@ -6153,6 +6289 ,7 @@
638
+ @@ -6153,6 +6287 ,7 @@
650
639
}
651
640
652
641
let getContainer = () =>
653
642
+ element.hasAttribute("zen-essential") ? gZenWorkspaces.getEssentialsSection(element) :
654
643
element.pinned
655
644
? this.tabContainer.pinnedTabsContainer
656
645
: this.tabContainer;
657
- @@ -6210,7 +6347 ,7 @@
646
+ @@ -6210,7 +6345 ,7 @@
658
647
if (!this.isTab(aTab)) {
659
648
throw new Error("Can only move a tab into a tab group");
660
649
}
@@ -663,7 +652,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
663
652
return;
664
653
}
665
654
if (aTab.group && aTab.group.id === aGroup.id) {
666
- @@ -6304,6 +6441 ,10 @@
655
+ @@ -6304,6 +6439 ,10 @@
667
656
668
657
moveActionCallback();
669
658
@@ -674,7 +663,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
674
663
// Clear tabs cache after moving nodes because the order of tabs may have
675
664
// changed.
676
665
this.tabContainer._invalidateCachedTabs();
677
- @@ -7198,7 +7339 ,7 @@
666
+ @@ -7198,7 +7337 ,7 @@
678
667
// preventDefault(). It will still raise the window if appropriate.
679
668
break;
680
669
}
@@ -683,15 +672,15 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
683
672
window.focus();
684
673
aEvent.preventDefault();
685
674
break;
686
- @@ -8143,6 +8284 ,7 @@
675
+ @@ -8143,6 +8282 ,7 @@
687
676
aWebProgress.isTopLevel
688
677
) {
689
678
this.mTab.setAttribute("busy", "true");
690
679
+ if (!this.mTab.selected) this.mTab.setAttribute("unread", "true");
691
680
gBrowser._tabAttrModified(this.mTab, ["busy"]);
692
681
this.mTab._notselectedsinceload = !this.mTab.selected;
693
682
}
694
- @@ -9108,7 +9250 ,7 @@ var TabContextMenu = {
683
+ @@ -9108,7 +9248 ,7 @@ var TabContextMenu = {
695
684
);
696
685
contextUnpinSelectedTabs.hidden =
697
686
!this.contextTab.pinned || !this.multiselected;
@@ -700,7 +689,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..e6b46996d96706d3641b6fc5c435a029
700
689
// Move Tab items
701
690
let contextMoveTabOptions = document.getElementById(
702
691
"context_moveTabOptions"
703
- @@ -9384,6 +9526 ,7 @@ var TabContextMenu = {
692
+ @@ -9384,6 +9524 ,7 @@ var TabContextMenu = {
704
693
)
705
694
);
706
695
} else {
0 commit comments