Bug 482065 - Allow rearranging of thumbnails in the all tabs panel. r=enn
authorDão Gottwald <dao@mozilla.com>
Fri, 22 Jan 2010 09:44:16 +0100
changeset 37404 97745a2b2de9
parent 37403 5160ef92cda9
child 37405 b99be55d43f7
push id11279
push userdgottwald@mozilla.com
push dateFri, 22 Jan 2010 08:44:45 +0000
treeherdermozilla-central@97745a2b2de9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenn
bugs482065
milestone1.9.3a1pre
Bug 482065 - Allow rearranging of thumbnails in the all tabs panel. r=enn
browser/base/content/browser-tabPreviews.js
browser/base/content/browser-tabPreviews.xml
--- a/browser/base/content/browser-tabPreviews.js
+++ b/browser/base/content/browser-tabPreviews.js
@@ -727,18 +727,20 @@ var allTabs = {
         break;
       case "TabMove":
         let siblingPreview = tab.nextSibling &&
                              this._getPreview(tab.nextSibling);
         if (siblingPreview)
           siblingPreview.parentNode.insertBefore(preview, siblingPreview);
         else
           this.container.lastChild.appendChild(preview);
-        if (this.isOpen && !preview.hidden)
+        if (this.isOpen && !preview.hidden) {
           this._reflow();
+          preview.focus();
+        }
         break;
       case "TabClose":
         this._removePreview(preview);
         break;
       case "keypress":
         this._onKeyPress(event);
         break;
       case "command":
--- a/browser/base/content/browser-tabPreviews.xml
+++ b/browser/base/content/browser-tabPreviews.xml
@@ -79,11 +79,29 @@
         <xul:hbox class="allTabs-favicon-container">
           <xul:image class="allTabs-favicon" xbl:inherits="src=image"/>
         </xul:hbox>
       </xul:stack>
     </content>
     <handlers>
       <handler event="command" action="allTabs.pick(this);"/>
       <handler event="click" button="1" action="gBrowser.removeTab(this._tab);"/>
+
+      <handler event="dragstart"><![CDATA[
+        event.dataTransfer.mozSetDataAt("application/x-moz-node", this._tab, 0);
+      ]]></handler>
+
+      <handler event="dragover"><![CDATA[
+        let tab = event.dataTransfer.mozGetDataAt("application/x-moz-node", 0);
+        if (tab && tab.parentNode == gBrowser.tabContainer)
+          event.preventDefault();
+      ]]></handler>
+
+      <handler event="drop"><![CDATA[
+        let tab = event.dataTransfer.mozGetDataAt("application/x-moz-node", 0);
+        if (tab && tab.parentNode == gBrowser.tabContainer) {
+          let newIndex = Array.indexOf(gBrowser.tabContainer.childNodes, this._tab);
+          gBrowser.moveTabTo(tab, newIndex);
+        }
+      ]]></handler>
     </handlers>
   </binding>
 </bindings>