fix: Fixed cancelling drag mid-split, b=closes #10554, c=tabs, split-view

This commit is contained in:
mr. m
2025-09-27 12:53:41 +02:00
parent bb33bbcc39
commit 528f3d6a0b
2 changed files with 45 additions and 43 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js
index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd0698e189659 100644
index c7557dad38db9ef02b981c46de9595df77cb67db..f45ecacd23179f06a436d5f3d372b536322388ea 100644
--- a/browser/components/tabbrowser/content/tabs.js
+++ b/browser/components/tabbrowser/content/tabs.js
@@ -44,6 +44,9 @@
@@ -157,7 +157,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
gBrowser.loadTabs(urls, {
inBackground,
replace,
@@ -1541,6 +1568,16 @@
@@ -1541,6 +1568,17 @@
}
this.#resetTabsAfterDrop(draggedTab.ownerDocument);
@@ -168,13 +168,14 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
+ return;
+ }
+ } else if (dt.mozUserCancelled) {
+ gZenViewSplitter.onBrowserDragEndToSplit(event, true);
+ if (gZenViewSplitter._lastOpenedTab) gZenViewSplitter._lastOpenedTab._visuallySelected = false;
+ }
+
if (
dt.mozUserCancelled ||
dt.dropEffect != "none" ||
@@ -1707,7 +1744,6 @@
@@ -1707,7 +1745,6 @@
this.toggleAttribute("overflow", true);
this._updateCloseButtons();
@@ -182,7 +183,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
document
.getElementById("tab-preview-panel")
@@ -1765,7 +1801,7 @@
@@ -1765,7 +1802,7 @@
}
get newTabButton() {
@@ -191,7 +192,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
}
get verticalMode() {
@@ -1781,6 +1817,7 @@
@@ -1781,6 +1818,7 @@
}
get overflowing() {
@@ -199,7 +200,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
return this.hasAttribute("overflow");
}
@@ -1789,31 +1826,51 @@
@@ -1789,31 +1827,51 @@
if (this.#allTabs) {
return this.#allTabs;
}
@@ -267,7 +268,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
}
/**
@@ -1880,29 +1937,23 @@
@@ -1880,29 +1938,23 @@
let elementIndex = 0;
@@ -306,7 +307,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
}
}
@@ -1914,6 +1965,7 @@
@@ -1914,6 +1966,7 @@
_invalidateCachedTabs() {
this.#allTabs = null;
this._invalidateCachedVisibleTabs();
@@ -314,7 +315,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
}
_invalidateCachedVisibleTabs() {
@@ -1929,8 +1981,8 @@
@@ -1929,8 +1982,8 @@
#isContainerVerticalPinnedGrid(tab) {
return (
this.verticalMode &&
@@ -325,7 +326,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
!this.expandOnHover
);
}
@@ -1946,7 +1998,7 @@
@@ -1946,7 +1999,7 @@
if (node == null) {
// We have a container for non-tab elements at the end of the scrollbox.
@@ -334,7 +335,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
}
node.before(tab);
@@ -2041,7 +2093,7 @@
@@ -2041,7 +2094,7 @@
// There are separate "new tab" buttons for horizontal tabs toolbar, vertical tabs and
// for when the tab strip is overflowed (which is shared by vertical and horizontal tabs);
// Attach the long click popup to all of them.
@@ -343,7 +344,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
const newTab2 = this.newTabButton;
const newTabVertical = document.getElementById(
"vertical-tabs-newtab-button"
@@ -2139,8 +2191,10 @@
@@ -2139,8 +2192,10 @@
*/
_handleTabSelect(aInstant) {
let selectedTab = this.selectedItem;
@@ -354,7 +355,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
selectedTab._notselectedsinceload = false;
}
@@ -2149,7 +2203,7 @@
@@ -2149,7 +2204,7 @@
* @param {boolean} [shouldScrollInstantly=false]
*/
#ensureTabIsVisible(tab, shouldScrollInstantly = false) {
@@ -363,7 +364,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
if (arrowScrollbox.overflowing) {
arrowScrollbox.ensureElementIsVisible(tab, shouldScrollInstantly);
}
@@ -2288,6 +2342,16 @@
@@ -2288,6 +2343,16 @@
when the tab is first selected to be dragged.
*/
#updateTabStylesOnDrag(tab) {
@@ -380,7 +381,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
let isPinned = tab.pinned;
let numPinned = gBrowser.pinnedTabCount;
let allTabs = this.ariaFocusableItems;
@@ -2540,7 +2604,7 @@
@@ -2540,7 +2605,7 @@
return;
}
@@ -389,7 +390,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
let directionX = screenX > dragData.animLastScreenX;
let directionY = screenY > dragData.animLastScreenY;
@@ -2549,6 +2613,8 @@
@@ -2549,6 +2614,8 @@
let { width: tabWidth, height: tabHeight } =
draggedTab.getBoundingClientRect();
@@ -398,7 +399,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
let shiftSizeX = tabWidth * movingTabs.length;
let shiftSizeY = tabHeight;
dragData.tabWidth = tabWidth;
@@ -2585,8 +2651,8 @@
@@ -2585,8 +2652,8 @@
let lastBoundX =
lastTabInRow.screenX +
lastTabInRow.getBoundingClientRect().width -
@@ -409,7 +410,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
translateX = Math.min(Math.max(translateX, firstBoundX), lastBoundX);
translateY = Math.min(Math.max(translateY, firstBoundY), lastBoundY);
@@ -2743,13 +2809,18 @@
@@ -2743,13 +2810,18 @@
this.#clearDragOverGroupingTimer();
@@ -432,7 +433,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
if (this.#rtlMode) {
tabs.reverse();
@@ -2760,7 +2831,7 @@
@@ -2760,7 +2832,7 @@
let screenAxis = this.verticalMode ? "screenY" : "screenX";
let size = this.verticalMode ? "height" : "width";
let translateAxis = this.verticalMode ? "translateY" : "translateX";
@@ -441,7 +442,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
let tabSize = this.verticalMode ? tabHeight : tabWidth;
let translateX = event.screenX - dragData.screenX;
let translateY = event.screenY - dragData.screenY;
@@ -2776,6 +2847,12 @@
@@ -2776,6 +2848,12 @@
);
let lastMovingTab = movingTabs.at(-1);
let firstMovingTab = movingTabs[0];
@@ -454,7 +455,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
let endEdge = ele => ele[screenAxis] + bounds(ele)[size];
let lastMovingTabScreen = endEdge(lastMovingTab);
let firstMovingTabScreen = firstMovingTab[screenAxis];
@@ -2790,6 +2867,11 @@
@@ -2790,6 +2868,11 @@
let endBound = this.#rtlMode
? endEdge(this) - lastMovingTabScreen
: periphery[screenAxis] - 1 - lastMovingTabScreen;
@@ -466,7 +467,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
translate = Math.min(Math.max(translate, startBound), endBound);
// Center the tab under the cursor if the tab is not under the cursor while dragging
@@ -2979,6 +3061,8 @@
@@ -2979,6 +3062,8 @@
};
let dropElement = getOverlappedElement();
@@ -475,7 +476,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
let newDropElementIndex;
if (dropElement) {
@@ -3060,7 +3144,7 @@
@@ -3060,7 +3145,7 @@
? Services.prefs.getIntPref(
"browser.tabs.dragDrop.moveOverThresholdPercent"
) / 100
@@ -484,7 +485,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
moveOverThreshold = Math.min(1, Math.max(0, moveOverThreshold));
let shouldMoveOver = overlapPercent > moveOverThreshold;
if (logicalForward && shouldMoveOver) {
@@ -3093,6 +3177,7 @@
@@ -3093,6 +3178,7 @@
// 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.
if (
@@ -492,7 +493,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
isTabGroupLabel(draggedTab) &&
dropElement?.group &&
(!dropElement.group.collapsed ||
@@ -3119,20 +3204,13 @@
@@ -3119,20 +3205,13 @@
let isOutOfBounds = isPinned
? dropElement.elementIndex >= numPinned
: dropElement.elementIndex < numPinned;
@@ -517,7 +518,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
let groupingDelay = Services.prefs.getIntPref(
"browser.tabs.dragDrop.createGroup.delayMS"
);
@@ -3140,6 +3218,7 @@
@@ -3140,6 +3219,7 @@
// When dragging tab(s) over an ungrouped tab, signal to the user
// that dropping the tab(s) will create a new tab group.
let shouldCreateGroupOnDrop =
@@ -525,7 +526,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
!movingTabsSet.has(dropElement) &&
isTab(dropElement) &&
!dropElement?.group &&
@@ -3148,6 +3227,7 @@
@@ -3148,6 +3228,7 @@
// When dragging tab(s) over a collapsed tab group label, signal to the
// user that dropping the tab(s) will add them to the group.
let shouldDropIntoCollapsedTabGroup =
@@ -533,7 +534,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
isTabGroupLabel(dropElement) &&
dropElement.group.collapsed &&
overlapPercent > dragOverGroupingThreshold;
@@ -3192,19 +3272,14 @@
@@ -3192,19 +3273,14 @@
dropElement = dropElementGroup;
colorCode = undefined;
} else if (isTabGroupLabel(dropElement)) {
@@ -561,7 +562,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
}
this.#setDragOverGroupColor(colorCode);
this.toggleAttribute("movingtab-addToGroup", colorCode);
@@ -3223,11 +3298,11 @@
@@ -3223,11 +3299,11 @@
dragData.dropElement = dropElement;
dragData.dropBefore = dropBefore;
dragData.animDropElementIndex = newDropElementIndex;
@@ -575,7 +576,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
continue;
}
@@ -3346,12 +3421,14 @@
@@ -3346,12 +3422,14 @@
element?.removeAttribute("dragover-groupTarget");
}
@@ -592,7 +593,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
for (let item of this.ariaFocusableItems) {
this.#resetGroupTarget(item);
@@ -3394,16 +3471,15 @@
@@ -3394,16 +3472,15 @@
tab.style.left = "";
tab.style.top = "";
tab.style.maxWidth = "";
@@ -611,7 +612,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
}
let periphery = draggedTabDocument.getElementById(
"tabbrowser-arrowscrollbox-periphery"
@@ -3475,7 +3551,7 @@
@@ -3475,7 +3552,7 @@
let postTransitionCleanup = () => {
movingTab._moveTogetherSelectedTabsData.animate = false;
};
@@ -620,7 +621,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
postTransitionCleanup();
} else {
let onTransitionEnd = transitionendEvent => {
@@ -3639,7 +3715,7 @@
@@ -3639,7 +3716,7 @@
}
_notifyBackgroundTab(aTab) {
@@ -629,7 +630,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
return;
}
@@ -3748,7 +3824,10 @@
@@ -3748,7 +3825,10 @@
#getDragTarget(event, { ignoreSides = false } = {}) {
let { target } = event;
while (target) {
@@ -641,7 +642,7 @@ index c7557dad38db9ef02b981c46de9595df77cb67db..4192dc797d5f07ece57e7e9ecb0cd069
break;
}
target = target.parentNode;
@@ -3765,6 +3844,9 @@
@@ -3765,6 +3845,9 @@
return null;
}
}