Fix: Ensure glance tabs are inserted correctly in the tab list order

This commit is contained in:
mr. M
2025-02-17 23:49:31 +01:00
parent bf34c9a9c3
commit 48a7e81906

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff7eed44ef 100644
index 8aeb244ffca9f48661805f5b7d860b5896055562..ad66e10f9b1c359eadf859cda58280479bc6483f 100644
--- a/browser/components/tabbrowser/content/tabs.js
+++ b/browser/components/tabbrowser/content/tabs.js
@@ -94,7 +94,7 @@
@@ -119,7 +119,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
// remove arrowScrollbox periphery element
children.pop();
@@ -1512,14 +1525,28 @@
@@ -1512,14 +1525,29 @@
}
this.#allTabs = [
@@ -132,8 +132,9 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
+ // add glance tabs (tabs inside tabs) to the list
+ const glanceTab = this.#allTabs[i].querySelector("tab[zen-glance-tab]");
+ if (glanceTab) {
+ // insert right after the parent tab
+ this.#allTabs.splice(i + 1, 0, glanceTab);
+ // insert right after the parent tab. note: it must be inserted before
+ // the last pinned tab so it can be inserted in the correct order
+ this.#allTabs.splice(Math.min(i + 1, lastPinnedTabIdx), 0, glanceTab);
+ i++;
+ } else if (this.#allTabs[i].classList.contains("vertical-pinned-tabs-container-separator")) {
+ // remove the separator from the list
@@ -150,7 +151,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
return children.filter(node => node.tagName == "tab-group");
}
@@ -1574,10 +1601,8 @@
@@ -1574,10 +1602,8 @@
return this.#focusableItems;
}
@@ -163,7 +164,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
let focusableItems = [];
for (let child of children) {
@@ -1593,6 +1618,7 @@
@@ -1593,6 +1619,7 @@
}
this.#focusableItems = [
@@ -171,7 +172,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
...verticalPinnedTabsContainer.children,
...focusableItems,
];
@@ -1617,8 +1643,8 @@
@@ -1617,8 +1644,8 @@
#isContainerVerticalPinnedExpanded(tab) {
return (
this.verticalMode &&
@@ -182,7 +183,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
);
}
@@ -1633,7 +1659,7 @@
@@ -1633,7 +1660,7 @@
if (node == null) {
// We have a container for non-tab elements at the end of the scrollbox.
@@ -191,7 +192,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
}
node.before(tab);
@@ -1733,7 +1759,7 @@
@@ -1733,7 +1760,7 @@
// There are separate "new tab" buttons for horizontal tabs toolbar, vertical tabs and
// for when the tab strip is overflowed (which is shared by vertical and horizontal tabs);
// Attach the long click popup to all of them.
@@ -200,7 +201,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
const newTab2 = this.newTabButton;
const newTabVertical = document.getElementById(
"vertical-tabs-newtab-button"
@@ -1816,7 +1842,7 @@
@@ -1816,7 +1843,7 @@
let rect = ele => {
return window.windowUtils.getBoundsWithoutFlushing(ele);
};
@@ -209,7 +210,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
if (tab && rect(tab).width <= this._tabClipWidth) {
this.setAttribute("closebuttons", "activetab");
} else {
@@ -1828,10 +1854,12 @@
@@ -1828,10 +1855,12 @@
_handleTabSelect(aInstant) {
let selectedTab = this.selectedItem;
@@ -222,7 +223,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
selectedTab._notselectedsinceload = false;
}
@@ -1843,7 +1871,7 @@
@@ -1843,7 +1872,7 @@
return;
}
@@ -231,7 +232,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
if (!tabs.length) {
return;
}
@@ -1879,7 +1907,7 @@
@@ -1879,7 +1908,7 @@
if (isEndTab && !this._hasTabTempMaxWidth) {
return;
}
@@ -240,7 +241,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
// Force tabs to stay the same width, unless we're closing the last tab,
// which case we need to let them expand just enough so that the overall
// tabbar width is the same.
@@ -1894,7 +1922,7 @@
@@ -1894,7 +1923,7 @@
let tabsToReset = [];
for (let i = numPinned; i < tabs.length; i++) {
let tab = tabs[i];
@@ -249,7 +250,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
if (!isEndTab) {
// keep tabs the same width
tab.style.transition = "none";
@@ -1960,16 +1988,15 @@
@@ -1960,16 +1989,15 @@
// Move pinned tabs to another container when the tabstrip is toggled to vertical
// and when session restore code calls _positionPinnedTabs; update styling whenever
// the number of pinned tabs changes.
@@ -271,7 +272,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
}
}
@@ -1977,9 +2004,7 @@
@@ -1977,9 +2005,7 @@
}
_resetVerticalPinnedTabs() {
@@ -282,7 +283,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
if (!verticalTabsContainer.children.length) {
return;
@@ -1992,8 +2017,8 @@
@@ -1992,8 +2018,8 @@
}
_positionPinnedTabs() {
@@ -293,7 +294,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
let absPositionHorizontalTabs =
this.overflowing && tabs.length > numPinned && numPinned > 0;
@@ -2003,6 +2028,7 @@
@@ -2003,6 +2029,7 @@
if (this.verticalMode) {
this._updateVerticalPinnedTabs();
} else if (absPositionHorizontalTabs) {
@@ -301,7 +302,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
let layoutData = this._pinnedTabsLayoutCache;
let uiDensity = document.documentElement.getAttribute("uidensity");
if (!layoutData || layoutData.uiDensity != uiDensity) {
@@ -2074,7 +2100,7 @@
@@ -2074,7 +2101,7 @@
return;
}
@@ -310,7 +311,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
let directionX = screenX > dragData.animLastScreenX;
let directionY = screenY > dragData.animLastScreenY;
@@ -2257,9 +2283,9 @@
@@ -2257,9 +2284,9 @@
}
let pinned = draggedTab.pinned;
@@ -323,7 +324,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
pinned ? numPinned : undefined
);
@@ -2502,8 +2528,9 @@
@@ -2502,8 +2529,9 @@
);
}
@@ -335,7 +336,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
return;
}
@@ -2668,9 +2695,9 @@
@@ -2668,9 +2696,9 @@
function newIndex(aTab, index) {
// Don't allow mixing pinned and unpinned tabs.
if (aTab.pinned) {
@@ -347,7 +348,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
}
}
@@ -2754,7 +2781,7 @@
@@ -2754,7 +2782,7 @@
}
_notifyBackgroundTab(aTab) {
@@ -356,7 +357,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
return;
}
@@ -2772,12 +2799,14 @@
@@ -2772,12 +2800,14 @@
selectedTab = {
left: selectedTab.left,
right: selectedTab.right,
@@ -372,7 +373,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
selectedTab,
];
})
@@ -2794,8 +2823,11 @@
@@ -2794,8 +2824,11 @@
delete this._lastTabToScrollIntoView;
// Is the new tab already completely visible?
if (
@@ -386,7 +387,7 @@ index 8aeb244ffca9f48661805f5b7d860b5896055562..117def8115affccadacfb75da57315ff
) {
return;
}
@@ -2803,21 +2835,29 @@
@@ -2803,21 +2836,29 @@
if (this.arrowScrollbox.smoothScroll) {
// Can we make both the new tab and the selected tab completely visible?
if (