diff --git a/browser/components/tabbrowser/content/tabs.js b/browser/components/tabbrowser/content/tabs.js index acaa5bc7e5be..f7c39fe80418 100644 --- a/browser/components/tabbrowser/content/tabs.js +++ b/browser/components/tabbrowser/content/tabs.js @@ -2286,9 +2286,6 @@ // as single tab dragging. tabs = tabs.filter(t => !movingTabs.includes(t) || t == draggedTab); - let firstTabCenter = firstMovingTabScreen + translate + tabSize / 2; - let lastTabCenter = lastMovingTabScreen + translate + tabSize / 2; - let tabCenter = directionForward ? lastTabCenter : firstTabCenter; let getTabShift = (tab, dropIndex) => { if (tab._tPos < draggedTab._tPos && tab._tPos >= dropIndex) { return this.#rtlMode ? -shiftSize : shiftSize; @@ -2302,7 +2299,12 @@ // We're doing a binary search in order to reduce the amount of // tabs we need to check. let oldIndex = dragData.animDropIndex ?? movingTabs[0]._tPos; - let tabDropIndexFromPoint = point => { + let getDragOverIndex = tabSizeDragOverThreshold => { + let point = + (directionForward + ? lastMovingTabScreen + tabSize * (1 - tabSizeDragOverThreshold) + : firstMovingTabScreen + tabSize * tabSizeDragOverThreshold) + + translate; let index = -1; let low = 0; let high = tabs.length - 1; @@ -2322,12 +2324,13 @@ break; } } - if (index >= oldIndex) { - index++; - } return index; }; - let newIndex = tabDropIndexFromPoint(tabCenter); + let moveOverThreshold = gBrowser._tabGroupsEnabled ? 0.7 : 0.5; + let newIndex = getDragOverIndex(moveOverThreshold); + if (newIndex >= oldIndex) { + newIndex++; + } if (newIndex < 0) { newIndex = oldIndex; } @@ -2340,15 +2343,7 @@ ) / 100; dragOverGroupingThreshold = Math.max(0, dragOverGroupingThreshold); dragOverGroupingThreshold = Math.min(0.5, dragOverGroupingThreshold); - let groupPoint = - (directionForward - ? lastMovingTabScreen + tabSize * (1 - dragOverGroupingThreshold) - : firstMovingTabScreen + tabSize * dragOverGroupingThreshold) + - translate; - let groupDropIndex = tabDropIndexFromPoint(groupPoint); - if (directionForward) { - groupDropIndex--; - } + let groupDropIndex = getDragOverIndex(dragOverGroupingThreshold); if ( "groupDropIndex" in dragData && dragData.groupDropIndex != groupDropIndex