Bug 1458056 - Implement ability to move a selection of tabs into another window through drag and drop. r?jaws draft multiselect_move_to_another_window_drag
authorAbdoulaye O. Ly <ablayelyfondou@gmail.com>
Tue, 07 Aug 2018 01:20:01 +0000
branchmultiselect_move_to_another_window_drag
changeset 827101 00566e92e2d05e66231e06a327a9d28b2e9e88e2
parent 826308 3d107866825433ab1168c7d23e94eac727e0f673
push id118464
push userbmo:ablayelyfondou@gmail.com
push dateTue, 07 Aug 2018 01:26:41 +0000
reviewersjaws
bugs1458056
milestone63.0a1
Bug 1458056 - Implement ability to move a selection of tabs into another window through drag and drop. r?jaws MozReview-Commit-ID: LFFoE6HsBp8
browser/base/content/tabbrowser.js
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -3474,16 +3474,22 @@ window._gBrowser = {
     firstInactiveTab.linkedBrowser.addEventListener("EndSwapDocShells", function() {
       for (let i = 1; i < inactiveTabs.length; i++) {
         win.gBrowser.adoptTab(inactiveTabs[i], i);
       }
 
       if (activeTabNewIndex > -1) {
         win.gBrowser.adoptTab(activeTab, activeTabNewIndex, true /* aSelectTab */);
       }
+
+      // Restore tab selection
+      let winVisibleTabs = win.gBrowser.visibleTabs;
+      let winTabLength = winVisibleTabs.length;
+      win.gBrowser.addRangeToMultiSelectedTabs(winVisibleTabs[0],
+                                               winVisibleTabs[winTabLength - 1]);
     }, { once: true });
 
     win = this.replaceTabWithWindow(firstInactiveTab);
     return win;
   },
 
   _updateTabsAfterInsert() {
     for (let i = 0; i < this.tabs.length; i++) {
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1458,17 +1458,24 @@
                 gBrowser.moveTabTo(tab, dropIndex);
                 if (incrementDropIndex)
                   dropIndex++;
               }
             }
           }
         } else if (draggedTab) {
           let newIndex = this._getDropIndex(event, false);
-          gBrowser.adoptTab(draggedTab, newIndex, true);
+          let newTabs = [];
+          for (let tab of movingTabs) {
+            let newTab = gBrowser.adoptTab(tab, newIndex++, tab == draggedTab);
+            newTabs.push(newTab);
+          }
+
+          // Restore tab selection
+          gBrowser.addRangeToMultiSelectedTabs(newTabs[0], newTabs[newTabs.length - 1]);
         } else {
           // Pass true to disallow dropping javascript: or data: urls
           let links;
           try {
             links = browserDragAndDrop.dropLinks(event, true);
           } catch (ex) {}
 
           if (!links || links.length === 0)
@@ -1585,17 +1592,17 @@
           window.moveTo(left, top);
           window.focus();
         } else {
           let props = { screenX: left, screenY: top, suppressanimation: 1 };
           if (AppConstants.platform != "win") {
             props.outerWidth = winWidth;
             props.outerHeight = winHeight;
           }
-          gBrowser.replaceTabWithWindow(draggedTab, props);
+          gBrowser.replaceTabsWithWindow(draggedTab, props);
         }
         event.stopPropagation();
       ]]></handler>
 
       <handler event="dragexit"><![CDATA[
         this._dragTime = 0;
 
         // This does not work at all (see bug 458613)