Bug 474908 - Dragging a tab in a window with only one tab detaches the tab. r=mano
authorDão Gottwald <dao@mozilla.com>
Sat, 07 Mar 2009 17:03:32 +0100
changeset 25823 77a7aa432a4e1a794a09ad9cde9953cc98f90abd
parent 25822 977faa9e0afa08b63d595f0e79862e4e26028390
child 25824 5cb7c5a0aaf820d099bb7a8ba35c5c8a1a1ccabc
push id5766
push userdgottwald@mozilla.com
push dateSat, 07 Mar 2009 16:04:21 +0000
treeherdermozilla-central@77a7aa432a4e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmano
bugs474908
milestone1.9.2a1pre
Bug 474908 - Dragging a tab in a window with only one tab detaches the tab. r=mano
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2209,27 +2209,21 @@
         <body>
           <![CDATA[
             // Note: while this case is correctly handled here, this event
             // isn't dispatched when the tab is moved within the tabstript,
             // see bug 460801.
 
             // * mozUserCancelled = the user pressed ESC to cancel the drag
             // * Within our browser window, the detach-target is the content
-            //   area.That case is handled by contentAreaDNDObserver.
+            //   area. That case is handled by contentAreaDNDObserver.
             // * The dragLeftWindow solution is suboptimal, a better solution
             //   is on bug 466379.
-            // * One-tab-left case: one might argue that this should
-            //   be handled in dragstart (i.e. not include the "detach"
-            //   type), but what if the user wants to "merge" this window
-            //   into another one?
             var dt = aEvent.dataTransfer;
-            if (dt.mozUserCancelled ||
-                !this._dragLeftWindow ||
-                this.mTabs.length == 1)
+            if (dt.mozUserCancelled || !this._dragLeftWindow)
               return;
 
             // The dropEffect == "none" scenarios:
             // 1. No-op (no postion change) - "catched" by !dragLeftWindow
             // 2. On the browser chrome (on element which don't handle
             //    text/plain or the tab type) - ditto.
             // 2. Drop outside the browser window - the case that is handled
             //    here.
@@ -2259,20 +2253,25 @@
             // still dragged within our window. How would that happen? Either
             // by the dragleave event that is dispatched right before the drop,
             // or by a bubbled dragleave event
             this._dragLeftWindow = aEvent.clientX < 0 || aEvent.clientY < 0;
           ]]>
         </body>
       </method>
 
+      <!-- Moves a tab to a new browser window, unless it's already the only tab
+           in the current window, in which case this will do nothing. -->
       <method name="replaceTabWithWindow">
         <parameter name="aTab"/>
         <body>
           <![CDATA[
+            if (this.mTabs.length == 1)
+              return;
+
             // tell a new window to take the "dropped" tab
             var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
                       getService(Ci.nsIWindowWatcher);
             ww.openWindow(window,
                           getBrowserURL(),
                           null,
                           "chrome,dialog=no,all",
                           aTab);