[Pkg-mozext-commits] [tabmixplus] 23/51: Move isElementVisible from gBrowser.tabContainer.mTabstrip to Tabmix.tabsUtils

David Prévot taffit at moszumanska.debian.org
Mon Feb 2 18:36:49 UTC 2015


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

taffit pushed a commit to branch master
in repository tabmixplus.

commit ec43741408cae014d28b4a16535288d099ff6faf
Author: onemen <tabmix.onemen at gmail.com>
Date:   Sat Jan 3 18:10:48 2015 +0200

    Move isElementVisible from gBrowser.tabContainer.mTabstrip to Tabmix.tabsUtils
---
 chrome/content/click/click.js       |  4 ++--
 chrome/content/minit/tablib.js      |  3 +--
 chrome/content/places/places.js     |  2 +-
 chrome/content/tab/scrollbox.xml    | 33 ++-------------------------------
 chrome/content/tab/tab.js           | 33 +++++++++++++++++++++++++++++----
 chrome/content/tab/tabbrowser_4.xml |  6 +++---
 modules/RenameTab.jsm               |  2 +-
 7 files changed, 39 insertions(+), 44 deletions(-)

diff --git a/chrome/content/click/click.js b/chrome/content/click/click.js
index 389604c..ef9989e 100644
--- a/chrome/content/click/click.js
+++ b/chrome/content/click/click.js
@@ -782,7 +782,7 @@ var TabmixAllTabs = {
       let curTabBO = curTab.boxObject;
       if (!curTabBO) // "Tabs From Other Computers" menuitem
         continue;
-      if (tabContainer.mTabstrip.isElementVisible(curTab))
+      if (Tabmix.tabsUtils.isElementVisible(curTab))
         this.childNodes[i].setAttribute("tabIsVisible", "true");
       else
         this.childNodes[i].removeAttribute("tabIsVisible");
@@ -936,7 +936,7 @@ var TabmixAllTabs = {
         let addToMenu = side != "right";
         for (let t = 0; t < tabs.length; t++) {
           let tab = tabs[t];
-          let visible = side && gBrowser.tabContainer.mTabstrip.isElementVisible(tab);
+          let visible = side && Tabmix.tabsUtils.isElementVisible(tab);
           if (visible) {
             if (tab.pinned)
               continue;
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index c973089..a3b0714 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -1635,9 +1635,8 @@ var tablib = {
     // return the current tab only if it is visible
     if (TabmixTabbar.widthFitTitle &&
         (!TMP_Places.inUpdateBatch || !TMP_Places.currentTab)) {
-      let tabBar = gBrowser.tabContainer;
       let tab = gBrowser.selectedTab;
-      if (tabBar.mTabstrip.isElementVisible(tab))
+      if (Tabmix.tabsUtils.isElementVisible(tab))
        TMP_Places.currentTab = tab;
     }
     return TMP_Places.getTabTitle(aTab, url, title);
diff --git a/chrome/content/places/places.js b/chrome/content/places/places.js
index 7b8607e..f0ae7cb 100644
--- a/chrome/content/places/places.js
+++ b/chrome/content/places/places.js
@@ -600,7 +600,7 @@ var TMP_Places = {
     this.inUpdateBatch = true;
 
     if (TabmixTabbar.widthFitTitle &&
-         gBrowser.tabContainer.mTabstrip.isElementVisible(gBrowser.mCurrentTab))
+        Tabmix.tabsUtils.isElementVisible(gBrowser.mCurrentTab))
       this.currentTab = gBrowser.mCurrentTab;
   },
 
diff --git a/chrome/content/tab/scrollbox.xml b/chrome/content/tab/scrollbox.xml
index 3e6a20e..14d5084 100644
--- a/chrome/content/tab/scrollbox.xml
+++ b/chrome/content/tab/scrollbox.xml
@@ -348,35 +348,6 @@
         ]]></getter>
       </property>
 
-      <method name="isElementVisible">
-        <parameter name="element"/>
-        <body><![CDATA[
-          if (!element || !element.parentNode || element.collapsed || element.hidden)
-            return false;
-
-          // pinned tabs are always visible
-          if (element.pinned)
-            return true;
-
-          var [start, end] = this._startEndProps;
-          var rect = this.scrollClientRect;
-          var containerStart = rect[start];
-          var containerEnd = rect[end];
-          rect = element.getBoundingClientRect();
-          var elementStart = rect[start];
-          var elementEnd = rect[end];
-
-          // we don't need the extra check with scrollContentRect
-          // like in ensureElementIsVisible, the element will be invisible anyhow.
-          if (elementStart < containerStart)
-            return false;
-          else if (containerEnd < elementEnd)
-            return false;
-
-          return true;
-        ]]></body>
-      </method>
-
       <method name="_enterVerticalMode">
         <parameter name="blockUnderflow"/>
         <body><![CDATA[
@@ -393,8 +364,8 @@
           let tabs = this._getScrollableElements();
           if (!tabs.length)
             return;
-          let isFirstTabVisible = this.isElementVisible(tabs[0]);
-          let isLastTabVisible = this.isElementVisible(tabs[tabs.length-1]);
+          let isFirstTabVisible = Tabmix.tabsUtils.isElementVisible(tabs[0]);
+          let isLastTabVisible = Tabmix.tabsUtils.isElementVisible(tabs[tabs.length-1]);
           if (!isFirstTabVisible || !isLastTabVisible) {
             // show Newtabbutton for the first time
             // for the case last tab in row fill the all strip and the button
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index 95a8808..b7a2e23 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -64,7 +64,7 @@ var TabmixTabbar = {
     this.scrollButtonsMode = tabscroll;
     var isMultiRow = tabscroll == this.SCROLL_BUTTONS_MULTIROW;
 
-    var currentVisible = start ? true : tabStrip.isElementVisible(gBrowser.mCurrentTab);
+    var currentVisible = start ? true : Tabmix.tabsUtils.isElementVisible(gBrowser.mCurrentTab);
 
     if (prevTabscroll != tabscroll) {
       // update pointer to the button object that we are going to use
@@ -958,6 +958,32 @@ Tabmix.tabsUtils = {
       tabstrip._scrollButtonUp.collapsed = !overflow;
       tabstrip._scrollButtonDown.collapsed = !overflow;
     }
+  },
+
+  isElementVisible: function(element) {
+    if (!element || !element.parentNode || element.collapsed || element.hidden)
+      return false;
+
+    // pinned tabs are always visible
+    if (element.pinned)
+      return true;
+
+    var [start, end] = this.tabBar.mTabstrip._startEndProps;
+    var rect = this.tabBar.mTabstrip.scrollClientRect;
+    var containerStart = rect[start];
+    var containerEnd = rect[end];
+    rect = element.getBoundingClientRect();
+    var elementStart = rect[start];
+    var elementEnd = rect[end];
+
+    // we don't need the extra check with scrollContentRect
+    // like in ensureElementIsVisible, the element will be invisible anyhow.
+    if (elementStart < containerStart)
+      return false;
+    else if (containerEnd < elementEnd)
+      return false;
+
+    return true;
   }
 };
 
@@ -1159,8 +1185,7 @@ var gTMPprefObserver = {
         break;
       case "browser.tabs.tabMaxWidth":
       case "browser.tabs.tabMinWidth":
-        var tabStrip = gBrowser.tabContainer.mTabstrip;
-        var currentVisible = tabStrip.isElementVisible(gBrowser.mCurrentTab);
+        var currentVisible = Tabmix.tabsUtils.isElementVisible(gBrowser.mCurrentTab);
         let tabMaxWidth = Math.max(16, Services.prefs.getIntPref("browser.tabs.tabMaxWidth"));
         let tabMinWidth = Math.max(16, Services.prefs.getIntPref("browser.tabs.tabMinWidth"));
         if (tabMaxWidth < tabMinWidth) {
@@ -1353,7 +1378,7 @@ var gTMPprefObserver = {
           }
           // maxRow changed
           if (TabmixTabbar.isMultiRow) {
-            let isVisible = tabBar.mTabstrip.isElementVisible(gBrowser.mCurrentTab);
+            let isVisible = Tabmix.tabsUtils.isElementVisible(gBrowser.mCurrentTab);
             // we hide the button to see if tabs can fits to fewer rows without the scroll buttons
             if (Tabmix.tabsUtils.overflow && row > TabmixTabbar.visibleRows)
               Tabmix.tabsUtils.overflow = false;
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index 49b2838..a2637ef 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -356,7 +356,7 @@
           if (aTab.pinned)
             return;
           // Is the new tab already completely visible?
-          if (this.mTabstrip.isElementVisible(aTab))
+          if (Tabmix.tabsUtils.isElementVisible(aTab))
             return;
 
           var scrollRect = this.mTabstrip.scrollClientRect;
@@ -412,7 +412,7 @@
       <method name="isTabVisible">
         <parameter name="aIndex"/>
         <body><![CDATA[
-          return this.mTabstrip.isElementVisible(this.childNodes.item(aIndex));
+          return Tabmix.tabsUtils.isElementVisible(this.childNodes.item(aIndex));
         ]]></body>
       </method>
       <method name="ensureTabIsVisible">
@@ -425,7 +425,7 @@
       </method>
       <property name="lastTabVisible" readonly="true">
         <getter><![CDATA[
-          return this.mTabstrip.isElementVisible(Tabmix.visibleTabs.last);
+          return Tabmix.tabsUtils.isElementVisible(Tabmix.visibleTabs.last);
         ]]></getter>
       </property>
 
diff --git a/modules/RenameTab.jsm b/modules/RenameTab.jsm
index 7ca7f65..153a7cf 100644
--- a/modules/RenameTab.jsm
+++ b/modules/RenameTab.jsm
@@ -80,7 +80,7 @@ this.RenameTab = {
     popup.addEventListener("keypress", this, false);
     // dock the panel to the tab icon when possible, otherwise show the panel
     // at screen center
-    if (this.window.gBrowser.tabContainer.mTabstrip.isElementVisible(this.data.tab))
+    if (this.window.Tabmix.tabsUtils.isElementVisible(this.data.tab))
       popup.openPopup(this.data.tab, "bottomcenter topleft");
     else {
       let screen = this.window.screen;

-- 
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