[Pkg-mozext-commits] [tabmixplus] 99/123: Add tabmixScrollBox to TabsToolbar in tabmix.xul overlay, split TabmixTabbar.setScrollButtonBox and move the code to setting the scroll buttons to tabStrip's binding and the code to set the box position to Tabmix.navToolbox

David Prévot taffit at moszumanska.debian.org
Wed Sep 17 21:16:31 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 4c40f092b0fd1b0aaa3a6ac51321a7a86e37c543
Author: onemen <tabmix.onemen at gmail.com>
Date:   Sat Sep 13 15:40:17 2014 +0300

    Add tabmixScrollBox to TabsToolbar in tabmix.xul overlay, split TabmixTabbar.setScrollButtonBox and move the code to setting the scroll buttons to tabStrip's binding and the code to set the box position to Tabmix.navToolbox
---
 chrome/content/minit/minit.js       | 56 ++++++++++++++++++++++++++-----------
 chrome/content/overlay/browsr.css   |  1 +
 chrome/content/tab/scrollbox.xml    | 26 +++++++++++++++++
 chrome/content/tab/tab.js           | 48 ++++++-------------------------
 chrome/content/tab/tabbrowser_4.xml |  3 +-
 chrome/content/tabmix.xul           | 11 ++++++--
 6 files changed, 86 insertions(+), 59 deletions(-)

diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index c5490c9..68a45ab 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -945,14 +945,20 @@ Tabmix.navToolbox = {
 
     // fix bug 1034394 - tab mix plus's tabmixscrollbox is not cleaned up after
     // uninstalling tab mix plus
+    if (!Tabmix.isVersion(290)) {
+      this.cleanCurrentset();
+      return;
+    }
+    CustomizableUI.removeWidgetFromArea("tabmixScrollBox");
+  },
+
+  cleanCurrentset: function() {
     let tabsToolbar = document.getElementById("TabsToolbar");
     let cSet = tabsToolbar.getAttribute("currentset");
     if (cSet.indexOf("tabmixScrollBox") > -1) {
       cSet = cSet.replace("tabmixScrollBox", "").replace(",,", ",");
       tabsToolbar.setAttribute("currentset", cSet);
       document.persist("TabsToolbar", "currentset");
-      if (Tabmix.isVersion(290))
-        CustomizableUI.removeWidgetFromArea("tabmixScrollBox");
     }
   },
 
@@ -1026,7 +1032,7 @@ Tabmix.navToolbox = {
     this.initializeSearchbar();
     this.toolbarButtons();
     this.initializeAlltabsPopup();
-    this.initializeScrollButtons();
+    this.tabStripAreaChanged();
   },
 
   urlBarInitialized: false,
@@ -1212,22 +1218,40 @@ Tabmix.navToolbox = {
     }
   },
 
-  initializeScrollButtons: function TMP_navToolbox_initializeScrollButtons() {
-    // Make sure our scroll buttons box is after tabbrowser-tabs
-    let id = "tabmixScrollBox";
-    let box = document.getElementById(id);
-    let tabBar = gBrowser.tabContainer;
-    if (box && box != tabBar.nextSibling) {
-      let useTabmixButtons = TabmixTabbar.scrollButtonsMode > TabmixTabbar.SCROLL_BUTTONS_LEFT_RIGHT;
-      TabmixTabbar.setScrollButtonBox(useTabmixButtons, true, true);
-      if (!Tabmix.isVersion(320) && useTabmixButtons && tabBar.overflow) {
-        tabBar.mTabstrip._scrollButtonUp.collapsed = false;
-        tabBar.mTabstrip._scrollButtonDown.collapsed = false;
-      }
-    }
+  tabStripAreaChanged: function() {
+    this.setScrollButtons();
 
     // reset tabsNewtabButton and afterTabsButtonsWidth
     if (typeof privateTab == "object")
       TMP_eventListener.updateMultiRow(true);
+  },
+
+  setScrollButtons: function(reset, onlyPosition) {
+    let box = document.getElementById("tabmixScrollBox");
+    if (!box)
+      return;
+
+    if (!reset && box == gBrowser.tabContainer.nextSibling)
+      return;
+
+    // Make sure our scroll buttons box is after tabbrowser-tabs
+    if (!Tabmix.isVersion(290)) {
+      let next = gBrowser.tabContainer.nextSibling;
+      next.parentNode.insertBefore(box, next);
+      return;
+    }
+    let tabsPosition = Tabmix.getPlacement("tabbrowser-tabs");
+    CustomizableUI.moveWidgetWithinArea("tabmixScrollBox", tabsPosition + 1);
+
+    if (!onlyPosition) {
+      let useTabmixButtons = TabmixTabbar.scrollButtonsMode > TabmixTabbar.SCROLL_BUTTONS_LEFT_RIGHT;
+      gBrowser.tabContainer.mTabstrip.updateScrollButtons(useTabmixButtons);
+    }
   }
+
+}
+
+Tabmix.getPlacement = function(id) {
+  let placement = CustomizableUI.getPlacementOfWidget(id);
+  return placement ? placement.position : null;
 }
diff --git a/chrome/content/overlay/browsr.css b/chrome/content/overlay/browsr.css
index 90e7257..dcac46a 100644
--- a/chrome/content/overlay/browsr.css
+++ b/chrome/content/overlay/browsr.css
@@ -153,6 +153,7 @@ label.text-link, label[onclick] {
 #TabsToolbar[tabmix-show-newtabbutton="aftertabs"]:not([customizing="true"]) >
    #tabbrowser-tabs:not([overflow="true"]) > .tabbrowser-arrowscrollbox > .tabs-newtab-button[command="cmd_newNavigatorTab"] {
   display: -moz-box;
+  visibility: visible;
 }
 
 #TabsToolbar[tabmix-show-newtabbutton*="side"] > #new-tab-button {
diff --git a/chrome/content/tab/scrollbox.xml b/chrome/content/tab/scrollbox.xml
index a9708bb..6318615 100644
--- a/chrome/content/tab/scrollbox.xml
+++ b/chrome/content/tab/scrollbox.xml
@@ -36,6 +36,14 @@
         document.getAnonymousElementByAttribute(this, "anonid", "scrollbutton-down-right");
       </field>
 
+      <constructor>
+        <![CDATA[
+          let tabstrip = gBrowser.tabContainer.mTabstrip;
+          tabstrip._scrollButtonDownRight = this._scrollButtonDown;
+          tabstrip._scrollButtonUpRight = this._scrollButtonUp;
+        ]]>
+      </constructor>
+
       <method name="finishScroll">
         <parameter name="aEvent"/>
         <body><![CDATA[
@@ -98,6 +106,24 @@
         document.getAnonymousElementByAttribute(this._scrollbox, "class", "box-inherit scrollbox-innerbox");
       </field>
 
+      <method name="updateScrollButtons">
+        <parameter name="useTabmixButtons"/>
+        <body><![CDATA[
+          this._scrollButtonDown = !useTabmixButtons ?
+              this._scrollButtonDownLeft : this._scrollButtonDownRight;
+          var tabContainer = document.getBindingParent(this);
+          tabContainer._animateElement = this._scrollButtonDown;
+
+          this._scrollButtonUp = !useTabmixButtons ?
+              this._scrollButtonUpLeft : this._scrollButtonUpRight;
+          this._updateScrollButtonsDisabledState();
+          if (!Tabmix.isVersion(320)) {
+            this._scrollButtonUp.collapsed = !tabContainer.overflow;
+            this._scrollButtonDown.collapsed = !tabContainer.overflow;
+          }
+        ]]></body>
+      </method>
+
       <!-- we replace tabbrowser.xml "tabbrowser-arrowscrollbox" binding with this one
            Override scrollbox.xml method, since our scrollbox's children are
            inherited from the binding parent -->
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index f9377fa..da93e12 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -72,19 +72,22 @@ var TabmixTabbar = {
       let overflow = tabBar.overflow;
 
       // from Firefox 4.0+ on we add dynamicly scroll buttons on TabsToolbar.
-      this.setScrollButtonBox(useTabmixButtons, false, true);
+      let tabmixScrollBox = document.getElementById("tabmixScrollBox");
+      if (tabmixScrollBox) // just in case our box is missing
+        tabBar.mTabstrip.updateScrollButtons(useTabmixButtons);
+
       if (isMultiRow || prevTabscroll == this.SCROLL_BUTTONS_MULTIROW) {
         // temporarily hide vertical scroll button.
         // visible button can interfere with row height calculation.
         // remove the collapsed attribut after updateVerticalTabStrip
-        Tabmix.setItem("tabmixScrollBox", "collapsed", true);
+        Tabmix.setItem(tabmixScrollBox, "collapsed", true);
       }
 
       let flowing = ["singlebar", "scrollbutton", "multibar", "scrollbutton"][tabscroll];
       this.flowing = flowing;
       let isDefault = tabscroll == this.SCROLL_BUTTONS_LEFT_RIGHT || null;
       Tabmix.setItem(tabBar, "defaultScrollButtons", isDefault);
-      Tabmix.setItem("tabmixScrollBox", "defaultScrollButtons", isDefault);
+      Tabmix.setItem(tabmixScrollBox, "defaultScrollButtons", isDefault);
 
       if (prevTabscroll == this.SCROLL_BUTTONS_MULTIROW) {
         tabBar.resetFirstTabInRow();
@@ -98,7 +101,7 @@ var TabmixTabbar = {
         if (tabBar.updateVerticalTabStrip() == "scrollbar")
           tabBar.overflow = true;
       }
-      Tabmix.setItem("tabmixScrollBox", "collapsed", null);
+      Tabmix.setItem(tabmixScrollBox, "collapsed", null);
 
       tabBar._positionPinnedTabs();
       if (isMultiRow && TMP_tabDNDObserver.paddingLeft)
@@ -210,39 +213,6 @@ var TabmixTabbar = {
     }
   },
 
-  setScrollButtonBox: function TMP_setScrollButtonBox(useTabmixButtons, insertAfterTabs, update) {
-    let newBox, box = document.getElementById("tabmixScrollBox");
-    if (useTabmixButtons && !box) {
-      newBox = true;
-      box = document.createElement("box");
-      box.setAttribute("class", "tabbrowser-arrowscrollbox tabmix_scrollbuttons_box");
-      box.setAttribute("type", "tabmix-box");
-      box.setAttribute("id", "tabmixScrollBox");
-    }
-
-    let tabStrip  = gBrowser.tabContainer.mTabstrip;
-    if (newBox || (useTabmixButtons && insertAfterTabs)) {
-      let tabsToolbar = document.getElementById("TabsToolbar");
-///XXX check if we can do it only on first oveflow
-      tabsToolbar.insertBefore(box, gBrowser.tabContainer.nextSibling);
-      tabStrip._scrollButtonDownRight = box._scrollButtonDown;
-      tabStrip._scrollButtonUpRight = box._scrollButtonUp;
-    }
-    if (update) {
-      tabStrip._scrollButtonDown = !useTabmixButtons ?
-          tabStrip._scrollButtonDownLeft : tabStrip._scrollButtonDownRight;
-      gBrowser.tabContainer._animateElement = tabStrip._scrollButtonDown;
-
-      tabStrip._scrollButtonUp = !useTabmixButtons ?
-          tabStrip._scrollButtonUpLeft : tabStrip._scrollButtonUpRight;
-      tabStrip._updateScrollButtonsDisabledState();
-      if (!Tabmix.isVersion(320)) {
-        tabStrip._scrollButtonUp.collapsed = !gBrowser.tabContainer.overflow;
-        tabStrip._scrollButtonDown.collapsed = !gBrowser.tabContainer.overflow;
-      }
-    }
-  },
-
   updateScrollStatus: function TMP_updateScrollStatus() {
     var tabBar = gBrowser.tabContainer;
     if (this.isMultiRow) {
@@ -1380,8 +1350,8 @@ var gTMPprefObserver = {
 
       // move button within TabsToolbar
       if (Tabmix.isVersion(290)) {
-        let buttonPosition = CustomizableUI.getPlacementOfWidget("new-tab-button").position;
-        let tabsPosition = CustomizableUI.getPlacementOfWidget("tabbrowser-tabs").position;
+        let buttonPosition = Tabmix.getPlacement("new-tab-button");
+        let tabsPosition = Tabmix.getPlacement("tabbrowser-tabs");
         let changePosition = (aPosition == 0 && buttonPosition > tabsPosition) ||
                              (aPosition == 1 && buttonPosition < tabsPosition) ||
                              (aPosition == 2 && buttonPosition != tabsPosition + 1);
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index 1ef20f4..c8b6a8f 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -799,8 +799,7 @@
 
           TabmixTabbar.flowing = this.getAttribute("flowing");
           this.setTabStripOrient();
-          let useTabmixButtons = TabmixTabbar.scrollButtonsMode > TabmixTabbar.SCROLL_BUTTONS_LEFT_RIGHT;
-          TabmixTabbar.setScrollButtonBox(useTabmixButtons, true, true);
+          Tabmix.navToolbox.setScrollButtons(true);
 
           // fix incompatibility with Personal Titlebar extension
           // the extensions trigger tabbar binding reset on toolbars customize
diff --git a/chrome/content/tabmix.xul b/chrome/content/tabmix.xul
index 88b8bef..5969275 100644
--- a/chrome/content/tabmix.xul
+++ b/chrome/content/tabmix.xul
@@ -380,8 +380,15 @@
       <tooltip id="tabmix-tooltip"/>
     </popupset>
 
-   <!-- hide Tab groups context menu in all-tabs list button -->
-   <menuitem id="menu_tabview" context=""/>
+    <!-- hide Tab groups context menu in all-tabs list button -->
+    <menuitem id="menu_tabview" context=""/>
+
+    <toolbar id="TabsToolbar">
+      <box id="tabmixScrollBox" insertafter="tabbrowser-tabs"
+                     class="tabbrowser-arrowscrollbox tabmix_scrollbuttons_box"
+                     type="tabmix-box"
+                     removable="false"/>
+    </toolbar>
 
   <!-- Tabmix Plus broadcasterset -->
   <broadcasterset id="mainBroadcasterSet">

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list