[Pkg-mozext-commits] [tabmixplus] 15/51: Move topTabY, getTabRowNumber and lastTabRowNumber to Tabmix.tabsUtils
David Prévot
taffit at moszumanska.debian.org
Mon Feb 2 18:36:47 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 5780baaa962819fe0ca49068f607d7dc38a31c74
Author: onemen <tabmix.onemen at gmail.com>
Date: Sat Jan 3 19:37:29 2015 +0200
Move topTabY, getTabRowNumber and lastTabRowNumber to Tabmix.tabsUtils
---
chrome/content/minit/minit.js | 4 +--
chrome/content/minit/tablib.js | 2 +-
chrome/content/tab/scrollbox.xml | 2 +-
chrome/content/tab/tab.js | 51 +++++++++++++++++++++++++++----------
chrome/content/tab/tabbrowser_4.xml | 37 +++------------------------
chrome/content/tabmix.js | 2 +-
6 files changed, 45 insertions(+), 53 deletions(-)
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index 9b5a8a0..8bc6a05 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -558,7 +558,7 @@ var TMP_tabDNDObserver = {
},
getNewIndex: function (event) {
- function getTabRowNumber(tab, top) tab.pinned ? 1 : gBrowser.tabContainer.getTabRowNumber(tab, top)
+ function getTabRowNumber(tab, top) tab.pinned ? 1 : Tabmix.tabsUtils.getTabRowNumber(tab, top)
// if mX is less then the first tab return 0
// check if mY is below the tab.... if yes go to next row
// in the row find the closest tab by mX,
@@ -577,7 +577,7 @@ var TMP_tabDNDObserver = {
}
}
else {
- let topY = tabBar.topTabY;
+ let topY = Tabmix.tabsUtils.topTabY;
for (let i = 0; i < numTabs; i++) {
let tab = tabs[i];
let thisRow = getTabRowNumber(tab, topY);
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index c6cb9ba..8ef8655 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -372,7 +372,7 @@ var tablib = {
// we get here when we are about to go to single row
// one tab before the last is in the first row and we are closing one tab
var tabs = visibleTabs || this.tabbrowser.visibleTabs;
- return this.getTabRowNumber(tabs[tabs.length-2], this.topTabY) == 1;
+ return Tabmix.tabsUtils.getTabRowNumber(tabs[tabs.length-2], Tabmix.tabsUtils.topTabY) == 1;
};
Tabmix.changeCode(tabBar, "gBrowser.tabContainer._lockTabSizing")._replace(
diff --git a/chrome/content/tab/scrollbox.xml b/chrome/content/tab/scrollbox.xml
index dd09ec6..6200c33 100644
--- a/chrome/content/tab/scrollbox.xml
+++ b/chrome/content/tab/scrollbox.xml
@@ -451,7 +451,7 @@
///XXX check if we can set the margin with animation when we scroll
let end = Tabmix.ltr ? "right": "left";
let containerEnd = this.scrollClientRect[end];
- let top = tabBar.topTabY;
+ let top = Tabmix.tabsUtils.topTabY;
let tabs = this._getScrollableElements();
let index, current = 0;
for (let i = 0; i < tabs.length; i++) {
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index aa5dfb3..55b2688 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -264,7 +264,7 @@ var TabmixTabbar = {
let height = Tabmix.tabsUtils.tabstripInnerbox.getBoundingClientRect().height;
if (tabBar.getAttribute("multibar") == "scrollbar") {
// We can get here if we switch to diffrent tabs position while in multibar
- let rowHeight = height/tabBar.lastTabRowNumber;
+ let rowHeight = height/Tabmix.tabsUtils.lastTabRowNumber;
newHeight = rowHeight * aRows;
}
else
@@ -407,7 +407,7 @@ var TabmixTabbar = {
let specialTab = isSpecialTab();
if (tab && (TabmixSvc.australis && attrib == "beforeselected" ||
multibar || tab.hasAttribute(removed) || specialTab)) {
- let sameRow = multibar ? tabRow == tabBar.getTabRowNumber(tab, topY) || null : true;
+ let sameRow = multibar ? tabRow == Tabmix.tabsUtils.getTabRowNumber(tab, topY) || null : true;
Tabmix.setItem(tab, removed, !sameRow || null);
Tabmix.setItem(tab, attrib, getAttVal(sameRow, true));
if (visible)
@@ -417,8 +417,8 @@ var TabmixTabbar = {
if (tabBar._hoveredTab && !tabBar._hoveredTab.closing) {
if (multibar) {
- topY = tabBar.topTabY;
- tabRow = tabBar.getTabRowNumber(tabBar._hoveredTab, topY);
+ topY = Tabmix.tabsUtils.topTabY;
+ tabRow = Tabmix.tabsUtils.getTabRowNumber(tabBar._hoveredTab, topY);
}
updateAtt(tabBar._beforeHoveredTab, "beforeHoveredTab", "beforehovered");
updateAtt(tabBar._afterHoveredTab, "afterHoveredTab", "afterhovered");
@@ -442,8 +442,8 @@ var TabmixTabbar = {
}
if (multibar) {
- topY = topY || tabBar.topTabY;
- tabRow = tabBar.getTabRowNumber(selected, topY);
+ topY = topY || Tabmix.tabsUtils.topTabY;
+ tabRow = Tabmix.tabsUtils.getTabRowNumber(selected, topY);
}
updateAtt(prev, "beforeSelectedTab", "beforeselected", TabmixSvc.australis, "tabmix-");
updateAtt(next, "afterSelectedTab", "afterselected", Tabmix.isVersion(220), "");
@@ -453,13 +453,12 @@ var TabmixTabbar = {
if (this._rowHeight && this._rowHeight[tabsPosition])
return this._rowHeight[tabsPosition];
- var tabBar = gBrowser.tabContainer;
var tabs = gBrowser.visibleTabs;
var firstTab = tabs[0];
var lastTab = Tabmix.visibleTabs.last;
- var topY = tabBar.topTabY;
- var lastTabRow = tabBar.lastTabRowNumber;
+ var topY = Tabmix.tabsUtils.topTabY;
+ var lastTabRow = Tabmix.tabsUtils.lastTabRowNumber;
if (lastTabRow == 1) { // one row
if (firstTab.getAttribute("selected") == "true")
return lastTab.boxObject.height;
@@ -472,7 +471,7 @@ var TabmixTabbar = {
// check if previous to last tab in the 1st row
// this happen when the selected tab is the first tab in the 2nd row
var prev = Tabmix.visibleTabs.previous(lastTab);
- if (prev && tabBar.getTabRowNumber(prev, topY) == 1)
+ if (prev && Tabmix.tabsUtils.getTabRowNumber(prev, topY) == 1)
return lastTab.boxObject.height;
else
newRowHeight = prev.baseY - firstTab.baseY;
@@ -481,7 +480,7 @@ var TabmixTabbar = {
// check if 2nd visible tab is in the 2nd row
// (not likely that user set tab width to more then half screen width)
var next = Tabmix.visibleTabs.next(firstTab);
- if (next && tabBar.getTabRowNumber(next, topY) == 2)
+ if (next && Tabmix.tabsUtils.getTabRowNumber(next, topY) == 2)
return lastTab.boxObject.height;
else
newRowHeight = lastTab.baseY - next.baseY;
@@ -520,9 +519,9 @@ var TabmixTabbar = {
if ( !tab1 || !tab2 )
return false;
- var tabBar = gBrowser.tabContainer;
- var topY = tabBar.topTabY;
- return tabBar.getTabRowNumber(tab1, topY) == tabBar.getTabRowNumber(tab2, topY);
+ var topY = Tabmix.tabsUtils.topTabY;
+ return Tabmix.tabsUtils.getTabRowNumber(tab1, topY) ==
+ Tabmix.tabsUtils.getTabRowNumber(tab2, topY);
},
setFirstTabInRow: function() {
@@ -799,6 +798,30 @@ Tabmix.tabsUtils = {
let newVal = this.tabBar.overflow || val;
TabmixTabbar.showNewTabButtonOnSide(newVal, "temporary-right-side");
return newVal;
+ },
+
+ get topTabY() {
+ return this.tabstripInnerbox.getBoundingClientRect().top +
+ Tabmix.getStyle(this.tabstripInnerbox, "paddingTop");
+ },
+
+ get lastTabRowNumber() {
+ return this.getTabRowNumber(Tabmix.visibleTabs.last, this.topTabY);
+ },
+
+ getTabRowNumber: function(aTab, aTop) {
+ var {top, height} = aTab ? aTab.getBoundingClientRect() : {};
+ height = aTab ? aTab.boxObject.height : 0;
+ if (!height) // don't panic
+ return 1;
+ // some theme add marginTop/marginBottom to tabs
+ var cStyle = window.getComputedStyle(aTab, null);
+ var marginTop = parseInt(cStyle["marginTop"]) || 0;
+ var marginBottom = parseInt(cStyle["marginBottom"]) || 0;
+ height += marginTop + marginBottom;
+
+ var tabBottom = top - marginTop + height;
+ return Math.round((tabBottom - aTop)/height);
}
};
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index 3605d50..bbaa682 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -363,8 +363,8 @@
// we must adjustNewtabButtonvisibility before get lastTabRowNumber
Tabmix.tabsUtils.adjustNewtabButtonvisibility();
let visibleRows = TabmixTabbar.visibleRows;
- // this.lastTabRowNumber is null when we hide the tabbar
- let rows = aReset || this.childNodes.length == 1 ? 1 : (this.lastTabRowNumber || 1);
+ // Tabmix.tabsUtils.lastTabRowNumber is null when we hide the tabbar
+ let rows = aReset || this.childNodes.length == 1 ? 1 : (Tabmix.tabsUtils.lastTabRowNumber || 1);
let currentMultibar = this.getAttribute("multibar") || null;
let maxRow = Tabmix.prefs.getIntPref("tabBarMaxRow");
@@ -374,7 +374,7 @@
// try to scroll all the way up
this.mTabstrip.scrollByPixels((rows - maxRow) * this.mTabstrip.singleRowHeight);
// get lastTabRowNumber after the scroll
- rows = this.lastTabRowNumber;
+ rows = Tabmix.tabsUtils.lastTabRowNumber;
}
let multibar;
@@ -461,37 +461,6 @@
<property name="canScrollTabsRight" readonly="true"
onget="return !this.mTabstrip._scrollButtonDown.disabled;"/>
- <property name="topTabY" readonly="true">
- <getter><![CDATA[
- return Tabmix.tabsUtils.tabstripInnerbox.boxObject.y +
- Tabmix.getStyle(Tabmix.tabsUtils.tabstripInnerbox, "paddingTop");
- ]]></getter>
- </property>
-
- <property name="lastTabRowNumber" readonly="true">
- <getter><![CDATA[
- return this.getTabRowNumber(Tabmix.visibleTabs.last, this.topTabY);
- ]]></getter>
- </property>
-
- <method name="getTabRowNumber">
- <parameter name="aTab"/>
- <parameter name="aTop"/>
- <body><![CDATA[
-/*XXX we can use aTab.getBoundingClientRect().top if we do the same in topTabY */
- var height = aTab ? aTab.boxObject.height : 0;
- if (height == 0) // don't panic
- return 1;
- // some theme add marginTop/marginBottom to tabs
- var cStyle = window.getComputedStyle(aTab, null);
- var marginTop = parseInt(cStyle["marginTop"]) || 0;
- var marginBottom = parseInt(cStyle["marginBottom"]) || 0;
- height += marginTop + marginBottom;
-
- var tabBottom = aTab.boxObject.y - marginTop + height;
- return Math.round((tabBottom - aTop)/height);
- ]]></body>
- </method>
<method name="_notifyBackgroundTab">
<parameter name="aTab"/>
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 544c594..d54af74 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -874,7 +874,7 @@ var TMP_eventListener = {
var tabBar = gBrowser.tabContainer;
function _updateTabstrip() {
if (tabBar.getAttribute("multibar") == "true" &&
- tabBar.lastTabRowNumber < TabmixTabbar.visibleRows)
+ Tabmix.tabsUtils.lastTabRowNumber < TabmixTabbar.visibleRows)
tabBar.updateVerticalTabStrip();
TabmixTabbar.updateBeforeAndAfter();
}
--
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