mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-05 17:36:34 +00:00
Refactor tab management and workspace state handling for improved functionality and consistency
This commit is contained in:
@@ -848,7 +848,7 @@
|
|||||||
height: calc(100% - var(--tab-block-margin) * 2);
|
height: calc(100% - var(--tab-block-margin) * 2);
|
||||||
margin-left: calc(-1 * var(--tab-inline-padding) + var(--tab-block-margin));
|
margin-left: calc(-1 * var(--tab-inline-padding) + var(--tab-block-margin));
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
padding: 0 calc(var(--toolbarbutton-inner-padding) - 4px) 0 calc(var(--toolbarbutton-inner-padding) / 4 + var(--tab-inline-padding) - 2px);
|
padding: 0 calc(var(--toolbarbutton-inner-padding)) 0 calc(var(--toolbarbutton-inner-padding) / 4 + var(--tab-inline-padding));
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
border-top-left-radius: var(--border-radius-medium);
|
border-top-left-radius: var(--border-radius-medium);
|
||||||
width: unset;
|
width: unset;
|
||||||
@@ -868,11 +868,11 @@
|
|||||||
&::after {
|
&::after {
|
||||||
content: '';
|
content: '';
|
||||||
display: block;
|
display: block;
|
||||||
width: 2px;
|
width: 2.5px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
background: light-dark(rgba(88, 79, 79, 0.02), rgba(255, 255, 255, 0.3));
|
background: light-dark(rgba(88, 79, 79, 0.02), rgba(255, 255, 255, 0.3));
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: calc(var(--tab-inline-padding) / 2 - 2px);
|
right: calc(var(--tab-inline-padding) / 2);
|
||||||
top: 50%;
|
top: 50%;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
transform: rotate(12deg) translateY(-50%);
|
transform: rotate(12deg) translateY(-50%);
|
||||||
|
@@ -216,16 +216,6 @@
|
|||||||
gBrowser._setTabLabel(tab, pin.title);
|
gBrowser._setTabLabel(tab, pin.title);
|
||||||
tab.setAttribute('zen-has-static-label', 'true');
|
tab.setAttribute('zen-has-static-label', 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reorder the tab if needed
|
|
||||||
if (tab._tPos !== pin.position) {
|
|
||||||
const parent = tab.parentNode;
|
|
||||||
const isEssential = tab.hasAttribute('zen-essential');
|
|
||||||
// If we arent an essential, we need to take into account
|
|
||||||
// that the last child is a separator
|
|
||||||
const childIndex = isEssential ? pin.position : Math.min(pin.position, parent.children.length - 1);
|
|
||||||
parent.insertBefore(tab, parent.children[childIndex]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Third pass: create new tabs for pins that don't have tabs
|
// Third pass: create new tabs for pins that don't have tabs
|
||||||
@@ -295,7 +285,7 @@
|
|||||||
`#vertical-pinned-tabs-container .zen-workspace-tabs-section[zen-workspace-id="${pin.workspaceUuid}"]`
|
`#vertical-pinned-tabs-container .zen-workspace-tabs-section[zen-workspace-id="${pin.workspaceUuid}"]`
|
||||||
);
|
);
|
||||||
if (container) {
|
if (container) {
|
||||||
container.insertBefore(newTab, container.lastChild);
|
container.prepend(newTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gBrowser.tabContainer._invalidateCachedTabs();
|
gBrowser.tabContainer._invalidateCachedTabs();
|
||||||
|
@@ -1705,7 +1705,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
if (!tabToSelect && gBrowser.visibleTabs.length) {
|
if (!tabToSelect && gBrowser.visibleTabs.length) {
|
||||||
tabToSelect = gBrowser.visibleTabs[gBrowser.visibleTabs.length - 1];
|
tabToSelect = gBrowser.visibleTabs[gBrowser.visibleTabs.length - 1];
|
||||||
}
|
}
|
||||||
if (tabToSelect?.hasAttribute('zen-essential')) {
|
if (tabToSelect?.hasAttribute('zen-essential') || (tabToSelect?.pinned && tabToSelect?.hasAttribute('pending'))) {
|
||||||
// Never select an essential tab
|
// Never select an essential tab
|
||||||
tabToSelect = null;
|
tabToSelect = null;
|
||||||
}
|
}
|
||||||
@@ -1728,9 +1728,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
return tabToSelect;
|
return tabToSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _updateWorkspaceState(window, onInit, tabToSelect) {
|
async _updateWorkspaceState(workspace, onInit, tabToSelect) {
|
||||||
// Update document state
|
// Update document state
|
||||||
document.documentElement.setAttribute('zen-workspace-id', window.uuid);
|
document.documentElement.setAttribute('zen-workspace-id', workspace.uuid);
|
||||||
|
|
||||||
// Recalculate new tab observers
|
// Recalculate new tab observers
|
||||||
gBrowser.tabContainer.observe(null, 'nsPref:changed', 'privacy.userContext.enabled');
|
gBrowser.tabContainer.observe(null, 'nsPref:changed', 'privacy.userContext.enabled');
|
||||||
@@ -1740,17 +1740,17 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
gZenUIManager.updateTabsToolbar();
|
gZenUIManager.updateTabsToolbar();
|
||||||
await this._propagateWorkspaceData({ clearCache: false });
|
await this._propagateWorkspaceData({ clearCache: false });
|
||||||
|
|
||||||
gZenThemePicker.onWorkspaceChange(window);
|
gZenThemePicker.onWorkspaceChange(workspace);
|
||||||
|
|
||||||
document.getElementById('zen-tabs-wrapper').style.scrollbarWidth = 'none';
|
document.getElementById('zen-tabs-wrapper').style.scrollbarWidth = 'none';
|
||||||
await this._animateTabs(window, !onInit && !this._animatingChange, tabToSelect);
|
await this._animateTabs(workspace, !onInit && !this._animatingChange, tabToSelect);
|
||||||
await this._organizeWorkspaceStripLocations(window, true);
|
await this._organizeWorkspaceStripLocations(workspace, true);
|
||||||
document.getElementById('zen-tabs-wrapper').style.scrollbarWidth = '';
|
document.getElementById('zen-tabs-wrapper').style.scrollbarWidth = '';
|
||||||
|
|
||||||
// Notify listeners
|
// Notify listeners
|
||||||
if (this._changeListeners?.length) {
|
if (this._changeListeners?.length) {
|
||||||
for (const listener of this._changeListeners) {
|
for (const listener of this._changeListeners) {
|
||||||
await listener(window, onInit);
|
await listener(workspace, onInit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1758,7 +1758,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
this._invalidateBookmarkContainers();
|
this._invalidateBookmarkContainers();
|
||||||
|
|
||||||
// Update workspace indicator
|
// Update workspace indicator
|
||||||
await this.updateWorkspaceIndicator(window, this.workspaceIndicator);
|
await this.updateWorkspaceIndicator(workspace, this.workspaceIndicator);
|
||||||
|
|
||||||
// Fix ctrl+tab behavior. Note, we dont call it with "await" because we dont want to wait for it
|
// Fix ctrl+tab behavior. Note, we dont call it with "await" because we dont want to wait for it
|
||||||
this._fixCtrlTabBehavior();
|
this._fixCtrlTabBehavior();
|
||||||
@@ -1851,7 +1851,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
// <= 2 because we have the empty tab and the new tab button
|
// <= 2 because we have the empty tab and the new tab button
|
||||||
const shouldHideSeparator =
|
const shouldHideSeparator =
|
||||||
pinnedContainer.children.length === 1 ||
|
pinnedContainer.children.length === 1 ||
|
||||||
Array.from(arrowScrollbox.children).filter((child) => !child.hasAttribute('hidden')).length <= 2;
|
Array.from(arrowScrollbox.children).filter(
|
||||||
|
(child) => !child.hasAttribute('hidden') && !child.hasAttribute('zen-empty-tab')
|
||||||
|
).length <= 1;
|
||||||
if (shouldHideSeparator) {
|
if (shouldHideSeparator) {
|
||||||
pinnedContainer.setAttribute('hide-separator', 'true');
|
pinnedContainer.setAttribute('hide-separator', 'true');
|
||||||
} else {
|
} else {
|
||||||
@@ -2149,10 +2151,6 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
const activeWorkspace = this.getActiveWorkspaceFromCache();
|
const activeWorkspace = this.getActiveWorkspaceFromCache();
|
||||||
const activeWorkspaceUserContextId = activeWorkspace?.containerTabId;
|
const activeWorkspaceUserContextId = activeWorkspace?.containerTabId;
|
||||||
|
|
||||||
if ((fromExternal || allowInheritPrincipal === false) && !!activeWorkspaceUserContextId) {
|
|
||||||
return [activeWorkspaceUserContextId, true, undefined];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof userContextId !== 'undefined' && userContextId !== activeWorkspaceUserContextId) {
|
if (typeof userContextId !== 'undefined' && userContextId !== activeWorkspaceUserContextId) {
|
||||||
return [userContextId, false, undefined];
|
return [userContextId, false, undefined];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user