From 5e09e88bb28a5c6e9a2b62b8e7a710d2607cdb00 Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Tue, 4 Dec 2012 01:40:31 +0900 Subject: [PATCH] Operate drag and drop of pinned tabs more correctly --- content/treestyletab/res/tabsDragUtils.js | 8 +++++++- modules/tabbarDNDObserver.js | 13 +++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/content/treestyletab/res/tabsDragUtils.js b/content/treestyletab/res/tabsDragUtils.js index 652c7f3d..d4e6c29f 100644 --- a/content/treestyletab/res/tabsDragUtils.js +++ b/content/treestyletab/res/tabsDragUtils.js @@ -410,7 +410,13 @@ collectAlignedTabs : function TDU_collectAlignedTabs(tabs, context) { context.allAnimatedTabs = tabs; - var base = context.draggedTab.boxObject[context.align]; + var baseTab = context.draggedTab; + if (!baseTab.pinned) + return tabs; + + // With Tree Style Tabs, pinned tabs are shown with multiple rows. + // We should animate only tabs in the same row. + var base = baseTab.boxObject[context.align]; return tabs.filter(function(aTab) { return aTab.boxObject[context.align] == base; }); diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js index 6c620cf9..c54d94c3 100644 --- a/modules/tabbarDNDObserver.js +++ b/modules/tabbarDNDObserver.js @@ -268,11 +268,16 @@ catch(e) { let draggedTab = aEvent.dataTransfer && aEvent.dataTransfer.mozGetDataAt(TAB_DROP_TYPE, 0); if (draggedTab._dragData) { - let tabs = sv.getTabs(b).filter(function(aTab) { - return !aTab._dragData; + let sameTypeUndraggedTabs = tabs.filter(function(aTab) { + return !aTab._dragData && aTab.pinned == draggedTab.pinned; }); - tab = sv.getTabFromCoordinates(aEvent, tabs) || - sv.getTabFromCoordinates(aEvent); + tab = draggedTab.pinned ? + // pinned tabs cannot be dropped to another pinned tab, so + // we can use the drop position calculated by "_animateTabMove()". + tabs[draggedTab._dragData.animDropIndex] : + // otherwise, we have to find "drop target" tab from screen coordinates. + sv.getTabFromCoordinates(aEvent, sameTypeUndraggedTabs) || + sv.getTabFromCoordinates(aEvent); } var isTabMoveFromOtherWindow = aSourceTab && aSourceTab.ownerDocument != d;