[Pkg-mozext-commits] [tabmixplus] 109/123: Improve compatibility with Vertical Tabs extension. Vertical Tabs override our gBrowser.tabContainer binding.
David Prévot
taffit at moszumanska.debian.org
Wed Sep 17 21:16:32 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 5047eb5ad6b7b10246ecaa03584324e0437398ed
Author: onemen <tabmix.onemen at gmail.com>
Date: Mon Sep 15 16:38:47 2014 +0300
Improve compatibility with Vertical Tabs extension. Vertical Tabs override our gBrowser.tabContainer binding.
---
chrome/content/click/click.js | 2 +-
chrome/content/minit/minit.js | 9 ++++--
chrome/content/minit/tablib.js | 8 ++---
chrome/content/preferences/appearance.js | 2 +-
chrome/content/tab/scrollbox.xml | 21 ++++++++++++++
chrome/content/tab/tab.js | 40 +++++++++++++++++++++----
chrome/content/tab/tabbrowser_4.xml | 50 +-------------------------------
chrome/content/tabmix.js | 8 ++---
8 files changed, 73 insertions(+), 67 deletions(-)
diff --git a/chrome/content/click/click.js b/chrome/content/click/click.js
index 637fcb9..fd5602d 100644
--- a/chrome/content/click/click.js
+++ b/chrome/content/click/click.js
@@ -471,7 +471,7 @@ var TabmixContext = {
var protectedTab = aTab.hasAttribute("protected");
var lockedTab = aTab.hasAttribute("locked");
var tabsCount = gBrowser.visibleTabs.length;
- var unpinnedTabs = tabsCount - gBrowser.tabContainer._real_numPinnedTabs;
+ var unpinnedTabs = tabsCount - TabmixTabbar._real_numPinnedTabs;
var cIndex = TMP_TabView.getIndexInVisibleTabsFromTab(aTab);
if (Tabmix.rtl)
cIndex = tabsCount - 1 - cIndex;
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index 4e4e499..5b6d162 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -21,6 +21,12 @@ var TMP_tabDNDObserver = {
init: function TMP_tabDNDObserver_init() {
var tabBar = gBrowser.tabContainer;
+ if (Tabmix.extensions.verticalTabBar) {
+ tabBar.useTabmixDragstart = function() false;
+ tabBar.useTabmixDnD = function() false;
+ return;
+ }
+
tabBar.moveTabOnDragging = Tabmix.prefs.getBoolPref("moveTabOnDragging");
// Determine what tab we're dragging over.
// * In tabmix tabs can have diffrent width
@@ -29,7 +35,6 @@ var TMP_tabDNDObserver = {
// is before (for dragging left) or after (for dragging right)
// the middle of a background tab, the dragged tab would take that
// tab's position when dropped.
- if (!Tabmix.extensions.treeStyleTab)
Tabmix.changeCode(tabBar, "gBrowser.tabContainer._animateTabMove")._replace(
'this.selectedItem = draggedTab;',
'if (Tabmix.prefs.getBoolPref("selectTabOnMouseDown"))\n\
@@ -109,7 +114,7 @@ var TMP_tabDNDObserver = {
tab.__tabmixDragStart = true;
this.draggedTab = tab;
tab.setAttribute("dragged", true);
- gBrowser.tabContainer.removeShowButtonAttr();
+ TabmixTabbar.removeShowButtonAttr();
let dt = event.dataTransfer;
dt.mozSetDataAt(TAB_DROP_TYPE, tab, 0);
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index effbc51..0ba46cf 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -172,7 +172,7 @@ var tablib = {
'{/* see TMP_BrowserOpenTab */}'
)._replace(
'this.tabContainer.adjustTabstrip();',
- 'if (!wasPinned) this.tabContainer.setFirstTabInRow();\
+ 'if (!wasPinned) TabmixTabbar.setFirstTabInRow();\
$&'
).toCode();
@@ -277,7 +277,7 @@ var tablib = {
if (!Tabmix.extensions.verticalTabs) {
Tabmix.changeCode(tabBar, "gBrowser.tabContainer._positionPinnedTabs")._replace(
'this.removeAttribute("positionpinnedtabs");',
- 'this.resetFirstTabInRow();\
+ 'this.mTabstrip.resetFirstTabInRow();\
$&'
)._replace(
/this.mTabstrip._scrollButtonDown.(scrollWidth|getBoundingClientRect\(\).width)/,
@@ -292,8 +292,8 @@ var tablib = {
' tab.style.MozMarginStart = width + "px";' +
' width += tab.getBoundingClientRect().width;' +
' }' +
- ' if (width != this.firstTabInRowMargin) {' +
- ' this.firstTabInRowMargin = width;' +
+ ' if (width != this.mTabstrip.firstTabInRowMargin) {' +
+ ' this.mTabstrip.firstTabInRowMargin = width;' +
' this.mTabstrip.firstVisible = {tab: null, x: 0, y: 0};' +
' gTMPprefObserver.dynamicRules["tabmix-firstTabInRow"]' +
' .style.setProperty("-moz-margin-start", width + "px", null);' +
diff --git a/chrome/content/preferences/appearance.js b/chrome/content/preferences/appearance.js
index 7e89b0e..54a2612 100644
--- a/chrome/content/preferences/appearance.js
+++ b/chrome/content/preferences/appearance.js
@@ -117,7 +117,7 @@ var gAppearancePane = {
// Display > Tab bar
function updateDisabledState(buttonID, itemID, aEnable) {
let button = aWindow.document.getElementById(buttonID);
- let enablePosition = button && button.parentNode == aWindow.gBrowser.tabContainer._container;
+ let enablePosition = button && button.parentNode == aWindow.document.getElementById("TabsToolbar");
gPrefWindow.setDisabled(itemID, !enablePosition || null);
gPrefWindow.setDisabled("obs_" + itemID, !aEnable || !enablePosition || null);
}
diff --git a/chrome/content/tab/scrollbox.xml b/chrome/content/tab/scrollbox.xml
index 6318615..04908de 100644
--- a/chrome/content/tab/scrollbox.xml
+++ b/chrome/content/tab/scrollbox.xml
@@ -91,6 +91,10 @@
extends="chrome://global/content/bindings/scrollbox.xml#arrowscrollbox-clicktoscroll">
<implementation>
+ <!-- for Vertical Tabs extension -->
+ <property name="_verticalTabs" readonly="true"
+ onget="return this.orient == 'vertical';"/>
+
<field name="blockUnderflow">false</field>
<field name="blockOverflow">false</field>
@@ -492,6 +496,23 @@
]]></body>
</method>
+ <field name="firstTabInRowMargin">0</field>
+ <method name="resetFirstTabInRow">
+ <body><![CDATA[
+ if (this.firstTabInRowMargin == 0)
+ return;
+ this.firstTabInRowMargin = 0;
+ // getElementsByAttribute return a live nodList
+ // each time we remove the attribute we remove node from the list
+ let tabBar = document.getBindingParent(this);
+ let tabs = tabBar.getElementsByAttribute("tabmix-firstTabInRow" , "*");
+ for (let i = 0, num = tabs.length; i < num; i++) {
+ tabs[0].removeAttribute("tabmix-firstTabInRow");
+ }
+ this.firstVisible = {tab: null, x: 0, y: 0};
+ ]]></body>
+ </method>
+
<method name="updateOverflow">
<parameter name="overflow"/>
<body><![CDATA[
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index 1de34e9..ce79737 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -34,7 +34,7 @@ var TabmixTabbar = {
},
isButtonOnTabsToolBar: function(button) {
- return button && button.parentNode == gBrowser.tabContainer._container;
+ return button && button.parentNode == document.getElementById("TabsToolbar");
},
// get privateTab-toolbar-openNewPrivateTab, when the button is on the tabbar
@@ -90,7 +90,7 @@ var TabmixTabbar = {
Tabmix.setItem(tabmixScrollBox, "defaultScrollButtons", isDefault);
if (prevTabscroll == this.SCROLL_BUTTONS_MULTIROW) {
- tabBar.resetFirstTabInRow();
+ tabBar.mTabstrip.resetFirstTabInRow();
tabBar.updateVerticalTabStrip(true);
}
else if (isMultiRow && overflow) {
@@ -188,16 +188,16 @@ var TabmixTabbar = {
// so if widthFitTitle is false we need to call it if we actualy change the width
// for other chases we need to call it when we change title
if (tabBar.mTabstrip.orient == "vertical") {
- tabBar.setFirstTabInRow();
+ this.setFirstTabInRow();
tabBar.updateVerticalTabStrip();
}
// with Australis overflow not always trigger when tab changed width
else if (TabmixSvc.australis && !this.widthFitTitle) {
tabBar.mTabstrip._enterVerticalMode();
- tabBar.setFirstTabInRow();
+ this.setFirstTabInRow();
}
}
- else if (!this.isMultiRow)
+ else if (!this.isMultiRow && typeof tabBar.adjustNewtabButtonvisibility == "function")
tabBar.adjustNewtabButtonvisibility();
},
@@ -350,7 +350,7 @@ var TabmixTabbar = {
_handleResize: function TMP__handleResize() {
var tabBar = gBrowser.tabContainer;
if (this.isMultiRow) {
- tabBar.setFirstTabInRow();
+ this.setFirstTabInRow();
if (tabBar.mTabstrip.orient != "vertical")
tabBar.mTabstrip._enterVerticalMode();
else
@@ -522,6 +522,34 @@ var TabmixTabbar = {
var tabBar = gBrowser.tabContainer;
var top = tabBar.topTabY;
return tabBar.getTabRowNumber(tab1, top) == tabBar.getTabRowNumber(tab2, top);
+ },
+
+ setFirstTabInRow: function() {
+ var tabBar = gBrowser.tabContainer;
+ // call our tabstrip function only when we are in multi-row and
+ // in overflow with pinned tabs
+ if (this.isMultiRow && tabBar.overflow && tabBar.firstChild.pinned)
+ tabBar.mTabstrip.setFirstTabInRow();
+ },
+
+ removeShowButtonAttr: function() {
+ var tabBar = gBrowser.tabContainer;
+ if ("__showbuttonTab" in tabBar) {
+ tabBar.__showbuttonTab.removeAttribute("showbutton");
+ delete tabBar.__showbuttonTab;
+ }
+ },
+
+ get _real_numPinnedTabs() {
+ var count = 0;
+ for (let i = 0; i < gBrowser.tabs.length; i++) {
+ let tab = gBrowser.tabs[i];
+ if (!tab.pinned)
+ break;
+ if (!tab.closing)
+ count++;
+ }
+ return count;
}
} // TabmixTabbar end
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index afa7196..944eb17 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -459,31 +459,6 @@
]]>
</destructor>
- <method name="setFirstTabInRow">
- <body><![CDATA[
- // call our tabstrip function only when we are in multi-row and
- // in overflow with pinned tabs
- if (TabmixTabbar.isMultiRow && this.overflow && this.firstChild.pinned)
- this.mTabstrip.setFirstTabInRow();
- ]]></body>
- </method>
-
- <field name="firstTabInRowMargin">0</field>
- <method name="resetFirstTabInRow">
- <body><![CDATA[
- if (this.firstTabInRowMargin == 0)
- return;
- this.firstTabInRowMargin = 0;
- // getElementsByAttribute return a live nodList
- // each time we remove the attribute we remove node from the list
- let tabs = this.getElementsByAttribute("tabmix-firstTabInRow" , "*");
- for (let i = 0, num = tabs.length; i < num; i++) {
- tabs[0].removeAttribute("tabmix-firstTabInRow");
- }
- this.mTabstrip.firstVisible = {tab: null, x: 0, y: 0};
- ]]></body>
- </method>
-
<method name="updateVerticalTabStrip">
<parameter name="aReset"/>
<body><![CDATA[
@@ -726,21 +701,6 @@
]]></setter>
</property>
- <property name="_real_numPinnedTabs" readonly="true">
- <getter><![CDATA[
- var count = 0;
- for (let i = 0; i < this.childNodes.length; i++) {
- let tab = this.childNodes[i];
- if (!tab.pinned)
- break;
-
- if (!tab.closing)
- count++;
- }
- return count;
- ]]></getter>
- </property>
-
<property name="topTabY" readonly="true">
<getter><![CDATA[
return this.tabstripInnerbox.boxObject.y + Tabmix.getStyle(this.tabstripInnerbox, "paddingTop");
@@ -777,6 +737,7 @@
// https://addons.mozilla.org/EN-US/firefox/addon/vertical-tabs/
// verticalTabs 0.9.1+ is restartless.
if (typeof VerticalTabs == "object" && !Tabmix.extensions.verticalTabs) {
+ Tabmix.setItem("TabsToolbar", "collapsed", null);
Tabmix.extensions.verticalTabs = true;
Tabmix.extensions.verticalTabBar = true;
TabmixTabbar.updateSettings();
@@ -868,15 +829,6 @@
]]></body>
</method>
- <method name="removeShowButtonAttr">
- <body><![CDATA[
- if ("__showbuttonTab" in this) {
- this.__showbuttonTab.removeAttribute("showbutton");
- delete this.__showbuttonTab;
- }
- ]]></body>
- </method>
-
<!-- Deprecated stuff, implemented for backwards compatibility. -->
<method name="isTabVisible">
<parameter name="aIndex"/>
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index e89c37b..a16f306 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -731,7 +731,7 @@ var TMP_eventListener = {
Tabmix.tabsNewtabButton = null;
if (TabmixTabbar.isMultiRow) {
gBrowser.tabContainer.updateVerticalTabStrip();
- gBrowser.tabContainer.setFirstTabInRow();
+ TabmixTabbar.setFirstTabInRow();
TabmixTabbar.updateBeforeAndAfter();
}
},
@@ -920,7 +920,7 @@ var TMP_eventListener = {
// moveTabTo call _positionPinnedTabs when pinned tab moves
if (!tab.pinned)
- gBrowser.tabContainer.setFirstTabInRow();
+ TabmixTabbar.setFirstTabInRow();
TabmixSessionManager.tabMoved(tab, aEvent.detail, tab._tPos);
TabmixTabbar.updateBeforeAndAfter();
@@ -946,7 +946,7 @@ var TMP_eventListener = {
return;
}
var tabBar = gBrowser.tabContainer;
- tabBar.removeShowButtonAttr();
+ TabmixTabbar.removeShowButtonAttr();
let shouldMoveFocus = scrollTabs == 1;
if (aEvent.shiftKey)
@@ -1155,7 +1155,7 @@ Tabmix.initialization = {
if (!stopInitialization) {
let tabBrowser = arguments.length > 1 ? arguments[1] : gBrowser;
- stopInitialization = typeof tabBrowser.tabContainer.setFirstTabInRow != "function";
+ stopInitialization = typeof tabBrowser.tabContainer.updateVerticalTabStrip != "function";
}
if (stopInitialization) {
--
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