Skip to content

Commit f07c1a5

Browse files
committed
fix: Fixed splitting tabs inside groups, b=no-bug, c=no-component
1 parent 2c5a761 commit f07c1a5

File tree

1 file changed

+46
-44
lines changed

1 file changed

+46
-44
lines changed

src/browser/components/tabbrowser/content/tabbrowser-js.patch

Lines changed: 46 additions & 44 deletions
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 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca08923f359862 100644
2+
index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..b46335091e4d4ea71bf5027ea3a472cc839781b8 100644
33
--- a/browser/components/tabbrowser/content/tabbrowser.js
44
+++ b/browser/components/tabbrowser/content/tabbrowser.js
55
@@ -422,15 +422,60 @@
@@ -293,7 +293,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
293293
}
294294

295295
if (!color) {
296-
@@ -3040,7 +3132,12 @@
296+
@@ -3040,9 +3132,13 @@
297297
label,
298298
isAdoptingGroup
299299
);
@@ -303,11 +303,13 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
303303
+ }
304304
+ group.essential = tabs.some(tab => tab.hasAttribute("essential"));
305305
+ group.pinned = group.essential || tabs.some(tab => tab.pinned);
306-
+ ((insertBefore?.group ?? insertBefore).parentNode).insertBefore(
306+
+ insertBefore.before(
307307
group,
308-
insertBefore?.group ?? insertBefore
308+
- insertBefore?.group ?? insertBefore
309309
);
310-
@@ -3163,7 +3260,7 @@
310+
group.addTabs(tabs);
311+
312+
@@ -3163,7 +3259,7 @@
311313
}
312314

313315
this.#handleTabMove(tab, () =>
@@ -316,23 +318,23 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
316318
);
317319
}
318320

319-
@@ -3357,6 +3454,7 @@
321+
@@ -3357,6 +3453,7 @@
320322
openWindowInfo,
321323
skipLoad,
322324
triggeringRemoteType,
323325
+ _forZenEmptyTab
324326
}
325327
) {
326328
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
327-
@@ -3426,6 +3524,7 @@
329+
@@ -3426,6 +3523,7 @@
328330
openWindowInfo,
329331
name,
330332
skipLoad,
331333
+ _forZenEmptyTab
332334
});
333335
}
334336

335-
@@ -3613,7 +3712,7 @@
337+
@@ -3613,7 +3711,7 @@
336338
// Add a new tab if needed.
337339
if (!tab) {
338340
let createLazyBrowser =
@@ -341,7 +343,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
341343

342344
let url = "about:blank";
343345
if (tabData.entries?.length) {
344-
@@ -3650,8 +3749,10 @@
346+
@@ -3650,8 +3748,10 @@
345347
insertTab: false,
346348
skipLoad: true,
347349
preferredRemoteType,
@@ -353,7 +355,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
353355
if (select) {
354356
tabToSelect = tab;
355357
}
356-
@@ -3663,7 +3764,8 @@
358+
@@ -3663,7 +3763,8 @@
357359
this.pinTab(tab);
358360
// Then ensure all the tab open/pinning information is sent.
359361
this._fireTabOpen(tab, {});
@@ -363,7 +365,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
363365
let { groupId } = tabData;
364366
const tabGroup = tabGroupWorkingData.get(groupId);
365367
// if a tab refers to a tab group we don't know, skip any group
366-
@@ -3677,7 +3779,10 @@
368+
@@ -3677,7 +3778,10 @@
367369
tabGroup.stateData.id,
368370
tabGroup.stateData.color,
369371
tabGroup.stateData.collapsed,
@@ -375,7 +377,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
375377
);
376378
tabsFragment.appendChild(tabGroup.node);
377379
}
378-
@@ -3722,9 +3827,23 @@
380+
@@ -3722,9 +3826,23 @@
379381
// to remove the old selected tab.
380382
if (tabToSelect) {
381383
let leftoverTab = this.selectedTab;
@@ -399,7 +401,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
399401

400402
if (tabs.length > 1 || !tabs[0].selected) {
401403
this._updateTabsAfterInsert();
402-
@@ -3919,7 +4038,7 @@
404+
@@ -3919,7 +4037,7 @@
403405
// Ensure we have an index if one was not provided.
404406
if (typeof elementIndex != "number" && typeof tabIndex != "number") {
405407
// Move the new tab after another tab if needed, to the end otherwise.
@@ -408,7 +410,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
408410
if (
409411
!bulkOrderedOpen &&
410412
((openerTab &&
411-
@@ -3931,7 +4050,7 @@
413+
@@ -3931,7 +4049,7 @@
412414
let lastRelatedTab =
413415
openerTab && this._lastRelatedTabMap.get(openerTab);
414416
let previousTab = lastRelatedTab || openerTab || this.selectedTab;
@@ -417,7 +419,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
417419
tabGroup = previousTab.group;
418420
}
419421
if (
420-
@@ -3942,7 +4061,7 @@
422+
@@ -3942,7 +4060,7 @@
421423
) {
422424
elementIndex = Infinity;
423425
} else if (previousTab.visible) {
@@ -426,7 +428,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
426428
} else if (previousTab == FirefoxViewHandler.tab) {
427429
elementIndex = 0;
428430
}
429-
@@ -3970,14 +4089,14 @@
431+
@@ -3970,14 +4088,14 @@
430432
}
431433
// Ensure index is within bounds.
432434
if (tab.pinned) {
@@ -445,7 +447,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
445447

446448
// Prevent a flash of unstyled content by setting up the tab content
447449
// and inherited attributes before appending it (see Bug 1592054):
448-
@@ -3985,7 +4104,7 @@
450+
@@ -3985,7 +4103,7 @@
449451

450452
this.tabContainer._invalidateCachedTabs();
451453

@@ -454,15 +456,15 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
454456
if (this.isTab(itemAfter) && itemAfter.group == tabGroup) {
455457
// Place at the front of, or between tabs in, the same tab group
456458
this.tabContainer.insertBefore(tab, itemAfter);
457-
@@ -4018,6 +4137,7 @@
459+
@@ -4018,6 +4136,7 @@
458460
if (pinned) {
459461
this._updateTabBarForPinnedTabs();
460462
}
461463
+ gZenWorkspaces.fixTabInsertLocation(tab, itemAfter);
462464

463465
TabBarVisibility.update();
464466
}
465-
@@ -4307,6 +4427,9 @@
467+
@@ -4307,6 +4426,9 @@
466468
return;
467469
}
468470

@@ -472,23 +474,23 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
472474
this.removeTabs(selectedTabs, { isUserTriggered, telemetrySource });
473475
}
474476

475-
@@ -4568,6 +4691,7 @@
477+
@@ -4568,6 +4690,7 @@
476478
telemetrySource,
477479
} = {}
478480
) {
479481
+ tabs = tabs.filter(tab => !tab.hasAttribute("zen-empty-tab"));
480482
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
481483
// can be considered equivalent to closing the window.
482484
if (
483-
@@ -4657,6 +4781,7 @@
485+
@@ -4657,6 +4780,7 @@
484486
if (lastToClose) {
485487
this.removeTab(lastToClose, aParams);
486488
}
487489
+ gZenUIManager.onTabClose(undefined);
488490
} catch (e) {
489491
console.error(e);
490492
}
491-
@@ -4695,6 +4820,12 @@
493+
@@ -4695,6 +4819,12 @@
492494
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
493495
}
494496

@@ -501,7 +503,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
501503
// Handle requests for synchronously removing an already
502504
// asynchronously closing tab.
503505
if (!animate && aTab.closing) {
504-
@@ -4709,6 +4840,9 @@
506+
@@ -4709,6 +4839,9 @@
505507
// state).
506508
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
507509
let isLastTab = this.#isLastTabInWindow(aTab);
@@ -511,7 +513,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
511513
if (
512514
!this._beginRemoveTab(aTab, {
513515
closeWindowFastpath: true,
514-
@@ -4891,7 +5025,7 @@
516+
@@ -4891,7 +5024,7 @@
515517
closeWindowWithLastTab != null
516518
? closeWindowWithLastTab
517519
: !window.toolbar.visible ||
@@ -520,15 +522,15 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
520522

521523
if (closeWindow) {
522524
// We've already called beforeunload on all the relevant tabs if we get here,
523-
@@ -4915,6 +5049,7 @@
525+
@@ -4915,6 +5048,7 @@
524526

525527
newTab = true;
526528
}
527529
+ gZenWorkspaces._removedByStartupPage = false;
528530
aTab._endRemoveArgs = [closeWindow, newTab];
529531

530532
// swapBrowsersAndCloseOther will take care of closing the window without animation.
531-
@@ -4955,9 +5090,7 @@
533+
@@ -4955,9 +5089,7 @@
532534
aTab._mouseleave();
533535

534536
if (newTab) {
@@ -539,23 +541,23 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
539541
} else {
540542
TabBarVisibility.update();
541543
}
542-
@@ -5090,6 +5223,7 @@
544+
@@ -5090,6 +5222,7 @@
543545
this.tabs[i]._tPos = i;
544546
}
545547

546548
+ gZenWorkspaces.updateTabsContainers();
547549
if (!this._windowIsClosing) {
548550
// update tab close buttons state
549551
this.tabContainer._updateCloseButtons();
550-
@@ -5302,6 +5436,7 @@
552+
@@ -5302,6 +5435,7 @@
551553
}
552554

553555
let excludeTabs = new Set(aExcludeTabs);
554556
+ gZenWorkspaces.getTabsToExclude(aTab).forEach(tab => excludeTabs.add(tab));
555557

556558
// If this tab has a successor, it should be selectable, since
557559
// hiding or closing a tab removes that tab as a successor.
558-
@@ -5314,13 +5449,13 @@
560+
@@ -5314,13 +5448,13 @@
559561
!excludeTabs.has(aTab.owner) &&
560562
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
561563
) {
@@ -571,7 +573,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
571573
);
572574

573575
let tab = this.tabContainer.findNextTab(aTab, {
574-
@@ -5336,7 +5471,7 @@
576+
@@ -5336,7 +5470,7 @@
575577
}
576578

577579
if (tab) {
@@ -580,7 +582,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
580582
}
581583

582584
// If no qualifying visible tab was found, see if there is a tab in
583-
@@ -5357,7 +5492,7 @@
585+
@@ -5357,7 +5491,7 @@
584586
});
585587
}
586588

@@ -589,7 +591,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
589591
}
590592

591593
_blurTab(aTab) {
592-
@@ -5759,10 +5894,10 @@
594+
@@ -5759,10 +5893,10 @@
593595
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
594596
}
595597

@@ -602,7 +604,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
602604
aTab.selected ||
603605
aTab.closing ||
604606
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
605-
@@ -5952,7 +6087,7 @@
607+
@@ -5952,7 +6086,7 @@
606608
* `true` if element is a `<tab-group>`
607609
*/
608610
isTabGroup(element) {
@@ -611,7 +613,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
611613
}
612614

613615
/**
614-
@@ -6029,7 +6164,7 @@
616+
@@ -6029,7 +6163,7 @@
615617

616618
// Don't allow mixing pinned and unpinned tabs.
617619
if (this.isTab(element) && element.pinned) {
@@ -620,7 +622,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
620622
} else {
621623
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
622624
}
623-
@@ -6055,10 +6190,16 @@
625+
@@ -6055,10 +6189,16 @@
624626
this.#handleTabMove(
625627
element,
626628
() => {
@@ -639,7 +641,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
639641
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
640642
neighbor.after(element);
641643
} else {
642-
@@ -6116,22 +6257,26 @@
644+
@@ -6116,22 +6256,26 @@
643645
#moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) {
644646
if (this.isTabGroupLabel(targetElement)) {
645647
targetElement = targetElement.group;
@@ -672,7 +674,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
672674
moveBefore = false;
673675
} else if (!element.pinned && targetElement && targetElement.pinned) {
674676
// If the caller asks to move an unpinned element next to a pinned
675-
@@ -6145,14 +6290,18 @@
677+
@@ -6145,14 +6289,18 @@
676678
// move the tab group right before the first unpinned tab.
677679
// 4. Moving a tab group and the first unpinned tab is grouped:
678680
// move the tab group right before the first unpinned tab's tab group.
@@ -692,7 +694,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
692694
element.pinned
693695
? this.tabContainer.pinnedTabsContainer
694696
: this.tabContainer;
695-
@@ -6161,7 +6310,7 @@
697+
@@ -6161,7 +6309,7 @@
696698
element,
697699
() => {
698700
if (moveBefore) {
@@ -701,7 +703,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
701703
} else if (targetElement) {
702704
targetElement.after(element);
703705
} else {
704-
@@ -6210,7 +6359,7 @@
706+
@@ -6210,7 +6358,7 @@
705707
if (!this.isTab(aTab)) {
706708
throw new Error("Can only move a tab into a tab group");
707709
}
@@ -710,7 +712,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
710712
return;
711713
}
712714
if (aTab.group && aTab.group.id === aGroup.id) {
713-
@@ -6304,6 +6453,10 @@
715+
@@ -6304,6 +6452,10 @@
714716

715717
moveActionCallback();
716718

@@ -721,7 +723,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
721723
// Clear tabs cache after moving nodes because the order of tabs may have
722724
// changed.
723725
this.tabContainer._invalidateCachedTabs();
724-
@@ -7198,7 +7351,7 @@
726+
@@ -7198,7 +7350,7 @@
725727
// preventDefault(). It will still raise the window if appropriate.
726728
break;
727729
}
@@ -730,15 +732,15 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
730732
window.focus();
731733
aEvent.preventDefault();
732734
break;
733-
@@ -8143,6 +8296,7 @@
735+
@@ -8143,6 +8295,7 @@
734736
aWebProgress.isTopLevel
735737
) {
736738
this.mTab.setAttribute("busy", "true");
737739
+ if (!this.mTab.selected) this.mTab.setAttribute("unread", "true");
738740
gBrowser._tabAttrModified(this.mTab, ["busy"]);
739741
this.mTab._notselectedsinceload = !this.mTab.selected;
740742
}
741-
@@ -9108,7 +9262,7 @@ var TabContextMenu = {
743+
@@ -9108,7 +9261,7 @@ var TabContextMenu = {
742744
);
743745
contextUnpinSelectedTabs.hidden =
744746
!this.contextTab.pinned || !this.multiselected;
@@ -747,7 +749,7 @@ index 96fd8acdc09cc4c9649d1ed7503c2a0bde536613..7bb218913170222d55e7b7bdf4ca0892
747749
// Move Tab items
748750
let contextMoveTabOptions = document.getElementById(
749751
"context_moveTabOptions"
750-
@@ -9384,6 +9538,7 @@ var TabContextMenu = {
752+
@@ -9384,6 +9537,7 @@ var TabContextMenu = {
751753
)
752754
);
753755
} else {

0 commit comments

Comments
 (0)