Fixed split view groups being unpinned / pinned

This commit is contained in:
mr. m 2025-03-01 13:18:30 +01:00
parent 52e18e5125
commit 47c64661ec
No known key found for this signature in database
GPG key ID: 419302196C23B258
4 changed files with 164 additions and 90 deletions

View file

@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7472158f2 100644
index 628aa6596627c85efe361fc1ece8fd58f7ee653e..287ff24e0fee10f435fd33914756d9e94798f4f7 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -412,11 +412,50 @@
@ -55,25 +55,42 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
}
return i;
}
@@ -814,7 +853,7 @@
this.ungroupTab(aTab);
if (this.tabContainer.verticalMode) {
@@ -811,12 +850,13 @@
}
this.showTab(aTab);
- this.ungroupTab(aTab);
- if (this.tabContainer.verticalMode) {
+ const handled = gZenFolders.handleTabPin(aTab);
+ if (!handled) this.ungroupTab(aTab);
+ if (this.tabContainer.verticalMode && !handled) {
this._handleTabMove(aTab, () =>
- this.verticalPinnedTabsContainer.appendChild(aTab)
+ aTab.hasAttribute("zen-essential") ? document.getElementById("zen-essentials-container").appendChild(aTab) : this.verticalPinnedTabsContainer.insertBefore(aTab, this.verticalPinnedTabsContainer.lastChild)
);
} else {
- } else {
+ } else if (!handled) {
this.moveTabTo(aTab, this.pinnedTabCount, { forceStandaloneTab: true });
@@ -835,7 +874,7 @@
}
aTab.setAttribute("pinned", "true");
@@ -830,12 +870,15 @@
}
if (this.tabContainer.verticalMode) {
+ const handled = gZenFolders.handleTabUnpin(aTab);
this._handleTabMove(aTab, () => {
// we remove this attribute first, so that allTabs represents
// the moving of a tab from the vertical pinned tabs container
// and back into arrowscrollbox.
aTab.removeAttribute("pinned");
- this.tabContainer.arrowScrollbox.prepend(aTab);
+ ZenWorkspaces.activeWorkspaceStrip.prepend(aTab);
+ if (!handled) {
+ ZenWorkspaces.activeWorkspaceStrip.prepend(aTab);
+ }
});
} else {
this.moveTabTo(aTab, this.pinnedTabCount - 1, {
@@ -1018,6 +1057,8 @@
@@ -1018,6 +1061,8 @@
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
@ -82,7 +99,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (
aIconURL &&
!aLoadingPrincipal &&
@@ -1028,6 +1069,9 @@
@@ -1028,6 +1073,9 @@
);
return;
}
@ -92,7 +109,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
let browser = this.getBrowserForTab(aTab);
browser.mIconURL = aIconURL;
@@ -1273,6 +1317,7 @@
@@ -1273,6 +1321,7 @@
if (!this._previewMode) {
newTab.recordTimeFromUnloadToReload();
newTab.updateLastAccessed();
@ -100,7 +117,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
oldTab.updateLastAccessed();
// if this is the foreground window, update the last-seen timestamps.
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
@@ -1425,6 +1470,9 @@
@@ -1425,6 +1474,9 @@
}
let activeEl = document.activeElement;
@ -110,7 +127,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
// If focus is on the old tab, move it to the new tab.
if (activeEl == oldTab) {
newTab.focus();
@@ -1748,7 +1796,7 @@
@@ -1748,7 +1800,7 @@
}
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
@ -119,7 +136,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
return false;
}
@@ -1851,7 +1899,7 @@
@@ -1851,7 +1903,7 @@
newIndex = this.selectedTab._tPos + 1;
}
@ -128,7 +145,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
let browser;
if (targetTab) {
browser = this.getBrowserForTab(targetTab);
@@ -2108,6 +2156,7 @@
@@ -2108,6 +2160,7 @@
uriIsAboutBlank,
userContextId,
skipLoad,
@ -136,7 +153,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
} = {}) {
let b = document.createXULElement("browser");
// Use the JSM global to create the permanentKey, so that if the
@@ -2181,8 +2230,7 @@
@@ -2181,8 +2234,7 @@
// we use a different attribute name for this?
b.setAttribute("name", name);
}
@ -146,7 +163,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
b.setAttribute("transparent", "true");
}
@@ -2347,7 +2395,7 @@
@@ -2347,7 +2399,7 @@
let panel = this.getPanel(browser);
let uniqueId = this._generateUniquePanelID();
@ -155,7 +172,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
aTab.linkedPanel = uniqueId;
// Inject the <browser> into the DOM if necessary.
@@ -2406,8 +2454,8 @@
@@ -2406,8 +2458,8 @@
// If we transitioned from one browser to two browsers, we need to set
// hasSiblings=false on both the existing browser and the new browser.
if (this.tabs.length == 2) {
@ -166,7 +183,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
} else {
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
}
@@ -2629,6 +2677,7 @@
@@ -2629,6 +2681,7 @@
schemelessInput,
hasValidUserGestureActivation = false,
textDirectiveUserActivation = false,
@ -174,7 +191,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
} = {}
) {
// all callers of addTab that pass a params object need to pass
@@ -2639,6 +2688,12 @@
@@ -2639,6 +2692,12 @@
);
}
@ -187,7 +204,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (!UserInteraction.running("browser.tabs.opening", window)) {
UserInteraction.start("browser.tabs.opening", "initting", window);
}
@@ -2702,6 +2757,15 @@
@@ -2702,6 +2761,15 @@
noInitialLabel,
skipBackgroundNotify,
});
@ -203,7 +220,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (insertTab) {
// insert the tab into the tab container in the correct position
this._insertTabAtIndex(t, {
@@ -2726,6 +2790,7 @@
@@ -2726,6 +2794,7 @@
initialBrowsingContextGroupId,
openWindowInfo,
skipLoad,
@ -211,7 +228,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
}));
if (focusUrlBar) {
@@ -2845,6 +2910,9 @@
@@ -2845,6 +2914,9 @@
}
}
@ -221,7 +238,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
// Additionally send pinned tab events
if (pinned) {
this._notifyPinnedStatus(t);
@@ -2918,7 +2986,8 @@
@@ -2918,7 +2990,8 @@
id = `${Date.now()}-${Math.round(Math.random() * 100)}`;
}
let group = this._createTabGroup(id, color, false, label);
@ -231,7 +248,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
group,
insertBefore?.group ?? insertBefore
);
@@ -3126,6 +3195,7 @@
@@ -3126,6 +3199,7 @@
initialBrowsingContextGroupId,
openWindowInfo,
skipLoad,
@ -239,7 +256,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
}
) {
// If we don't have a preferred remote type, and we have a remote
@@ -3189,6 +3259,7 @@
@@ -3189,6 +3263,7 @@
openWindowInfo,
name,
skipLoad,
@ -247,7 +264,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
});
}
@@ -3367,6 +3438,24 @@
@@ -3367,6 +3442,24 @@
) {
tabWasReused = true;
tab = this.selectedTab;
@ -272,7 +289,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (!tabData.pinned) {
this.unpinTab(tab);
} else {
@@ -3380,6 +3469,7 @@
@@ -3380,6 +3473,7 @@
restoreTabsLazily && !select && !tabData.pinned;
let url = "about:blank";
@ -280,7 +297,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (tabData.entries?.length) {
let activeIndex = (tabData.index || tabData.entries.length) - 1;
// Ensure the index is in bounds.
@@ -3415,7 +3505,24 @@
@@ -3415,7 +3509,24 @@
skipLoad: true,
preferredRemoteType,
});
@ -306,7 +323,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (select) {
tabToSelect = tab;
}
@@ -3428,8 +3535,8 @@
@@ -3428,8 +3539,8 @@
// inserted in the DOM. If the tab is not yet in the DOM,
// just insert it in the right place from the start.
if (!tab.parentNode) {
@ -317,7 +334,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
tab.toggleAttribute("pinned", true);
this.tabContainer._invalidateCachedTabs();
// Then ensure all the tab open/pinning information is sent.
@@ -3693,7 +3800,7 @@
@@ -3693,7 +3804,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.
@ -326,7 +343,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (
!bulkOrderedOpen &&
((openerTab &&
@@ -3736,18 +3843,18 @@
@@ -3736,18 +3847,18 @@
// Ensure index is within bounds.
if (tab.pinned) {
@ -349,7 +366,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (tabAfter && tabAfter.group == tabGroup) {
// Place at the front of, or between tabs in, the same tab group
this.tabContainer.insertBefore(tab, tabAfter);
@@ -4059,6 +4166,9 @@
@@ -4059,6 +4170,9 @@
return;
}
@ -359,7 +376,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
this.removeTabs(selectedTabs);
}
@@ -4391,6 +4501,7 @@
@@ -4391,6 +4505,7 @@
skipSessionStore,
} = {}
) {
@ -367,7 +384,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (UserInteraction.running("browser.tabs.opening", window)) {
UserInteraction.finish("browser.tabs.opening", window);
}
@@ -4407,6 +4518,12 @@
@@ -4407,6 +4522,12 @@
TelemetryStopwatch.start("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
}
@ -380,7 +397,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
// Handle requests for synchronously removing an already
// asynchronously closing tab.
if (!animate && aTab.closing) {
@@ -4421,7 +4538,9 @@
@@ -4421,7 +4542,9 @@
// frame created for it (for example, by updating the visually selected
// state).
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
@ -391,7 +408,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (
!this._beginRemoveTab(aTab, {
closeWindowFastpath: true,
@@ -4435,7 +4554,6 @@
@@ -4435,7 +4558,6 @@
TelemetryStopwatch.cancel("FX_TAB_CLOSE_TIME_NO_ANIM_MS", aTab);
return;
}
@ -399,7 +416,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
let lockTabSizing =
!this.tabContainer.verticalMode &&
!aTab.pinned &&
@@ -4574,14 +4692,14 @@
@@ -4574,14 +4696,14 @@
!!this.tabsInCollapsedTabGroups.length;
if (
aTab.visible &&
@ -416,7 +433,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (closeWindow) {
// We've already called beforeunload on all the relevant tabs if we get here,
@@ -4605,6 +4723,7 @@
@@ -4605,6 +4727,7 @@
newTab = true;
}
@ -424,7 +441,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -4645,9 +4764,7 @@
@@ -4645,9 +4768,7 @@
aTab._mouseleave();
if (newTab) {
@ -435,7 +452,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
} else {
TabBarVisibility.update();
}
@@ -4776,6 +4893,8 @@
@@ -4776,6 +4897,8 @@
this.tabs[i]._tPos = i;
}
@ -444,7 +461,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (!this._windowIsClosing) {
if (wasPinned) {
this.tabContainer._positionPinnedTabs();
@@ -4994,7 +5113,7 @@
@@ -4994,7 +5117,7 @@
!excludeTabs.has(aTab.owner) &&
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) {
@ -453,7 +470,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
}
// Try to find a remaining tab that comes after the given tab
@@ -5016,7 +5135,7 @@
@@ -5016,7 +5139,7 @@
}
if (tab) {
@ -462,7 +479,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
}
// If no qualifying visible tab was found, see if there is a tab in
@@ -5434,10 +5553,10 @@
@@ -5434,10 +5557,10 @@
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
}
@ -475,7 +492,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -5675,7 +5794,7 @@
@@ -5675,7 +5798,7 @@
// Don't allow mixing pinned and unpinned tabs.
if (aTab.pinned) {
@ -484,7 +501,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
} else {
aIndex = Math.max(aIndex, this.pinnedTabCount);
}
@@ -5684,11 +5803,17 @@
@@ -5684,11 +5807,17 @@
}
this._handleTabMove(aTab, () => {
@ -505,7 +522,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
neighbor.after(aTab);
} else {
this.tabContainer.insertBefore(aTab, neighbor);
@@ -5697,7 +5822,7 @@
@@ -5697,7 +5826,7 @@
}
moveTabToGroup(aTab, aGroup) {
@ -514,7 +531,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
return;
}
if (aTab.group && aTab.group.id === aGroup.id) {
@@ -5721,6 +5846,8 @@
@@ -5721,6 +5850,8 @@
moveActionCallback();
@ -523,7 +540,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
// Clear tabs cache after moving nodes because the order of tabs may have
// changed.
this.tabContainer._invalidateCachedTabs();
@@ -5771,7 +5898,7 @@
@@ -5771,7 +5902,7 @@
createLazyBrowser,
};
@ -532,7 +549,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
if (aIndex < numPinned || (aTab.pinned && aIndex == numPinned)) {
params.pinned = true;
}
@@ -7415,6 +7542,7 @@
@@ -7415,6 +7546,7 @@
aWebProgress.isTopLevel
) {
this.mTab.setAttribute("busy", "true");
@ -540,7 +557,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
gBrowser._tabAttrModified(this.mTab, ["busy"]);
this.mTab._notselectedsinceload = !this.mTab.selected;
}
@@ -8381,7 +8509,7 @@ var TabContextMenu = {
@@ -8381,7 +8513,7 @@ var TabContextMenu = {
);
contextUnpinSelectedTabs.hidden =
!this.contextTab.pinned || !multiselectionContext;
@ -549,7 +566,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
// Move Tab items
let contextMoveTabOptions = document.getElementById(
"context_moveTabOptions"
@@ -8414,7 +8542,7 @@ var TabContextMenu = {
@@ -8414,7 +8546,7 @@ var TabContextMenu = {
let contextMoveTabToStart = document.getElementById("context_moveToStart");
let isFirstTab =
tabsToMove[0] == visibleTabs[0] ||
@ -558,7 +575,7 @@ index 628aa6596627c85efe361fc1ece8fd58f7ee653e..091194c85e35743c648f043a5fb7c8f7
contextMoveTabToStart.disabled = isFirstTab && allSelectedTabsAdjacent;
document.getElementById("context_openTabInWindow").disabled =
@@ -8647,6 +8775,7 @@ var TabContextMenu = {
@@ -8647,6 +8779,7 @@ var TabContextMenu = {
if (this.contextTab.multiselected) {
gBrowser.removeMultiSelectedTabs();
} else {