fix: Fixed closing and reopening zen turning tabs into blank states when having multiple windows, b=bug #11831, c=split-view

This commit is contained in:
mr. m
2026-01-08 20:48:38 +01:00
parent 7e7d860c9e
commit f39faf6638
3 changed files with 26 additions and 16 deletions

View File

@@ -4,4 +4,10 @@
#include zen-commands.inc.xhtml
<keyset id="zenKeyset"></keyset>
<keyset id="zenKeyset">
# Prefetch these keys because they are being used by the native menu bar
# and they need to be available even before the XUL is fully loaded and
# our KBS sysmtem is initialized.
<key id="zen-workspace-forward" />
<key id="zen-workspace-backward" />
</keyset>

View File

@@ -599,19 +599,6 @@ class nsZenWindowSync {
if (aOurTab.linkedBrowser.isRemoteBrowser != aOtherTab.linkedBrowser.isRemoteBrowser) {
return false;
}
// Load about:blank if by any chance we loaded the previous tab's URL.
// TODO: We should maybe start using a singular about:blank preloaded view
// to avoid loading a full blank page each time and wasting resources.
// We do need to do this though instead of just unloading the browser because
// firefox doesn't expect an unloaded + selected tab, so we need to get
// around this limitation somehow.
if (!onClose && aOurTab.linkedBrowser?.currentURI.spec !== 'about:blank') {
this.log(`Loading about:blank in our tab ${aOurTab.id} before swap`);
aOurTab.linkedBrowser.loadURI(Services.io.newURI('about:blank'), {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
});
}
// Running `swapBrowsersAndCloseOther` doesn't expect us to use the tab after
// the operation, so it doesn't really care about cleaning up the other tab.
// We need to make a new tab progress listener for the other tab after the swap.
@@ -623,7 +610,7 @@ class nsZenWindowSync {
// Sometimes, when closing a window for example, when we swap the browsers,
// there's a chance that the tab does not have the entries state moved over properly.
// To avoid losing history entries, we have to keep the permanentKey in sync.
this.#makeSureTabSyncsPermanentKey(aOtherTab);
this.#makeSureTabSyncsPermanentKey(aOurTab);
// Since we are moving progress listeners around, there's a chance that we
// trigger a load while making the switch, and since we remove the previous
// tab's listeners, the other browser window will never get the 'finish load' event
@@ -633,6 +620,19 @@ class nsZenWindowSync {
if (!aOtherTab.hasAttribute('busy')) {
aOurTab.removeAttribute('busy');
}
// Load about:blank if by any chance we loaded the previous tab's URL.
// TODO: We should maybe start using a singular about:blank preloaded view
// to avoid loading a full blank page each time and wasting resources.
// We do need to do this though instead of just unloading the browser because
// firefox doesn't expect an unloaded + selected tab, so we need to get
// around this limitation somehow.
if (!onClose && aOtherTab.linkedBrowser?.currentURI.spec !== 'about:blank') {
this.log(`Loading about:blank in our tab ${aOtherTab.id} before swap`);
aOtherTab.linkedBrowser.loadURI(Services.io.newURI('about:blank'), {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
loadFlags: Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY,
});
}
},
onClose
);

View File

@@ -256,7 +256,11 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature {
// tab copy or move
draggedTab = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
// not our drop then
if (!gBrowser.isTab(draggedTab) || gBrowser.selectedTab.hasAttribute('zen-empty-tab')) {
if (
!gBrowser.isTab(draggedTab) ||
gBrowser.selectedTab.hasAttribute('zen-empty-tab') ||
draggedTab.ownerGlobal !== window
) {
return;
}
gBrowser.tabContainer.tabDragAndDrop.finishMoveTogetherSelectedTabs(draggedTab);