mirror of
https://github.com/zen-browser/desktop.git
synced 2026-02-23 20:06:38 +00:00
feat: Start using Firefox's split views to prevent memory leaks, b=no-bug, c=common, split-view
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
diff --git a/browser/components/tabbrowser/AsyncTabSwitcher.sys.mjs b/browser/components/tabbrowser/AsyncTabSwitcher.sys.mjs
|
||||
index bcd7689e9d68ef8b171c327188174334c4271e21..f69180acb87644f109aa91b871e347f1b1835f53 100644
|
||||
index bcd7689e9d68ef8b171c327188174334c4271e21..0a95e1137fdf4b63e0d841776ad934da1a513c6f 100644
|
||||
--- a/browser/components/tabbrowser/AsyncTabSwitcher.sys.mjs
|
||||
+++ b/browser/components/tabbrowser/AsyncTabSwitcher.sys.mjs
|
||||
@@ -938,6 +938,7 @@ export class AsyncTabSwitcher {
|
||||
this.tabbrowser._printPreviewBrowsers.has(browser) ||
|
||||
this.tabbrowser.splitViewBrowsers.includes(browser) ||
|
||||
lazy.PictureInPicture.isOriginatingBrowser(browser)
|
||||
+ || browser?.parentNode?.parentNode?.parentNode?.classList?.contains("zen-glance-background")
|
||||
+ || browser?.zenModeActive
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
|
||||
index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326cbd973686 100644
|
||||
index c0eafd4faf8d57b8486c5bf8917375850ec8147e..cead9e6e52f7354e20b8b64ad06a075e6923fe5f 100644
|
||||
--- a/browser/components/tabbrowser/content/tabbrowser.js
|
||||
+++ b/browser/components/tabbrowser/content/tabbrowser.js
|
||||
@@ -450,15 +450,64 @@
|
||||
@@ -386,6 +386,7 @@
|
||||
* @type {MozBrowser[]}
|
||||
*/
|
||||
get splitViewBrowsers() {
|
||||
+ return gZenViewSplitter.splitViewBrowsers;
|
||||
const browsers = [];
|
||||
if (this.#activeSplitView) {
|
||||
for (const tab of this.#activeSplitView.tabs) {
|
||||
@@ -450,15 +451,64 @@
|
||||
return this.tabContainer.visibleTabs;
|
||||
}
|
||||
|
||||
@@ -69,7 +77,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
set selectedTab(val) {
|
||||
if (
|
||||
gSharedTabWarning.willShowSharedTabWarning(val) ||
|
||||
@@ -613,6 +662,7 @@
|
||||
@@ -613,6 +663,7 @@
|
||||
this.tabpanels.appendChild(panel);
|
||||
|
||||
let tab = this.tabs[0];
|
||||
@@ -77,7 +85,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
tab.linkedPanel = uniqueId;
|
||||
this._selectedTab = tab;
|
||||
this._selectedBrowser = browser;
|
||||
@@ -898,13 +948,17 @@
|
||||
@@ -898,13 +949,17 @@
|
||||
}
|
||||
|
||||
this.showTab(aTab);
|
||||
@@ -96,7 +104,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
|
||||
aTab.setAttribute("pinned", "true");
|
||||
this._updateTabBarForPinnedTabs();
|
||||
@@ -917,11 +971,15 @@
|
||||
@@ -917,11 +972,15 @@
|
||||
}
|
||||
|
||||
this.#handleTabMove(aTab, () => {
|
||||
@@ -113,7 +121,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
});
|
||||
|
||||
aTab.style.marginInlineStart = "";
|
||||
@@ -1098,6 +1156,8 @@
|
||||
@@ -1098,6 +1157,8 @@
|
||||
|
||||
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
|
||||
|
||||
@@ -122,7 +130,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (
|
||||
aIconURL &&
|
||||
!LOCAL_PROTOCOLS.some(protocol => aIconURL.startsWith(protocol))
|
||||
@@ -1107,6 +1167,9 @@
|
||||
@@ -1107,6 +1168,9 @@
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -132,7 +140,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
|
||||
let browser = this.getBrowserForTab(aTab);
|
||||
browser.mIconURL = aIconURL;
|
||||
@@ -1379,7 +1442,6 @@
|
||||
@@ -1379,7 +1443,6 @@
|
||||
|
||||
// Preview mode should not reset the owner
|
||||
if (!this._previewMode && !oldTab.selected) {
|
||||
@@ -140,7 +148,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
}
|
||||
|
||||
let lastRelatedTab = this._lastRelatedTabMap.get(oldTab);
|
||||
@@ -1470,6 +1532,7 @@
|
||||
@@ -1470,6 +1533,7 @@
|
||||
if (!this._previewMode) {
|
||||
newTab.recordTimeFromUnloadToReload();
|
||||
newTab.updateLastAccessed();
|
||||
@@ -148,7 +156,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
oldTab.updateLastAccessed();
|
||||
// if this is the foreground window, update the last-seen timestamps.
|
||||
if (this.ownerGlobal == BrowserWindowTracker.getTopWindow()) {
|
||||
@@ -1622,6 +1685,9 @@
|
||||
@@ -1622,6 +1686,9 @@
|
||||
}
|
||||
|
||||
let activeEl = document.activeElement;
|
||||
@@ -158,7 +166,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
// If focus is on the old tab, move it to the new tab.
|
||||
if (activeEl == oldTab) {
|
||||
newTab.focus();
|
||||
@@ -1945,7 +2011,8 @@
|
||||
@@ -1945,7 +2012,8 @@
|
||||
}
|
||||
|
||||
_setTabLabel(aTab, aLabel, { beforeTabOpen, isContentTitle, isURL } = {}) {
|
||||
@@ -168,7 +176,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2053,7 +2120,7 @@
|
||||
@@ -2053,7 +2121,7 @@
|
||||
newIndex = this.selectedTab._tPos + 1;
|
||||
}
|
||||
|
||||
@@ -177,7 +185,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (this.isTabGroupLabel(targetTab)) {
|
||||
throw new Error(
|
||||
"Replacing a tab group label with a tab is not supported"
|
||||
@@ -2328,6 +2395,7 @@
|
||||
@@ -2328,6 +2396,7 @@
|
||||
uriIsAboutBlank,
|
||||
userContextId,
|
||||
skipLoad,
|
||||
@@ -185,7 +193,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
} = {}) {
|
||||
let b = document.createXULElement("browser");
|
||||
// Use the JSM global to create the permanentKey, so that if the
|
||||
@@ -2401,8 +2469,7 @@
|
||||
@@ -2401,8 +2470,7 @@
|
||||
// we use a different attribute name for this?
|
||||
b.setAttribute("name", name);
|
||||
}
|
||||
@@ -195,7 +203,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
b.setAttribute("transparent", "true");
|
||||
}
|
||||
|
||||
@@ -2567,7 +2634,7 @@
|
||||
@@ -2567,7 +2635,7 @@
|
||||
|
||||
let panel = this.getPanel(browser);
|
||||
let uniqueId = this._generateUniquePanelID();
|
||||
@@ -204,7 +212,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
aTab.linkedPanel = uniqueId;
|
||||
|
||||
// Inject the <browser> into the DOM if necessary.
|
||||
@@ -2626,8 +2693,8 @@
|
||||
@@ -2626,8 +2694,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) {
|
||||
@@ -215,7 +223,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
} else {
|
||||
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
|
||||
}
|
||||
@@ -2814,7 +2881,6 @@
|
||||
@@ -2814,7 +2882,6 @@
|
||||
this.selectedTab = this.addTrustedTab(BROWSER_NEW_TAB_URL, {
|
||||
tabIndex: tab._tPos + 1,
|
||||
userContextId: tab.userContextId,
|
||||
@@ -223,7 +231,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
focusUrlBar: true,
|
||||
});
|
||||
resolve(this.selectedBrowser);
|
||||
@@ -2923,6 +2989,8 @@
|
||||
@@ -2923,6 +2990,8 @@
|
||||
schemelessInput,
|
||||
hasValidUserGestureActivation = false,
|
||||
textDirectiveUserActivation = false,
|
||||
@@ -232,7 +240,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
} = {}
|
||||
) {
|
||||
// all callers of addTab that pass a params object need to pass
|
||||
@@ -2933,10 +3001,17 @@
|
||||
@@ -2933,10 +3002,17 @@
|
||||
);
|
||||
}
|
||||
|
||||
@@ -250,7 +258,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
// If we're opening a foreground tab, set the owner by default.
|
||||
ownerTab ??= inBackground ? null : this.selectedTab;
|
||||
|
||||
@@ -2944,6 +3019,7 @@
|
||||
@@ -2944,6 +3020,7 @@
|
||||
if (this.selectedTab.owner) {
|
||||
this.selectedTab.owner = null;
|
||||
}
|
||||
@@ -258,7 +266,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
|
||||
// Find the tab that opened this one, if any. This is used for
|
||||
// determining positioning, and inherited attributes such as the
|
||||
@@ -2996,6 +3072,19 @@
|
||||
@@ -2996,6 +3073,19 @@
|
||||
noInitialLabel,
|
||||
skipBackgroundNotify,
|
||||
});
|
||||
@@ -278,7 +286,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (insertTab) {
|
||||
// Insert the tab into the tab container in the correct position.
|
||||
this.#insertTabAtIndex(t, {
|
||||
@@ -3004,6 +3093,7 @@
|
||||
@@ -3004,6 +3094,7 @@
|
||||
ownerTab,
|
||||
openerTab,
|
||||
pinned,
|
||||
@@ -286,7 +294,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
bulkOrderedOpen,
|
||||
tabGroup: tabGroup ?? openerTab?.group,
|
||||
});
|
||||
@@ -3022,6 +3112,7 @@
|
||||
@@ -3022,6 +3113,7 @@
|
||||
openWindowInfo,
|
||||
skipLoad,
|
||||
triggeringRemoteType,
|
||||
@@ -294,7 +302,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
}));
|
||||
|
||||
if (focusUrlBar) {
|
||||
@@ -3146,6 +3237,12 @@
|
||||
@@ -3146,6 +3238,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,7 +315,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
// Additionally send pinned tab events
|
||||
if (pinned) {
|
||||
this.#notifyPinnedStatus(t);
|
||||
@@ -3330,10 +3427,10 @@
|
||||
@@ -3330,10 +3428,10 @@
|
||||
isAdoptingGroup = false,
|
||||
isUserTriggered = false,
|
||||
telemetryUserCreateSource = "unknown",
|
||||
@@ -319,7 +327,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
}
|
||||
|
||||
if (!color) {
|
||||
@@ -3354,9 +3451,14 @@
|
||||
@@ -3354,9 +3452,14 @@
|
||||
label,
|
||||
isAdoptingGroup
|
||||
);
|
||||
@@ -336,7 +344,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
);
|
||||
group.addTabs(tabs);
|
||||
|
||||
@@ -3477,7 +3579,7 @@
|
||||
@@ -3477,7 +3580,7 @@
|
||||
}
|
||||
|
||||
this.#handleTabMove(tab, () =>
|
||||
@@ -345,7 +353,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3679,6 +3781,7 @@
|
||||
@@ -3679,6 +3782,7 @@
|
||||
openWindowInfo,
|
||||
skipLoad,
|
||||
triggeringRemoteType,
|
||||
@@ -353,7 +361,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
}
|
||||
) {
|
||||
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
|
||||
@@ -3748,6 +3851,7 @@
|
||||
@@ -3748,6 +3852,7 @@
|
||||
openWindowInfo,
|
||||
name,
|
||||
skipLoad,
|
||||
@@ -361,7 +369,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3935,7 +4039,7 @@
|
||||
@@ -3935,7 +4040,7 @@
|
||||
// Add a new tab if needed.
|
||||
if (!tab) {
|
||||
let createLazyBrowser =
|
||||
@@ -370,7 +378,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
|
||||
let url = "about:blank";
|
||||
if (tabData.entries?.length) {
|
||||
@@ -3972,8 +4076,10 @@
|
||||
@@ -3972,8 +4077,10 @@
|
||||
insertTab: false,
|
||||
skipLoad: true,
|
||||
preferredRemoteType,
|
||||
@@ -382,7 +390,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (select) {
|
||||
tabToSelect = tab;
|
||||
}
|
||||
@@ -3985,7 +4091,8 @@
|
||||
@@ -3985,7 +4092,8 @@
|
||||
this.pinTab(tab);
|
||||
// Then ensure all the tab open/pinning information is sent.
|
||||
this._fireTabOpen(tab, {});
|
||||
@@ -392,7 +400,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
let { groupId } = tabData;
|
||||
const tabGroup = tabGroupWorkingData.get(groupId);
|
||||
// if a tab refers to a tab group we don't know, skip any group
|
||||
@@ -3999,7 +4106,10 @@
|
||||
@@ -3999,7 +4107,10 @@
|
||||
tabGroup.stateData.id,
|
||||
tabGroup.stateData.color,
|
||||
tabGroup.stateData.collapsed,
|
||||
@@ -404,7 +412,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
);
|
||||
tabsFragment.appendChild(tabGroup.node);
|
||||
}
|
||||
@@ -4044,9 +4154,23 @@
|
||||
@@ -4044,9 +4155,23 @@
|
||||
// to remove the old selected tab.
|
||||
if (tabToSelect) {
|
||||
let leftoverTab = this.selectedTab;
|
||||
@@ -428,7 +436,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
|
||||
if (tabs.length > 1 || !tabs[0].selected) {
|
||||
this._updateTabsAfterInsert();
|
||||
@@ -4237,11 +4361,14 @@
|
||||
@@ -4237,11 +4362,14 @@
|
||||
if (ownerTab) {
|
||||
tab.owner = ownerTab;
|
||||
}
|
||||
@@ -444,7 +452,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (
|
||||
!bulkOrderedOpen &&
|
||||
((openerTab &&
|
||||
@@ -4253,7 +4380,7 @@
|
||||
@@ -4253,7 +4381,7 @@
|
||||
let lastRelatedTab =
|
||||
openerTab && this._lastRelatedTabMap.get(openerTab);
|
||||
let previousTab = lastRelatedTab || openerTab || this.selectedTab;
|
||||
@@ -453,7 +461,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
tabGroup = previousTab.group;
|
||||
}
|
||||
if (
|
||||
@@ -4264,7 +4391,7 @@
|
||||
@@ -4264,7 +4392,7 @@
|
||||
) {
|
||||
elementIndex = Infinity;
|
||||
} else if (previousTab.visible) {
|
||||
@@ -462,7 +470,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
} else if (previousTab == FirefoxViewHandler.tab) {
|
||||
elementIndex = 0;
|
||||
}
|
||||
@@ -4292,14 +4419,14 @@
|
||||
@@ -4292,14 +4420,14 @@
|
||||
}
|
||||
// Ensure index is within bounds.
|
||||
if (tab.pinned) {
|
||||
@@ -481,7 +489,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
|
||||
if (pinned && !itemAfter?.pinned) {
|
||||
itemAfter = null;
|
||||
@@ -4310,7 +4437,7 @@
|
||||
@@ -4310,7 +4438,7 @@
|
||||
|
||||
this.tabContainer._invalidateCachedTabs();
|
||||
|
||||
@@ -490,7 +498,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (this.isTab(itemAfter) && itemAfter.group == tabGroup) {
|
||||
// Place at the front of, or between tabs in, the same tab group
|
||||
this.tabContainer.insertBefore(tab, itemAfter);
|
||||
@@ -4338,7 +4465,11 @@
|
||||
@@ -4338,7 +4466,11 @@
|
||||
const tabContainer = pinned
|
||||
? this.tabContainer.pinnedTabsContainer
|
||||
: this.tabContainer;
|
||||
@@ -502,7 +510,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
}
|
||||
|
||||
this._updateTabsAfterInsert();
|
||||
@@ -4346,6 +4477,7 @@
|
||||
@@ -4346,6 +4478,7 @@
|
||||
if (pinned) {
|
||||
this._updateTabBarForPinnedTabs();
|
||||
}
|
||||
@@ -510,7 +518,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
|
||||
TabBarVisibility.update();
|
||||
}
|
||||
@@ -4635,6 +4767,9 @@
|
||||
@@ -4635,6 +4768,9 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -520,7 +528,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
this.removeTabs(selectedTabs, { isUserTriggered, telemetrySource });
|
||||
}
|
||||
|
||||
@@ -4896,6 +5031,7 @@
|
||||
@@ -4896,6 +5032,7 @@
|
||||
telemetrySource,
|
||||
} = {}
|
||||
) {
|
||||
@@ -528,7 +536,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
|
||||
// can be considered equivalent to closing the window.
|
||||
if (
|
||||
@@ -4985,6 +5121,7 @@
|
||||
@@ -4985,6 +5122,7 @@
|
||||
if (lastToClose) {
|
||||
this.removeTab(lastToClose, aParams);
|
||||
}
|
||||
@@ -536,7 +544,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
@@ -5023,6 +5160,12 @@
|
||||
@@ -5023,6 +5161,12 @@
|
||||
aTab._closeTimeNoAnimTimerId = Glean.browserTabclose.timeNoAnim.start();
|
||||
}
|
||||
|
||||
@@ -549,7 +557,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
// Handle requests for synchronously removing an already
|
||||
// asynchronously closing tab.
|
||||
if (!animate && aTab.closing) {
|
||||
@@ -5037,6 +5180,9 @@
|
||||
@@ -5037,6 +5181,9 @@
|
||||
// state).
|
||||
let tabWidth = window.windowUtils.getBoundsWithoutFlushing(aTab).width;
|
||||
let isLastTab = this.#isLastTabInWindow(aTab);
|
||||
@@ -559,7 +567,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (
|
||||
!this._beginRemoveTab(aTab, {
|
||||
closeWindowFastpath: true,
|
||||
@@ -5085,7 +5231,13 @@
|
||||
@@ -5085,7 +5232,13 @@
|
||||
// We're not animating, so we can cancel the animation stopwatch.
|
||||
Glean.browserTabclose.timeAnim.cancel(aTab._closeTimeAnimTimerId);
|
||||
aTab._closeTimeAnimTimerId = null;
|
||||
@@ -574,7 +582,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5219,7 +5371,7 @@
|
||||
@@ -5219,7 +5372,7 @@
|
||||
closeWindowWithLastTab != null
|
||||
? closeWindowWithLastTab
|
||||
: !window.toolbar.visible ||
|
||||
@@ -583,7 +591,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
|
||||
if (closeWindow) {
|
||||
// We've already called beforeunload on all the relevant tabs if we get here,
|
||||
@@ -5243,6 +5395,7 @@
|
||||
@@ -5243,6 +5396,7 @@
|
||||
|
||||
newTab = true;
|
||||
}
|
||||
@@ -591,7 +599,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
aTab._endRemoveArgs = [closeWindow, newTab];
|
||||
|
||||
// swapBrowsersAndCloseOther will take care of closing the window without animation.
|
||||
@@ -5283,13 +5436,7 @@
|
||||
@@ -5283,13 +5437,7 @@
|
||||
aTab._mouseleave();
|
||||
|
||||
if (newTab) {
|
||||
@@ -606,7 +614,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
} else {
|
||||
TabBarVisibility.update();
|
||||
}
|
||||
@@ -5422,6 +5569,7 @@
|
||||
@@ -5422,6 +5570,7 @@
|
||||
this.tabs[i]._tPos = i;
|
||||
}
|
||||
|
||||
@@ -614,7 +622,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (!this._windowIsClosing) {
|
||||
// update tab close buttons state
|
||||
this.tabContainer._updateCloseButtons();
|
||||
@@ -5643,6 +5791,7 @@
|
||||
@@ -5643,6 +5792,7 @@
|
||||
}
|
||||
|
||||
let excludeTabs = new Set(aExcludeTabs);
|
||||
@@ -622,7 +630,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
|
||||
// If this tab has a successor, it should be selectable, since
|
||||
// hiding or closing a tab removes that tab as a successor.
|
||||
@@ -5655,13 +5804,13 @@
|
||||
@@ -5655,13 +5805,13 @@
|
||||
!excludeTabs.has(aTab.owner) &&
|
||||
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
|
||||
) {
|
||||
@@ -638,7 +646,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
);
|
||||
|
||||
let tab = this.tabContainer.findNextTab(aTab, {
|
||||
@@ -5677,7 +5826,7 @@
|
||||
@@ -5677,7 +5827,7 @@
|
||||
}
|
||||
|
||||
if (tab) {
|
||||
@@ -647,7 +655,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
}
|
||||
|
||||
// If no qualifying visible tab was found, see if there is a tab in
|
||||
@@ -5698,7 +5847,7 @@
|
||||
@@ -5698,7 +5848,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
@@ -656,7 +664,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
}
|
||||
|
||||
_blurTab(aTab) {
|
||||
@@ -6104,10 +6253,10 @@
|
||||
@@ -6104,10 +6254,10 @@
|
||||
SessionStore.deleteCustomTabValue(aTab, "hiddenBy");
|
||||
}
|
||||
|
||||
@@ -669,7 +677,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
aTab.selected ||
|
||||
aTab.closing ||
|
||||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
|
||||
@@ -6166,6 +6315,7 @@
|
||||
@@ -6166,6 +6316,7 @@
|
||||
* @param {MozTabbrowserTab|MozTabbrowserTabGroup|MozTabbrowserTabGroup.labelElement} aTab
|
||||
*/
|
||||
replaceTabWithWindow(aTab, aOptions) {
|
||||
@@ -677,7 +685,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (this.tabs.length == 1) {
|
||||
return null;
|
||||
}
|
||||
@@ -6299,7 +6449,7 @@
|
||||
@@ -6299,7 +6450,7 @@
|
||||
* `true` if element is a `<tab-group>`
|
||||
*/
|
||||
isTabGroup(element) {
|
||||
@@ -686,7 +694,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6375,8 +6525,8 @@
|
||||
@@ -6375,8 +6526,8 @@
|
||||
}
|
||||
|
||||
// Don't allow mixing pinned and unpinned tabs.
|
||||
@@ -697,7 +705,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
} else {
|
||||
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
|
||||
}
|
||||
@@ -6402,10 +6552,16 @@
|
||||
@@ -6402,10 +6553,16 @@
|
||||
this.#handleTabMove(
|
||||
element,
|
||||
() => {
|
||||
@@ -716,7 +724,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
if (neighbor && this.isTab(element) && tabIndex > element._tPos) {
|
||||
neighbor.after(element);
|
||||
} else {
|
||||
@@ -6463,23 +6619,28 @@
|
||||
@@ -6463,23 +6620,28 @@
|
||||
#moveTabNextTo(element, targetElement, moveBefore = false, metricsContext) {
|
||||
if (this.isTabGroupLabel(targetElement)) {
|
||||
targetElement = targetElement.group;
|
||||
@@ -751,7 +759,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
} else if (!element.pinned && targetElement && targetElement.pinned) {
|
||||
// If the caller asks to move an unpinned element next to a pinned
|
||||
// tab, move the unpinned element to be the first unpinned element
|
||||
@@ -6492,14 +6653,34 @@
|
||||
@@ -6492,14 +6654,34 @@
|
||||
// move the tab group right before the first unpinned tab.
|
||||
// 4. Moving a tab group and the first unpinned tab is grouped:
|
||||
// move the tab group right before the first unpinned tab's tab group.
|
||||
@@ -787,7 +795,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
element.pinned
|
||||
? this.tabContainer.pinnedTabsContainer
|
||||
: this.tabContainer;
|
||||
@@ -6508,7 +6689,7 @@
|
||||
@@ -6508,7 +6690,7 @@
|
||||
element,
|
||||
() => {
|
||||
if (moveBefore) {
|
||||
@@ -796,7 +804,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
} else if (targetElement) {
|
||||
targetElement.after(element);
|
||||
} else {
|
||||
@@ -6580,10 +6761,10 @@
|
||||
@@ -6580,10 +6762,10 @@
|
||||
* @param {TabMetricsContext} [metricsContext]
|
||||
*/
|
||||
moveTabToGroup(aTab, aGroup, metricsContext) {
|
||||
@@ -809,7 +817,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
return;
|
||||
}
|
||||
if (aTab.group && aTab.group.id === aGroup.id) {
|
||||
@@ -6613,6 +6794,7 @@
|
||||
@@ -6613,6 +6795,7 @@
|
||||
|
||||
let state = {
|
||||
tabIndex: tab._tPos,
|
||||
@@ -817,7 +825,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
};
|
||||
if (tab.visible) {
|
||||
state.elementIndex = tab.elementIndex;
|
||||
@@ -6639,7 +6821,7 @@
|
||||
@@ -6639,7 +6822,7 @@
|
||||
let changedTabGroup =
|
||||
previousTabState.tabGroupId != currentTabState.tabGroupId;
|
||||
|
||||
@@ -826,7 +834,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
tab.dispatchEvent(
|
||||
new CustomEvent("TabMove", {
|
||||
bubbles: true,
|
||||
@@ -6676,6 +6858,10 @@
|
||||
@@ -6676,6 +6859,10 @@
|
||||
|
||||
moveActionCallback();
|
||||
|
||||
@@ -837,7 +845,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
// Clear tabs cache after moving nodes because the order of tabs may have
|
||||
// changed.
|
||||
this.tabContainer._invalidateCachedTabs();
|
||||
@@ -7576,7 +7762,7 @@
|
||||
@@ -7576,7 +7763,7 @@
|
||||
// preventDefault(). It will still raise the window if appropriate.
|
||||
break;
|
||||
}
|
||||
@@ -846,7 +854,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
window.focus();
|
||||
aEvent.preventDefault();
|
||||
break;
|
||||
@@ -7593,7 +7779,6 @@
|
||||
@@ -7593,7 +7780,6 @@
|
||||
}
|
||||
case "TabGroupCollapse":
|
||||
aEvent.target.tabs.forEach(tab => {
|
||||
@@ -854,7 +862,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
});
|
||||
break;
|
||||
case "TabGroupCreateByUser":
|
||||
@@ -8542,6 +8727,7 @@
|
||||
@@ -8542,6 +8728,7 @@
|
||||
aWebProgress.isTopLevel
|
||||
) {
|
||||
this.mTab.setAttribute("busy", "true");
|
||||
@@ -862,7 +870,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
gBrowser._tabAttrModified(this.mTab, ["busy"]);
|
||||
this.mTab._notselectedsinceload = !this.mTab.selected;
|
||||
}
|
||||
@@ -9543,7 +9729,7 @@ var TabContextMenu = {
|
||||
@@ -9543,7 +9730,7 @@ var TabContextMenu = {
|
||||
);
|
||||
contextUnpinSelectedTabs.hidden =
|
||||
!this.contextTab.pinned || !this.multiselected;
|
||||
@@ -871,7 +879,7 @@ index c0eafd4faf8d57b8486c5bf8917375850ec8147e..1bf95403333f914f082b38441d31326c
|
||||
// Build Ask Chat items
|
||||
TabContextMenu.GenAI.buildTabMenu(
|
||||
document.getElementById("context_askChat"),
|
||||
@@ -9863,6 +10049,7 @@ var TabContextMenu = {
|
||||
@@ -9863,6 +10050,7 @@ var TabContextMenu = {
|
||||
)
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -493,20 +493,26 @@ var gZenUIManager = {
|
||||
|
||||
if (gURLBar.focused) {
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('ZenURLBarClosed', { detail: { onSwitch, onElementPicked } })
|
||||
);
|
||||
gURLBar.view.close({ elementPicked: onElementPicked });
|
||||
gURLBar.updateTextOverflow();
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('ZenURLBarClosed', { detail: { onSwitch, onElementPicked } })
|
||||
);
|
||||
gURLBar.view.close({ elementPicked: onElementPicked });
|
||||
gURLBar.updateTextOverflow();
|
||||
|
||||
// Ensure tab and browser are valid before updating state
|
||||
const selectedTab = gBrowser.selectedTab;
|
||||
if (selectedTab && selectedTab.linkedBrowser && !selectedTab.closing && onSwitch) {
|
||||
const browserState = gURLBar.getBrowserState(selectedTab.linkedBrowser);
|
||||
if (browserState) {
|
||||
browserState.urlbarFocused = false;
|
||||
if (onElementPicked && onSwitch) {
|
||||
gURLBar.setURI(null, onSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure tab and browser are valid before updating state
|
||||
const selectedTab = gBrowser.selectedTab;
|
||||
if (selectedTab && selectedTab.linkedBrowser && !selectedTab.closing && onSwitch) {
|
||||
const browserState = gURLBar.getBrowserState(selectedTab.linkedBrowser);
|
||||
if (browserState) {
|
||||
browserState.urlbarFocused = false;
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1067,86 +1067,88 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
||||
* @param {string|undefined} gridType - The type of grid layout.
|
||||
*/
|
||||
splitTabs(tabs, gridType, initialIndex = 0) {
|
||||
// TODO: Add support for splitting essential tabs
|
||||
tabs = tabs.filter((t) => !t.hidden && !t.hasAttribute('zen-empty-tab'));
|
||||
if (tabs.length < 2 || tabs.length > this.MAX_TABS) {
|
||||
return;
|
||||
}
|
||||
this.#withoutSplitViewTransition(() => {
|
||||
// TODO: Add support for splitting essential tabs
|
||||
tabs = tabs.filter((t) => !t.hidden && !t.hasAttribute('zen-empty-tab'));
|
||||
if (tabs.length < 2 || tabs.length > this.MAX_TABS) {
|
||||
return;
|
||||
}
|
||||
|
||||
const existingSplitTab = tabs.find((tab) => tab.splitView);
|
||||
if (existingSplitTab) {
|
||||
this._moveTabsToContainer(tabs, tabs[initialIndex]);
|
||||
const groupIndex = this._data.findIndex((group) => group.tabs.includes(existingSplitTab));
|
||||
const group = this._data[groupIndex];
|
||||
const gridTypeChange = gridType && group.gridType !== gridType;
|
||||
const newTabsAdded = tabs.find((t) => !group.tabs.includes(t));
|
||||
if (gridTypeChange || !newTabsAdded) {
|
||||
// reset layout
|
||||
group.gridType = gridType;
|
||||
group.layoutTree = this.calculateLayoutTree(
|
||||
[...new Set(group.tabs.concat(tabs))],
|
||||
gridType
|
||||
);
|
||||
} else {
|
||||
// Add any tabs that are not already in the group
|
||||
const existingSplitTab = tabs.find((tab) => tab.splitView);
|
||||
if (existingSplitTab) {
|
||||
this._moveTabsToContainer(tabs, tabs[initialIndex]);
|
||||
const groupIndex = this._data.findIndex((group) => group.tabs.includes(existingSplitTab));
|
||||
const group = this._data[groupIndex];
|
||||
const gridTypeChange = gridType && group.gridType !== gridType;
|
||||
const newTabsAdded = tabs.find((t) => !group.tabs.includes(t));
|
||||
if (gridTypeChange || !newTabsAdded) {
|
||||
// reset layout
|
||||
group.gridType = gridType;
|
||||
group.layoutTree = this.calculateLayoutTree(
|
||||
[...new Set(group.tabs.concat(tabs))],
|
||||
gridType
|
||||
);
|
||||
} else {
|
||||
// Add any tabs that are not already in the group
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
const tab = tabs[i];
|
||||
if (!group.tabs.includes(tab)) {
|
||||
gBrowser.moveTabToGroup(tab, this._getSplitViewGroup(tabs));
|
||||
group.tabs.push(tab);
|
||||
this.addTabToSplit(tab, group.layoutTree);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this._sessionRestoring) {
|
||||
return;
|
||||
}
|
||||
this.activateSplitView(group, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// We are here if none of the tabs have been previously split
|
||||
// If there's ANY pinned tab on the list, we clone the pinned tab
|
||||
// state to all the tabs
|
||||
const allArePinned = tabs.every((tab) => tab.pinned);
|
||||
const thereIsOnePinned = tabs.some((tab) => tab.pinned);
|
||||
const thereIsOneEssential = tabs.some((tab) => tab.hasAttribute('zen-essential'));
|
||||
|
||||
if (thereIsOneEssential || (thereIsOnePinned && !allArePinned)) {
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
const tab = tabs[i];
|
||||
if (!group.tabs.includes(tab)) {
|
||||
gBrowser.moveTabToGroup(tab, this._getSplitViewGroup(tabs));
|
||||
group.tabs.push(tab);
|
||||
this.addTabToSplit(tab, group.layoutTree);
|
||||
if (tab.pinned) {
|
||||
tabs[i] = gBrowser.duplicateTab(tab, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gridType ??= 'grid';
|
||||
|
||||
const splitData = {
|
||||
tabs,
|
||||
gridType,
|
||||
layoutTree: this.calculateLayoutTree(tabs, gridType),
|
||||
};
|
||||
this._data.push(splitData);
|
||||
if (!this._sessionRestoring) {
|
||||
window.gBrowser.selectedTab = tabs[initialIndex] ?? tabs[0];
|
||||
}
|
||||
|
||||
// Add tabs to the split view group
|
||||
let splitGroup = this._getSplitViewGroup(tabs);
|
||||
if (splitGroup) {
|
||||
for (const tab of tabs) {
|
||||
if (!tab.group || tab.group !== splitGroup) {
|
||||
gBrowser.moveTabToGroup(tab, splitGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this._sessionRestoring) {
|
||||
return;
|
||||
}
|
||||
this.activateSplitView(group, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// We are here if none of the tabs have been previously split
|
||||
// If there's ANY pinned tab on the list, we clone the pinned tab
|
||||
// state to all the tabs
|
||||
const allArePinned = tabs.every((tab) => tab.pinned);
|
||||
const thereIsOnePinned = tabs.some((tab) => tab.pinned);
|
||||
const thereIsOneEssential = tabs.some((tab) => tab.hasAttribute('zen-essential'));
|
||||
|
||||
if (thereIsOneEssential || (thereIsOnePinned && !allArePinned)) {
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
const tab = tabs[i];
|
||||
if (tab.pinned) {
|
||||
tabs[i] = gBrowser.duplicateTab(tab, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gridType ??= 'grid';
|
||||
|
||||
const splitData = {
|
||||
tabs,
|
||||
gridType,
|
||||
layoutTree: this.calculateLayoutTree(tabs, gridType),
|
||||
};
|
||||
this._data.push(splitData);
|
||||
if (!this._sessionRestoring) {
|
||||
window.gBrowser.selectedTab = tabs[initialIndex] ?? tabs[0];
|
||||
}
|
||||
|
||||
// Add tabs to the split view group
|
||||
let splitGroup = this._getSplitViewGroup(tabs);
|
||||
if (splitGroup) {
|
||||
for (const tab of tabs) {
|
||||
if (!tab.group || tab.group !== splitGroup) {
|
||||
gBrowser.moveTabToGroup(tab, splitGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this._sessionRestoring) {
|
||||
return;
|
||||
}
|
||||
this.activateSplitView(splitData);
|
||||
this.activateSplitView(splitData);
|
||||
});
|
||||
}
|
||||
|
||||
addTabToSplit(tab, splitNode, prepend = true) {
|
||||
@@ -1929,6 +1931,17 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
||||
return true;
|
||||
}
|
||||
|
||||
#withoutSplitViewTransition(callback) {
|
||||
this.tabBrowserPanel.classList.add('zen-split-view-no-transition');
|
||||
try {
|
||||
callback();
|
||||
} finally {
|
||||
requestAnimationFrame(() => {
|
||||
this.tabBrowserPanel.classList.remove('zen-split-view-no-transition');
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
createEmptySplit() {
|
||||
const selectedTab = gBrowser.selectedTab;
|
||||
const emptyTab = gZenWorkspaces._emptyTab;
|
||||
@@ -1975,6 +1988,13 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
|
||||
gZenUIManager.handleNewTab(false, false, 'tab', true);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
get splitViewBrowsers() {
|
||||
if (this.currentView < 0) {
|
||||
return [];
|
||||
}
|
||||
return this._data[this.currentView].tabs.map((tab) => tab.linkedBrowser);
|
||||
}
|
||||
}
|
||||
|
||||
window.gZenViewSplitter = new nsZenViewSplitter();
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
#tabbrowser-tabpanels[zen-split-view='true']:not([zen-split-resizing]) > [zen-split='true'] {
|
||||
#tabbrowser-tabpanels[zen-split-view='true']:not(.zen-split-view-no-transition):not([zen-split-resizing]) > [zen-split='true'] {
|
||||
transition: inset 0.09s ease-out !important;
|
||||
& browser {
|
||||
transition: opacity 0.2s ease-out !important;
|
||||
|
||||
Reference in New Issue
Block a user