gh-15489: Fixed closing a window not swiping browser views (gh-15490)

This commit is contained in:
mr. m
2026-09-20 11:55:02 +02:00
committed by GitHub
parent 450aeeccd3
commit 7debd15013
2 changed files with 109 additions and 97 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/Tabbrowser.sys.mjs b/browser/components/tabbrowser/Tabbrowser.sys.mjs
index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a4aadcff3 100644
index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..a9a5dfbc38348f2c070f22af2954a089db94a6d3 100644
--- a/browser/components/tabbrowser/Tabbrowser.sys.mjs
+++ b/browser/components/tabbrowser/Tabbrowser.sys.mjs
@@ -484,6 +484,7 @@ export class Tabbrowser {
@@ -10,7 +10,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
const browsers = [];
if (this.#activeSplitView) {
for (const tab of this.#activeSplitView.tabs) {
@@ -582,15 +583,74 @@ export class Tabbrowser {
@@ -582,15 +583,86 @@ export class Tabbrowser {
return this.tabContainer.visibleTabs;
}
@@ -20,6 +20,18 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
+
+ get zenTabProgressListener() { return TabProgressListener; }
+
+ zenGetTabProgressFilter(tab) {
+ return this.#tabFilters.get(tab);
+ }
+
+ zenGetTabProgressListener(tab) {
+ return this.#tabListeners.get(tab);
+ }
+
+ zenSetTabProgressListener(tab, listener) {
+ this.#tabListeners.set(tab, listener);
+ }
+
+ get TabStateFlusher() {
+ return lazy.TabStateFlusher;
+ }
@@ -87,7 +99,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
setSelectedTab(val, metricsContext = null) {
if (this.selectedTab === val) {
return;
@@ -603,6 +663,9 @@ export class Tabbrowser {
@@ -603,6 +675,9 @@ export class Tabbrowser {
) {
return;
}
@@ -97,7 +109,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// Update the tab
this.tabbox.selectedTab = val;
@@ -688,6 +751,10 @@ export class Tabbrowser {
@@ -688,6 +763,10 @@ export class Tabbrowser {
userContextId = parseInt(tabArgument.getAttribute("usercontextid"), 10);
}
@@ -108,7 +120,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (openWindowInfo) {
userContextId = openWindowInfo.originAttributes.userContextId;
}
@@ -786,6 +853,8 @@ export class Tabbrowser {
@@ -786,6 +865,8 @@ export class Tabbrowser {
this.tabpanels.appendChild(panel);
let tab = this.tabs[0];
@@ -117,7 +129,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
tab.linkedPanel = uniqueId;
this.#selectedTab = tab;
this.#selectedBrowser = browser;
@@ -1234,18 +1303,24 @@ export class Tabbrowser {
@@ -1234,18 +1315,24 @@ export class Tabbrowser {
* The context for the operation for telemetry purposes, defaults to an unknown context.
*/
pinTab(aTab, { metricsContext = this.TabMetrics.UNKNOWN_CONTEXT } = {}) {
@@ -143,7 +155,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
aTab.setAttribute("pinned", "true");
this.#updateTabBarForPinnedTabs();
@@ -1262,16 +1337,25 @@ export class Tabbrowser {
@@ -1262,16 +1349,25 @@ export class Tabbrowser {
* The context for the operation for telemetry purposes, defaults to an unknown context.
*/
unpinTab(aTab, { metricsContext = this.TabMetrics.UNKNOWN_CONTEXT } = {}) {
@@ -170,7 +182,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
});
aTab.style.marginInlineStart = "";
@@ -1494,6 +1578,9 @@ export class Tabbrowser {
@@ -1494,6 +1590,9 @@ export class Tabbrowser {
let LOCAL_PROTOCOLS = ["chrome:", "about:", "resource:", "data:"];
@@ -180,7 +192,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (
aIconURL &&
!LOCAL_PROTOCOLS.some(protocol => aIconURL.startsWith(protocol))
@@ -1503,6 +1590,9 @@ export class Tabbrowser {
@@ -1503,6 +1602,9 @@ export class Tabbrowser {
);
return;
}
@@ -190,7 +202,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
let browser = this.getBrowserForTab(aTab);
browser.mIconURL = aIconURL;
@@ -1831,7 +1921,6 @@ export class Tabbrowser {
@@ -1831,7 +1933,6 @@ export class Tabbrowser {
// Preview mode should not reset the owner
if (!this.#previewMode && !oldTab.selected) {
@@ -198,7 +210,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
let lastRelatedTab = this.#lastRelatedTabMap.get(oldTab);
@@ -1922,6 +2011,7 @@ export class Tabbrowser {
@@ -1922,6 +2023,7 @@ export class Tabbrowser {
if (!this.#previewMode) {
newTab.recordTimeFromUnloadToReload();
newTab.updateLastAccessed();
@@ -206,7 +218,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
oldTab.updateLastAccessed();
// if this is the foreground window, update the last-seen timestamps.
if (this.documentGlobal == lazy.BrowserWindowTracker.getTopWindow()) {
@@ -2136,6 +2226,9 @@ export class Tabbrowser {
@@ -2136,6 +2238,9 @@ export class Tabbrowser {
}
let activeEl = this.document.activeElement;
@@ -216,7 +228,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// If focus is on the old tab, move it to the new tab.
if (activeEl == oldTab) {
newTab.focus();
@@ -2174,7 +2267,7 @@ export class Tabbrowser {
@@ -2174,7 +2279,7 @@ export class Tabbrowser {
// Focus the location bar if it was previously focused for that tab.
// In full screen mode, only bother making the location bar visible
// if the tab is a blank one.
@@ -225,7 +237,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
let selectURL = () => {
if (this.#asyncTabSwitching) {
// Set _awaitingSetURI flag to suppress popup notification
@@ -2478,6 +2571,10 @@ export class Tabbrowser {
@@ -2478,6 +2583,10 @@ export class Tabbrowser {
return this.#setTabLabel(aTab, aLabel);
}
@@ -236,7 +248,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
/**
* Sets a tab's label, shortened and clamped for display.
*
@@ -2498,7 +2595,12 @@ export class Tabbrowser {
@@ -2498,7 +2607,12 @@ export class Tabbrowser {
* @returns {boolean}
* Whether the label changed.
*/
@@ -250,7 +262,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (!aLabel || (isURL && /^about:reader\?url=/.test(aLabel))) {
return false;
}
@@ -2657,7 +2759,7 @@ export class Tabbrowser {
@@ -2657,7 +2771,7 @@ export class Tabbrowser {
newIndex = this.selectedTab.index + 1;
}
@@ -259,7 +271,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (this.isTabGroupLabel(targetTab)) {
throw new Error(
"Replacing a tab group label with a tab is not supported"
@@ -2971,6 +3073,7 @@ export class Tabbrowser {
@@ -2971,6 +3085,7 @@ export class Tabbrowser {
uriIsAboutBlank,
userContextId,
skipLoad,
@@ -267,7 +279,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
} = {}) {
let b = this.document.createXULElement("browser");
// Use the JSM global to create the permanentKey, so that if the
@@ -3045,10 +3148,7 @@ export class Tabbrowser {
@@ -3045,10 +3160,7 @@ export class Tabbrowser {
b.setAttribute("name", name);
}
@@ -279,7 +291,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
b.setAttribute("transparent", "true");
}
@@ -3212,7 +3312,7 @@ export class Tabbrowser {
@@ -3212,7 +3324,7 @@ export class Tabbrowser {
let panel = this.getPanel(browser);
let uniqueId = this.#generateUniquePanelID();
@@ -288,7 +300,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
aTab.linkedPanel = uniqueId;
// Inject the <browser> into the DOM if necessary.
@@ -3269,8 +3369,8 @@ export class Tabbrowser {
@@ -3269,8 +3381,8 @@ export class Tabbrowser {
// 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) {
@@ -299,7 +311,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
} else {
aTab.linkedBrowser.browsingContext.hasSiblings = this.tabs.length > 1;
}
@@ -3458,7 +3558,6 @@ export class Tabbrowser {
@@ -3458,7 +3570,6 @@ export class Tabbrowser {
{
tabIndex: tab.index + 1,
userContextId: tab.userContextId,
@@ -307,7 +319,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
focusUrlBar: true,
}
);
@@ -3667,6 +3766,10 @@ export class Tabbrowser {
@@ -3667,6 +3778,10 @@ export class Tabbrowser {
schemelessInput,
hasValidUserGestureActivation = false,
textDirectiveUserActivation = false,
@@ -318,7 +330,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
} = {}
) {
// all callers of addTab that pass a params object need to pass
@@ -3677,6 +3780,23 @@ export class Tabbrowser {
@@ -3677,6 +3792,23 @@ export class Tabbrowser {
);
}
@@ -342,7 +354,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (!UserInteraction.running("browser.tabs.opening", this.documentGlobal)) {
UserInteraction.start(
"browser.tabs.opening",
@@ -3685,6 +3805,7 @@ export class Tabbrowser {
@@ -3685,6 +3817,7 @@ export class Tabbrowser {
);
}
@@ -350,7 +362,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// If we're opening a foreground tab, set the owner by default.
ownerTab ??= inBackground ? null : this.selectedTab;
@@ -3692,6 +3813,7 @@ export class Tabbrowser {
@@ -3692,6 +3825,7 @@ export class Tabbrowser {
if (this.selectedTab.owner) {
this.selectedTab.owner = null;
}
@@ -358,7 +370,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// Find the tab that opened this one, if any. This is used for
// determining positioning, and inherited attributes such as the
@@ -3744,6 +3866,22 @@ export class Tabbrowser {
@@ -3744,6 +3878,22 @@ export class Tabbrowser {
noInitialLabel,
skipBackgroundNotify,
});
@@ -381,7 +393,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (insertTab) {
// Insert the tab into the tab container in the correct position.
this.#insertTabAtIndex(t, {
@@ -3752,6 +3890,7 @@ export class Tabbrowser {
@@ -3752,6 +3902,7 @@ export class Tabbrowser {
ownerTab,
openerTab,
pinned,
@@ -389,7 +401,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
bulkOrderedOpen,
tabGroup: tabGroup ?? openerTab?.group,
});
@@ -3770,6 +3909,7 @@ export class Tabbrowser {
@@ -3770,6 +3921,7 @@ export class Tabbrowser {
openWindowInfo,
skipLoad,
triggeringRemoteType,
@@ -397,7 +409,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}));
if (focusUrlBar) {
@@ -3894,6 +4034,12 @@ export class Tabbrowser {
@@ -3894,6 +4046,12 @@ export class Tabbrowser {
}
}
@@ -410,7 +422,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// Additionally send pinned tab events
if (pinned) {
this.#notifyPinnedStatus(t);
@@ -3904,6 +4050,15 @@ export class Tabbrowser {
@@ -3904,6 +4062,15 @@ export class Tabbrowser {
if (!inBackground) {
this.selectedTab = t;
}
@@ -426,7 +438,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
return t;
}
@@ -4125,6 +4280,7 @@ export class Tabbrowser {
@@ -4125,6 +4292,7 @@ export class Tabbrowser {
insertBefore = null,
isAdoptingGroup = false,
metricsContext = this.TabMetrics.UNKNOWN_CONTEXT,
@@ -434,7 +446,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
} = {}
) {
if (
@@ -4135,7 +4291,6 @@ export class Tabbrowser {
@@ -4135,7 +4303,6 @@ export class Tabbrowser {
!this.isSplitViewWrapper(tabOrSplitView)
)
) {
@@ -442,7 +454,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
if (!color) {
@@ -4150,7 +4305,15 @@ export class Tabbrowser {
@@ -4150,7 +4317,15 @@ export class Tabbrowser {
id = `${Date.now()}-${Math.round(Math.random() * 100)}`;
}
let group = this.#createTabGroup(id, color, false, label, isAdoptingGroup);
@@ -459,7 +471,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
group.addTabs(tabsAndSplitViews, metricsContext);
// Bail out if the group is empty at this point. This can happen if all
@@ -4253,7 +4416,7 @@ export class Tabbrowser {
@@ -4253,7 +4428,7 @@ export class Tabbrowser {
}
this.#handleTabMove(tab, () =>
@@ -468,7 +480,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
);
}
@@ -4337,6 +4500,7 @@ export class Tabbrowser {
@@ -4337,6 +4512,7 @@ export class Tabbrowser {
color: group.color,
insertBefore: newTabs[0],
isAdoptingGroup: true,
@@ -476,7 +488,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
});
}
@@ -4597,6 +4761,7 @@ export class Tabbrowser {
@@ -4597,6 +4773,7 @@ export class Tabbrowser {
openWindowInfo,
skipLoad,
triggeringRemoteType,
@@ -484,7 +496,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
) {
// If we don't have a preferred remote type (or it is `NOT_REMOTE`), and
@@ -4660,6 +4825,7 @@ export class Tabbrowser {
@@ -4660,6 +4837,7 @@ export class Tabbrowser {
openWindowInfo,
name,
skipLoad,
@@ -492,7 +504,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
});
}
@@ -4943,8 +5109,9 @@ export class Tabbrowser {
@@ -4943,8 +5121,9 @@ export class Tabbrowser {
}
// Add a new tab if needed.
@@ -504,7 +516,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
let url = "about:blank";
if (tabData.entries?.length) {
@@ -4977,8 +5144,10 @@ export class Tabbrowser {
@@ -4977,8 +5156,10 @@ export class Tabbrowser {
insertTab: false,
skipLoad: true,
preferredRemoteType,
@@ -516,7 +528,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (select) {
tabToSelect = tab;
}
@@ -5000,7 +5169,8 @@ export class Tabbrowser {
@@ -5000,7 +5181,8 @@ export class Tabbrowser {
this.pinTab(tab);
// Then ensure all the tab open/pinning information is sent.
this.#fireTabOpen(tab, {});
@@ -526,7 +538,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
let { groupId } = tabData;
const tabGroup = tabGroupWorkingData.get(groupId);
// if a tab refers to a tab group we don't know, skip any group
@@ -5020,7 +5190,10 @@ export class Tabbrowser {
@@ -5020,7 +5202,10 @@ export class Tabbrowser {
tabGroup.stateData.id,
tabGroup.stateData.color,
tabGroup.stateData.collapsed,
@@ -538,7 +550,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
);
tabsFragment.appendChild(tabGroup.node);
}
@@ -5080,9 +5253,18 @@ export class Tabbrowser {
@@ -5080,9 +5265,18 @@ export class Tabbrowser {
// to remove the old selected tab.
if (tabToSelect) {
let leftoverTab = this.selectedTab;
@@ -557,7 +569,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (tabs.length > 1 || !tabs[0].selected) {
this.#updateTabsAfterInsert();
@@ -5313,11 +5495,17 @@ export class Tabbrowser {
@@ -5313,11 +5507,17 @@ export class Tabbrowser {
if (ownerTab) {
tab.owner = ownerTab;
}
@@ -576,7 +588,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
let insertRelatedAfterCurrent = Services.prefs.getBoolPref(
"browser.tabs.insertRelatedAfterCurrent"
);
@@ -5332,7 +5520,7 @@ export class Tabbrowser {
@@ -5332,7 +5532,7 @@ export class Tabbrowser {
(insertRelatedAfterCurrent && lastRelatedTab) ||
openerTab ||
this.selectedTab;
@@ -585,7 +597,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
tabGroup = previousTab.group;
}
if (
@@ -5348,7 +5536,7 @@ export class Tabbrowser {
@@ -5348,7 +5548,7 @@ export class Tabbrowser {
previousTab.splitview
) + 1;
} else if (previousTab.visible) {
@@ -594,7 +606,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
} else if (previousTab == this.documentGlobal.FirefoxViewHandler.tab) {
elementIndex = 0;
}
@@ -5376,14 +5564,14 @@ export class Tabbrowser {
@@ -5376,14 +5576,14 @@ export class Tabbrowser {
}
// Ensure index is within bounds.
if (tab.pinned) {
@@ -613,7 +625,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (pinned && !itemAfter?.pinned) {
itemAfter = null;
@@ -5400,7 +5588,7 @@ export class Tabbrowser {
@@ -5400,7 +5600,7 @@ export class Tabbrowser {
this.tabContainer._invalidateCachedTabs();
@@ -622,7 +634,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (
(this.isTab(itemAfter) && itemAfter.group == tabGroup) ||
this.isSplitViewWrapper(itemAfter)
@@ -5431,7 +5619,11 @@ export class Tabbrowser {
@@ -5431,7 +5631,11 @@ export class Tabbrowser {
const tabContainer = pinned
? this.tabContainer.pinnedTabsContainer
: this.tabContainer;
@@ -634,7 +646,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
if (tab.group?.collapsed) {
@@ -5446,6 +5638,7 @@ export class Tabbrowser {
@@ -5446,6 +5650,7 @@ export class Tabbrowser {
if (pinned) {
this.#updateTabBarForPinnedTabs();
}
@@ -642,7 +654,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
this.documentGlobal.TabBarVisibility.update();
}
@@ -6025,6 +6218,7 @@ export class Tabbrowser {
@@ -6025,6 +6230,7 @@ export class Tabbrowser {
metricsContext,
} = {}
) {
@@ -650,7 +662,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
// can be considered equivalent to closing the window.
if (
@@ -6135,6 +6329,7 @@ export class Tabbrowser {
@@ -6135,6 +6341,7 @@ export class Tabbrowser {
closedTabCount -= 1;
}
}
@@ -658,7 +670,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (closedTabCount > 0) {
this.recordTabMetrics(
@@ -6236,6 +6431,14 @@ export class Tabbrowser {
@@ -6236,6 +6443,14 @@ export class Tabbrowser {
return;
}
@@ -673,7 +685,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
let isVisibleTab = aTab.visible;
// We have to sample the tab width now, since #beginRemoveTab might
// end up modifying the DOM in such a way that aTab gets a new
@@ -6244,6 +6447,9 @@ export class Tabbrowser {
@@ -6244,6 +6459,9 @@ export class Tabbrowser {
let tabWidth =
this.documentGlobal.windowUtils.getBoundsWithoutFlushing(aTab).width;
let isLastTab = this.#isLastTabInWindow(aTab);
@@ -683,7 +695,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (
!this.#beginRemoveTab(aTab, {
closeWindowFastpath: true,
@@ -6254,13 +6460,14 @@ export class Tabbrowser {
@@ -6254,13 +6472,14 @@ export class Tabbrowser {
metricsContext,
})
) {
@@ -699,7 +711,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
let lockTabSizing =
!this.tabContainer.verticalMode &&
!aTab.pinned &&
@@ -6291,7 +6498,13 @@ export class Tabbrowser {
@@ -6291,7 +6510,13 @@ export class Tabbrowser {
// We're not animating, so we can cancel the animation stopwatch.
Glean.browserTabclose.timeAnim.cancel(aTab._closeTimeAnimTimerId);
aTab._closeTimeAnimTimerId = null;
@@ -714,7 +726,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
return;
}
@@ -6331,7 +6544,9 @@ export class Tabbrowser {
@@ -6331,7 +6556,9 @@ export class Tabbrowser {
get #shouldCloseWindowWithLastTab() {
return (
!this.documentGlobal.toolbar.visible ||
@@ -725,7 +737,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
);
}
@@ -6347,7 +6562,7 @@ export class Tabbrowser {
@@ -6347,7 +6574,7 @@ export class Tabbrowser {
*/
#isLastTabInWindow(tab) {
for (const otherTab of this.tabs) {
@@ -734,7 +746,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
return false;
}
}
@@ -6488,6 +6703,7 @@ export class Tabbrowser {
@@ -6488,6 +6715,7 @@ export class Tabbrowser {
newTab = true;
}
@@ -742,7 +754,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
aTab._endRemoveArgs = [closeWindow, newTab];
// swapBrowsersAndCloseOther will take care of closing the window without animation.
@@ -6542,13 +6758,7 @@ export class Tabbrowser {
@@ -6542,13 +6770,7 @@ export class Tabbrowser {
}
if (newTab) {
@@ -757,7 +769,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
} else {
this.documentGlobal.TabBarVisibility.update();
}
@@ -6701,6 +6911,7 @@ export class Tabbrowser {
@@ -6701,6 +6923,7 @@ export class Tabbrowser {
this.tabs[i]._index = i;
}
@@ -765,7 +777,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (!this.#windowIsClosing) {
// update tab close buttons state
this.tabContainer._updateCloseButtons();
@@ -6891,6 +7102,7 @@ export class Tabbrowser {
@@ -6891,6 +7114,7 @@ export class Tabbrowser {
memory_after: await getTotalMemoryUsage(),
time_to_unload_in_ms: timeElapsed,
});
@@ -773,7 +785,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
/**
@@ -6937,11 +7149,12 @@ export class Tabbrowser {
@@ -6937,11 +7161,12 @@ export class Tabbrowser {
}
let excludeTabs = new Set(aExcludeTabs);
@@ -787,7 +799,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
if (
@@ -6949,13 +7162,13 @@ export class Tabbrowser {
@@ -6949,13 +7174,13 @@ export class Tabbrowser {
!excludeTabs.has(aTab.owner) &&
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")
) {
@@ -803,7 +815,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
);
if (Services.prefs.getBoolPref("browser.tabs.selectMRUOnClose", false)) {
@@ -6970,6 +7183,13 @@ export class Tabbrowser {
@@ -6970,6 +7195,13 @@ export class Tabbrowser {
}
}
@@ -817,7 +829,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
let tab = this.tabContainer.findNextTab(aTab, {
direction: 1,
filter: _tab => remainingTabs.includes(_tab),
@@ -6983,7 +7203,7 @@ export class Tabbrowser {
@@ -6983,7 +7215,7 @@ export class Tabbrowser {
}
if (tab) {
@@ -826,7 +838,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
// If no qualifying visible tab was found, see if there is a tab in
@@ -7004,7 +7224,7 @@ export class Tabbrowser {
@@ -7004,7 +7236,7 @@ export class Tabbrowser {
});
}
@@ -835,7 +847,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
#blurTab(aTab) {
@@ -7021,7 +7241,7 @@ export class Tabbrowser {
@@ -7021,7 +7253,7 @@ export class Tabbrowser {
* @returns {boolean}
* False if swapping isn't permitted, true otherwise.
*/
@@ -844,7 +856,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// Do not allow transfering a private tab to a non-private window
// and vice versa.
if (
@@ -7080,6 +7300,7 @@ export class Tabbrowser {
@@ -7080,6 +7312,7 @@ export class Tabbrowser {
// fire the beforeunload event in the process. Close the other
// window if this was its last tab.
if (
@@ -852,7 +864,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
!remoteBrowser.#beginRemoveTab(aOtherTab, {
adoptedByTab: aOurTab,
closeWindowWithLastTab: true,
@@ -7091,7 +7312,7 @@ export class Tabbrowser {
@@ -7091,7 +7324,7 @@ export class Tabbrowser {
// If this is the last tab of the window, hide the window
// immediately without animation before the docshell swap, to avoid
// about:blank being painted.
@@ -861,7 +873,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (closeWindow) {
let win = aOtherTab.documentGlobal;
win.windowUtils.suppressAnimation(true);
@@ -7231,11 +7452,13 @@ export class Tabbrowser {
@@ -7231,11 +7464,13 @@ export class Tabbrowser {
}
// Finish tearing down the tab that's going away.
@@ -875,7 +887,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
this.setTabTitle(aOurTab);
@@ -7484,10 +7707,10 @@ export class Tabbrowser {
@@ -7484,10 +7719,10 @@ export class Tabbrowser {
}
}
@@ -888,7 +900,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
aTab.selected ||
aTab.closing ||
// Tabs that are sharing the screen, microphone or camera cannot be hidden.
@@ -7576,7 +7799,8 @@ export class Tabbrowser {
@@ -7576,7 +7811,8 @@ export class Tabbrowser {
* @param {object} [aOptions={}]
* Key-value pairs that will be serialized into the features string.
*/
@@ -898,7 +910,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (this.tabs.length == 1) {
return null;
}
@@ -7593,7 +7817,7 @@ export class Tabbrowser {
@@ -7593,7 +7829,7 @@ export class Tabbrowser {
// tell a new window to take the "dropped" tab
let args = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
args.appendElement(aTab.splitview ?? aTab);
@@ -907,7 +919,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
private: lazy.PrivateBrowsingUtils.isWindowPrivate(this.documentGlobal),
features: Object.entries(aOptions)
.map(([key, value]) => `${key}=${value}`)
@@ -7601,6 +7825,8 @@ export class Tabbrowser {
@@ -7601,6 +7837,8 @@ export class Tabbrowser {
openerWindow: this.documentGlobal,
args,
});
@@ -916,7 +928,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
/**
@@ -7734,7 +7960,7 @@ export class Tabbrowser {
@@ -7734,7 +7972,7 @@ export class Tabbrowser {
* @returns {element is MozTabbrowserTabGroup}
*/
isTabGroup(element) {
@@ -925,7 +937,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
/**
@@ -7807,8 +8033,8 @@ export class Tabbrowser {
@@ -7807,8 +8045,8 @@ export class Tabbrowser {
}
// Don't allow mixing pinned and unpinned tabs.
@@ -936,7 +948,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
} else {
tabIndex = Math.max(tabIndex, this.pinnedTabCount);
}
@@ -7854,8 +8080,8 @@ export class Tabbrowser {
@@ -7854,8 +8092,8 @@ export class Tabbrowser {
this.#handleTabMove(
element,
() => {
@@ -947,7 +959,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
neighbor = neighbor.group;
}
if (neighbor?.splitview) {
@@ -7866,6 +8092,12 @@ export class Tabbrowser {
@@ -7866,6 +8104,12 @@ export class Tabbrowser {
return;
}
}
@@ -960,7 +972,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
if (movingForwards && neighbor) {
neighbor.after(element);
@@ -7939,23 +8171,31 @@ export class Tabbrowser {
@@ -7939,23 +8183,31 @@ export class Tabbrowser {
) {
if (this.isTabGroupLabel(targetElement)) {
targetElement = targetElement.group;
@@ -998,7 +1010,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
} 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
@@ -7968,12 +8208,35 @@ export class Tabbrowser {
@@ -7968,12 +8220,35 @@ export class Tabbrowser {
// 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.
@@ -1035,7 +1047,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// We want to include the splitview wrapper if it's the targetElement, but
// not in the case where we want to reverse tabs within the same splitview.
@@ -7982,6 +8245,7 @@ export class Tabbrowser {
@@ -7982,6 +8257,7 @@ export class Tabbrowser {
}
let getContainer = () =>
@@ -1043,7 +1055,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
element.pinned
? this.tabContainer.pinnedTabsContainer
: this.tabContainer;
@@ -7990,11 +8254,15 @@ export class Tabbrowser {
@@ -7990,11 +8266,15 @@ export class Tabbrowser {
element,
() => {
if (moveBefore) {
@@ -1060,7 +1072,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
},
{ metricsContext }
@@ -8070,11 +8338,15 @@ export class Tabbrowser {
@@ -8070,11 +8350,15 @@ export class Tabbrowser {
* The context for the operation for telemetry purposes.
*/
moveTabToExistingGroup(aTab, aGroup, { metricsContext } = {}) {
@@ -1079,7 +1091,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
}
if (aTab.group && aTab.group.id === aGroup.id) {
return;
@@ -8153,6 +8425,7 @@ export class Tabbrowser {
@@ -8153,6 +8437,7 @@ export class Tabbrowser {
let state = {
tabIndex: tab.index,
@@ -1087,7 +1099,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
};
if (tab.visible) {
state.elementIndex = tab.elementIndex;
@@ -8190,7 +8463,7 @@ export class Tabbrowser {
@@ -8190,7 +8475,7 @@ export class Tabbrowser {
let changedSplitView =
previousTabState.splitViewId != currentTabState.splitViewId;
@@ -1096,7 +1108,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
tab.dispatchEvent(
new this.documentGlobal.CustomEvent("TabMove", {
bubbles: true,
@@ -8248,6 +8521,10 @@ export class Tabbrowser {
@@ -8248,6 +8533,10 @@ export class Tabbrowser {
moveActionCallback();
@@ -1107,7 +1119,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// Clear tabs cache after moving nodes because the order of tabs may have
// changed.
this.tabContainer._invalidateCachedTabs();
@@ -8307,7 +8584,22 @@ export class Tabbrowser {
@@ -8307,7 +8596,22 @@ export class Tabbrowser {
* @returns {object}
* The new tab in the current window, null if the tab couldn't be adopted.
*/
@@ -1131,7 +1143,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
// Swap the dropped tab with a new one we create and then close
// it in the other window (making it seem to have moved between
// windows). We also ensure that the tab we create to swap into has
@@ -8350,6 +8642,8 @@ export class Tabbrowser {
@@ -8350,6 +8654,8 @@ export class Tabbrowser {
}
params.skipLoad = true;
let newTab = this.addWebTab("about:blank", params);
@@ -1140,7 +1152,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
aTab.container.tabDragAndDrop.finishAnimateTabMove();
@@ -9189,7 +9483,7 @@ export class Tabbrowser {
@@ -9189,7 +9495,7 @@ export class Tabbrowser {
// preventDefault(). It will still raise the window if appropriate.
return;
}
@@ -1149,7 +1161,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
this.documentGlobal.focus();
aEvent.preventDefault();
}
@@ -9206,7 +9500,6 @@ export class Tabbrowser {
@@ -9206,7 +9512,6 @@ export class Tabbrowser {
on_TabGroupCollapse(aEvent) {
aEvent.target.tabs.forEach(tab => {
@@ -1157,7 +1169,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
});
}
@@ -9554,7 +9847,9 @@ export class Tabbrowser {
@@ -9554,7 +9859,9 @@ export class Tabbrowser {
let filter = this.#tabFilters.get(tab);
if (filter) {
@@ -1167,7 +1179,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
let listener = this.#tabListeners.get(tab);
if (listener) {
@@ -10354,6 +10649,7 @@ class TabProgressListener {
@@ -10354,6 +10661,7 @@ class TabProgressListener {
aWebProgress.isTopLevel
) {
this._tab.setAttribute("busy", "true");
@@ -1175,7 +1187,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
this.#tabbrowser._tabAttrModified(this._tab, ["busy"]);
this._tab._notselectedsinceload = !this._tab.selected;
}
@@ -10434,6 +10730,7 @@ class TabProgressListener {
@@ -10434,6 +10742,7 @@ class TabProgressListener {
// known defaults. Note we use the original URL since about:newtab
// redirects to a prerendered page.
const shouldRemoveFavicon =
@@ -1183,7 +1195,7 @@ index f68e37926001384d0c8e80a3c163dc89e9c4ee5c..5cfd47aa16ed47e90bf75c81070bbc6a
!this._browser.mIconURL &&
!ignoreBlank &&
!(originalLocation.spec in FAVICON_DEFAULTS);
@@ -10610,13 +10907,6 @@ class TabProgressListener {
@@ -10610,13 +10919,6 @@ class TabProgressListener {
this._browser.originalURI = aRequest.originalURI;
}

View File

@@ -779,8 +779,8 @@ class nsZenWindowSync {
const otherBrowser = aTab.linkedBrowser;
// We aren't closing the other tab so, we also need to swap its tablisteners.
let filter = otherTabBrowser._getTabProgressFilter(aTab);
let tabListener = otherTabBrowser._getTabProgressListener(aTab);
let filter = otherTabBrowser.zenGetTabProgressFilter(aTab);
let tabListener = otherTabBrowser.zenGetTabProgressListener(aTab);
try {
otherBrowser.webProgress.removeProgressListener(filter);
filter.removeProgressListener(tabListener);
@@ -802,7 +802,7 @@ class nsZenWindowSync {
true,
false
);
otherTabBrowser._setTabProgressListener(aTab, tabListener);
otherTabBrowser.zenSetTabProgressListener(aTab, tabListener);
const notifyAll = Ci.nsIWebProgress.NOTIFY_ALL;
filter.addProgressListener(tabListener, notifyAll);