Bug 686417 - Allow dragging within the tab sidebar [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 22 Sep 2011 19:19:12 -0700
changeset 77371 31f2a1d947be4b750f1e5edccaf0e68da3949b92
parent 77370 8547992229cc1d3efdcc9be67ddd9c8256cb7aef
child 77372 1e9807475e1e7011df078a324807dc4f7efd36a0
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmfinkle
bugs686417
milestone9.0a1
Bug 686417 - Allow dragging within the tab sidebar [r=mfinkle]
mobile/chrome/content/tabs.xml
--- a/mobile/chrome/content/tabs.xml
+++ b/mobile/chrome/content/tabs.xml
@@ -176,16 +176,51 @@
       <xul:box class="tabs-list" anonid="tabs-undo"/>
     </content>
     <implementation>
       <field name="children">document.getAnonymousElementByAttribute(this, "anonid", "tabs-children");</field>
       <field name="_scrollbox">document.getAnonymousElementByAttribute(this, "anonid", "tabs-scrollbox");</field>
       <field name="_tabsUndo">document.getAnonymousElementByAttribute(this, "anonid", "tabs-undo");</field>
       <field name="_selectedTab">null</field>
 
+      <constructor>
+        <![CDATA[
+          // This customDragger wraps the default dragger, and looks for
+          // horizontal movement to hide or show the tab bar in tablet mode.
+          let scrollbox = this._scrollbox;
+          let [,scroller,dragger] = ScrollUtils.getScrollboxFromElement(scrollbox);
+          scrollbox.customDragger = {
+            _grabSidebar: false,
+
+            isDraggable: function isDraggable(target, content) {
+              return { x: true, y: true };
+            },
+
+            dragStart: function dragStart(cx, cy, target) {
+              this._grabSidebar = Util.isTablet() && !Util.isPortrait();
+              if (this._grabSidebar)
+                Browser.grabSidebar();
+              dragger.dragStart(cx, cy, target, scroller);
+            },
+
+            dragStop: function dragStop(dx, dy) {
+              if (this._grabSidebar)
+                Browser.ungrabSidebar();
+              dragger.dragStop(dx, dy, scroller);
+            },
+
+            dragMove: function dragMove(dx, dy) {
+              if (this._grabSidebar)
+                Browser.slideSidebarBy(dx);
+              return dragger.dragMove(dx, dy, scroller);
+            }
+          };
+        ]]>
+      </constructor>
+
       <!-- Used by the chrome input handler -->
       <property name="boxObject"
                 readonly="true"
                 onget="return this._scrollbox.boxObject;"/>
 
       <field name="scrollBoxObject">
         this.boxObject.QueryInterface(Ci.nsIScrollBoxObject);
       </field>