fix: Small fixes with the folder database, b=no-bug, c=tabs, folders, workspaces

This commit is contained in:
Mr. M
2025-08-26 16:31:59 +02:00
parent ca6d34def5
commit 7db203ca77
6 changed files with 69 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce164f06b427 100644 index e47f735e4e4563c9b7537944628418d1478c068d..b6d52ef3179d66ecd7f06fd61a6bca6d075b9cf7 100644
--- a/browser/components/tabbrowser/content/tabs.js --- a/browser/components/tabbrowser/content/tabs.js
+++ b/browser/components/tabbrowser/content/tabs.js +++ b/browser/components/tabbrowser/content/tabs.js
@@ -332,7 +332,7 @@ @@ -332,7 +332,7 @@
@@ -341,15 +341,24 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
selectedTab._notselectedsinceload = false; selectedTab._notselectedsinceload = false;
} }
@@ -2152,6 +2208,7 @@ @@ -2152,6 +2208,16 @@
when the tab is first selected to be dragged. when the tab is first selected to be dragged.
*/ */
#updateTabStylesOnDrag(tab) { #updateTabStylesOnDrag(tab) {
+ let { movingTabs: zenMovingTabs } = tab._dragData;
+ for (let movingTab of zenMovingTabs.slice(zenMovingTabs.findIndex(t => t._tPos == tab._tPos))) {
+ if (isTabGroupLabel(tab)) {
+ movingTab = movingTab.parentElement;
+ }
+ // "dragtarget" contains the following rules which must only be set AFTER the above
+ // elements have been adjusted. {z-index: 3 !important, position: absolute !important}
+ movingTab.setAttribute("zen-dragtarget", "");
+ }
+ return; + return;
let isPinned = tab.pinned; let isPinned = tab.pinned;
let numPinned = gBrowser.pinnedTabCount; let numPinned = gBrowser.pinnedTabCount;
let allTabs = this.ariaFocusableItems; let allTabs = this.ariaFocusableItems;
@@ -2385,7 +2442,7 @@ @@ -2385,7 +2451,7 @@
return; return;
} }
@@ -358,7 +367,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
let directionX = screenX > dragData.animLastScreenX; let directionX = screenX > dragData.animLastScreenX;
let directionY = screenY > dragData.animLastScreenY; let directionY = screenY > dragData.animLastScreenY;
@@ -2394,6 +2451,8 @@ @@ -2394,6 +2460,8 @@
let { width: tabWidth, height: tabHeight } = let { width: tabWidth, height: tabHeight } =
draggedTab.getBoundingClientRect(); draggedTab.getBoundingClientRect();
@@ -367,7 +376,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
let shiftSizeX = tabWidth * movingTabs.length; let shiftSizeX = tabWidth * movingTabs.length;
let shiftSizeY = tabHeight; let shiftSizeY = tabHeight;
dragData.tabWidth = tabWidth; dragData.tabWidth = tabWidth;
@@ -2430,8 +2489,8 @@ @@ -2430,8 +2498,8 @@
let lastBoundX = let lastBoundX =
lastTabInRow.screenX + lastTabInRow.screenX +
lastTabInRow.getBoundingClientRect().width - lastTabInRow.getBoundingClientRect().width -
@@ -378,7 +387,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
translateX = Math.min(Math.max(translateX, firstBoundX), lastBoundX); translateX = Math.min(Math.max(translateX, firstBoundX), lastBoundX);
translateY = Math.min(Math.max(translateY, firstBoundY), lastBoundY); translateY = Math.min(Math.max(translateY, firstBoundY), lastBoundY);
@@ -2547,7 +2606,7 @@ @@ -2547,7 +2615,7 @@
} }
dragData.animDropElementIndex = newIndex; dragData.animDropElementIndex = newIndex;
@@ -387,7 +396,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
dragData.dropBefore = newIndex < tabs.length; dragData.dropBefore = newIndex < tabs.length;
// Shift background tabs to leave a gap where the dragged tab // Shift background tabs to leave a gap where the dragged tab
@@ -2580,13 +2639,18 @@ @@ -2580,13 +2648,18 @@
this.#clearDragOverCreateGroupTimer(); this.#clearDragOverCreateGroupTimer();
@@ -410,7 +419,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
if (this.#rtlMode) { if (this.#rtlMode) {
tabs.reverse(); tabs.reverse();
@@ -2597,7 +2661,7 @@ @@ -2597,7 +2670,7 @@
let screenAxis = this.verticalMode ? "screenY" : "screenX"; let screenAxis = this.verticalMode ? "screenY" : "screenX";
let size = this.verticalMode ? "height" : "width"; let size = this.verticalMode ? "height" : "width";
let translateAxis = this.verticalMode ? "translateY" : "translateX"; let translateAxis = this.verticalMode ? "translateY" : "translateX";
@@ -419,7 +428,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
let translateX = event.screenX - dragData.screenX; let translateX = event.screenX - dragData.screenX;
let translateY = event.screenY - dragData.screenY; let translateY = event.screenY - dragData.screenY;
@@ -2607,10 +2671,16 @@ @@ -2607,10 +2680,16 @@
dragData.translateY = translateY; dragData.translateY = translateY;
// Move the dragged tab based on the mouse position. // Move the dragged tab based on the mouse position.
@@ -438,7 +447,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
let endEdge = ele => ele[screenAxis] + bounds(ele)[size]; let endEdge = ele => ele[screenAxis] + bounds(ele)[size];
let lastMovingTabScreen = endEdge(lastMovingTab); let lastMovingTabScreen = endEdge(lastMovingTab);
let firstMovingTabScreen = firstMovingTab[screenAxis]; let firstMovingTabScreen = firstMovingTab[screenAxis];
@@ -2619,6 +2689,7 @@ @@ -2619,6 +2698,7 @@
// Constrain the range over which the moving tabs can move between the first and last tab // Constrain the range over which the moving tabs can move between the first and last tab
let firstBound = firstTab[screenAxis] - firstMovingTabScreen; let firstBound = firstTab[screenAxis] - firstMovingTabScreen;
let lastBound = endEdge(lastTab) - lastMovingTabScreen; let lastBound = endEdge(lastTab) - lastMovingTabScreen;
@@ -446,7 +455,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
// Center the tab under the cursor if the tab is not under the cursor while dragging // Center the tab under the cursor if the tab is not under the cursor while dragging
if ( if (
@@ -2636,6 +2707,9 @@ @@ -2636,6 +2716,9 @@
// Shift the `.tab-group-label-container` to shift the label element. // Shift the `.tab-group-label-container` to shift the label element.
item = item.parentElement; item = item.parentElement;
} }
@@ -456,7 +465,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
item.style.transform = `${translateAxis}(${translate}px)`; item.style.transform = `${translateAxis}(${translate}px)`;
} }
@@ -2773,6 +2847,9 @@ @@ -2773,6 +2856,9 @@
break; break;
} }
let element = tabs[mid]; let element = tabs[mid];
@@ -466,7 +475,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
let elementForSize = isTabGroupLabel(element) let elementForSize = isTabGroupLabel(element)
? element.parentElement ? element.parentElement
: element; : element;
@@ -2792,6 +2869,8 @@ @@ -2792,6 +2878,8 @@
}; };
let dropElement = getOverlappedElement(); let dropElement = getOverlappedElement();
@@ -475,7 +484,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
let newDropElementIndex; let newDropElementIndex;
if (dropElement) { if (dropElement) {
@@ -2856,7 +2935,10 @@ @@ -2856,7 +2944,10 @@
let shouldCreateGroupOnDrop; let shouldCreateGroupOnDrop;
let dropBefore; let dropBefore;
if (dropElement) { if (dropElement) {
@@ -487,7 +496,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
? dropElement.parentElement ? dropElement.parentElement
: dropElement; : dropElement;
@@ -2876,7 +2958,7 @@ @@ -2876,7 +2967,7 @@
? Services.prefs.getIntPref( ? Services.prefs.getIntPref(
"browser.tabs.dragDrop.moveOverThresholdPercent" "browser.tabs.dragDrop.moveOverThresholdPercent"
) / 100 ) / 100
@@ -496,7 +505,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
moveOverThreshold = Math.min(1, Math.max(0, moveOverThreshold)); moveOverThreshold = Math.min(1, Math.max(0, moveOverThreshold));
let shouldMoveOver = overlapPercent > moveOverThreshold; let shouldMoveOver = overlapPercent > moveOverThreshold;
if (logicalForward && shouldMoveOver) { if (logicalForward && shouldMoveOver) {
@@ -2908,44 +2990,21 @@ @@ -2908,44 +2999,21 @@
// If dragging a group over another group, don't make it look like it is // If dragging a group over another group, don't make it look like it is
// possible to drop the dragged group inside the other group. // possible to drop the dragged group inside the other group.
@@ -546,7 +555,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
// When dragging tab(s) over an ungrouped tab, signal to the user // When dragging tab(s) over an ungrouped tab, signal to the user
// that dropping the tab(s) will create a new tab group. // that dropping the tab(s) will create a new tab group.
shouldCreateGroupOnDrop = shouldCreateGroupOnDrop =
@@ -2955,12 +3014,6 @@ @@ -2955,12 +3023,6 @@
overlapPercent > dragOverGroupingThreshold; overlapPercent > dragOverGroupingThreshold;
if (shouldCreateGroupOnDrop) { if (shouldCreateGroupOnDrop) {
@@ -559,7 +568,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
} else { } else {
this.removeAttribute("movingtab-createGroup"); this.removeAttribute("movingtab-createGroup");
document document
@@ -2987,19 +3040,14 @@ @@ -2987,19 +3049,14 @@
dropElement = dropElementGroup; dropElement = dropElementGroup;
colorCode = undefined; colorCode = undefined;
} else if (isTabGroupLabel(dropElement)) { } else if (isTabGroupLabel(dropElement)) {
@@ -587,7 +596,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
} }
this.#setDragOverGroupColor(colorCode); this.#setDragOverGroupColor(colorCode);
this.toggleAttribute("movingtab-ungroup", !colorCode); this.toggleAttribute("movingtab-ungroup", !colorCode);
@@ -3017,19 +3065,28 @@ @@ -3017,19 +3074,28 @@
dragData.dropElement = dropElement; dragData.dropElement = dropElement;
dragData.dropBefore = dropBefore; dragData.dropBefore = dropBefore;
dragData.animDropElementIndex = newDropElementIndex; dragData.animDropElementIndex = newDropElementIndex;
@@ -618,7 +627,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
} }
item.style.transform = transform; item.style.transform = transform;
} }
@@ -3082,12 +3139,14 @@ @@ -3082,12 +3148,14 @@
); );
} }
@@ -635,7 +644,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
for (let item of this.ariaFocusableItems) { for (let item of this.ariaFocusableItems) {
if (isTabGroupLabel(item)) { if (isTabGroupLabel(item)) {
@@ -3095,6 +3154,18 @@ @@ -3095,6 +3163,18 @@
item = item.parentElement; item = item.parentElement;
} }
item.style.transform = ""; item.style.transform = "";
@@ -654,15 +663,26 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
item.removeAttribute("dragover-createGroup"); item.removeAttribute("dragover-createGroup");
} }
this.removeAttribute("movingtab-createGroup"); this.removeAttribute("movingtab-createGroup");
@@ -3122,7 +3193,6 @@ @@ -3116,16 +3196,15 @@
tab.style.left = "";
tab.style.top = "";
tab.style.maxWidth = "";
- tab.removeAttribute("dragtarget");
+ tab.removeAttribute("zen-dragtarget");
}
for (let label of draggedTabDocument.getElementsByClassName(
"tab-group-label-container" "tab-group-label-container"
)) { )) {
label.style.width = ""; label.style.width = "";
- label.style.height = ""; - label.style.height = "";
label.style.left = ""; label.style.left = "";
label.style.top = ""; label.style.top = "";
label.removeAttribute("dragtarget"); - label.removeAttribute("dragtarget");
@@ -3198,7 +3268,7 @@ + label.removeAttribute("zen-dragtarget");
}
let periphery = draggedTabDocument.getElementById(
"tabbrowser-arrowscrollbox-periphery"
@@ -3198,7 +3277,7 @@
let postTransitionCleanup = () => { let postTransitionCleanup = () => {
movingTab._moveTogetherSelectedTabsData.animate = false; movingTab._moveTogetherSelectedTabsData.animate = false;
}; };
@@ -671,7 +691,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
postTransitionCleanup(); postTransitionCleanup();
} else { } else {
let onTransitionEnd = transitionendEvent => { let onTransitionEnd = transitionendEvent => {
@@ -3371,7 +3441,7 @@ @@ -3371,7 +3450,7 @@
} }
_notifyBackgroundTab(aTab) { _notifyBackgroundTab(aTab) {
@@ -680,7 +700,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
return; return;
} }
@@ -3480,7 +3550,10 @@ @@ -3480,7 +3559,10 @@
#getDragTarget(event, { ignoreSides = false } = {}) { #getDragTarget(event, { ignoreSides = false } = {}) {
let { target } = event; let { target } = event;
while (target) { while (target) {
@@ -692,7 +712,7 @@ index e47f735e4e4563c9b7537944628418d1478c068d..ca542ede66aed5bcd6ecfc5c3d5fce16
break; break;
} }
target = target.parentNode; target = target.parentNode;
@@ -3497,6 +3570,9 @@ @@ -3497,6 +3579,9 @@
return null; return null;
} }
} }

View File

@@ -1223,13 +1223,15 @@
collapseVisibleTab(group, onlyIfActive = false, selectedTab = null) { collapseVisibleTab(group, onlyIfActive = false, selectedTab = null) {
let tabsToCollapse = [selectedTab]; let tabsToCollapse = [selectedTab];
if (group?.hasAttribute('split-view-group')) { if (group?.hasAttribute('split-view-group') && selectedTab && onlyIfActive) {
tabsToCollapse = group.tabs; tabsToCollapse = group.tabs;
group = group.group; group = group.group;
} }
if (!group?.isZenFolder) return; if (!group?.isZenFolder) return;
selectedTab.style.removeProperty('--zen-folder-indent'); if (selectedTab) {
selectedTab.style.removeProperty('--zen-folder-indent');
}
// We ignore if the flag is set to avoid infinite recursion // We ignore if the flag is set to avoid infinite recursion
if (onlyIfActive && group.activeGroups.length && selectedTab) { if (onlyIfActive && group.activeGroups.length && selectedTab) {
onlyIfActive = true; onlyIfActive = true;

View File

@@ -319,9 +319,7 @@ zen-folder {
color: var(--sidebar-text-color) !important; color: var(--sidebar-text-color) !important;
margin: 0 !important; margin: 0 !important;
font-weight: 600; font-weight: 600;
display: flex; align-self: center !important;
align-items: center;
height: 100% !important;
text-align: start; text-align: start;
:root:not([zen-sidebar-expanded]) & { :root:not([zen-sidebar-expanded]) & {

View File

@@ -442,7 +442,7 @@
group.collapsed, group.collapsed,
workspaceId, workspaceId,
group.getAttribute('zen-pin-id'), group.getAttribute('zen-pin-id'),
group.labelElement.elementIndex group._pPos
); );
group.setAttribute('zen-pin-id', id); group.setAttribute('zen-pin-id', id);
await this.refreshPinnedTabs(); await this.refreshPinnedTabs();
@@ -457,7 +457,7 @@
const pinId = group.getAttribute('zen-pin-id'); const pinId = group.getAttribute('zen-pin-id');
const tabPinId = tab.getAttribute('zen-pin-id'); const tabPinId = tab.getAttribute('zen-pin-id');
const tabPin = this._pinsCache?.find((p) => p.uuid === tabPinId); const tabPin = this._pinsCache?.find((p) => p.uuid === tabPinId);
if (!tabPin) { if (!tabPin || !tabPin.group) {
return; return;
} }
ZenPinnedTabsStorage.addTabToGroup(tabPinId, pinId, /* position */ tab._pPos); ZenPinnedTabsStorage.addTabToGroup(tabPinId, pinId, /* position */ tab._pPos);
@@ -487,7 +487,7 @@
groupPin.title = group.name; groupPin.title = group.name;
groupPin.folderIcon = group.iconURL; groupPin.folderIcon = group.iconURL;
groupPin.isFolderCollapsed = group.collapsed; groupPin.isFolderCollapsed = group.collapsed;
groupPin.position = group.labelElement.elementIndex; groupPin.position = group._pPos;
groupPin.parentUuid = group.group?.getAttribute('zen-pin-id') || null; groupPin.parentUuid = group.group?.getAttribute('zen-pin-id') || null;
groupPin.workspaceUuid = group.getAttribute('zen-workspace-id') || null; groupPin.workspaceUuid = group.getAttribute('zen-workspace-id') || null;
await this.savePin(groupPin); await this.savePin(groupPin);
@@ -515,7 +515,7 @@
if (!group.isZenFolder) { if (!group.isZenFolder) {
return; return;
} }
const newIndex = group.labelElement.elementIndex; const newIndex = group._pPos;
const pinId = group.getAttribute('zen-pin-id'); const pinId = group.getAttribute('zen-pin-id');
if (!pinId) { if (!pinId) {
return; return;
@@ -1259,7 +1259,7 @@
} }
getLastTabBound(lastBound, lastTab, isDraggingFolder = false) { getLastTabBound(lastBound, lastTab, isDraggingFolder = false) {
if (!gBrowser.isTab(lastTab) || !lastTab.pinned || isDraggingFolder) { if (!lastTab.pinned || isDraggingFolder) {
return lastBound; return lastBound;
} }
const shiftedItems = this.dragShiftableItems; const shiftedItems = this.dragShiftableItems;

View File

@@ -1475,3 +1475,8 @@
display: flex !important; display: flex !important;
} }
} }
.tabbrowser-tab[zen-dragtarget],
.tab-group-label-container[zen-dragtarget] {
z-index: 9 !important;
}

View File

@@ -1106,9 +1106,12 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
for (let tab of tabs) { for (let tab of tabs) {
const workspaceID = tab.getAttribute('zen-workspace-id'); const workspaceID = tab.getAttribute('zen-workspace-id');
if ( if (
workspaceID && (workspaceID &&
!tab.hasAttribute('zen-essential') && !tab.hasAttribute('zen-essential') &&
!workspaces.workspaces.find((workspace) => workspace.uuid === workspaceID) !workspaces.workspaces.find((workspace) => workspace.uuid === workspaceID)) ||
// Also remove empty tabs that are supposed to be from parent folders but
// they dont exist anymore
(tab.pinned && tab.hasAttribute('zen-empty-tab') && !tab.group)
) { ) {
// Remove any tabs where their workspace doesn't exist anymore // Remove any tabs where their workspace doesn't exist anymore
gBrowser.unpinTab(tab); gBrowser.unpinTab(tab);
@@ -1615,6 +1618,7 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
} }
#fixTabPositions() { #fixTabPositions() {
gBrowser.tabContainer._invalidateCachedTabs();
// Fix tabs _tPos values relative to the actual order // Fix tabs _tPos values relative to the actual order
const tabs = gBrowser.tabs; const tabs = gBrowser.tabs;
const usedGroups = new Set(); const usedGroups = new Set();