[Pkg-mozext-commits] [tabmixplus] 08/73: Update compatibility with treeStyleTab - instruct treeStyleTab to use 'kNEWTAB_OPEN_AS_NEXT_SIBLING' when our preference is to open the tab next
David Prévot
taffit at moszumanska.debian.org
Mon May 9 02:30:50 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit 7946718b1c599903d1647d3a2a2def37971a2a77
Author: onemen <tabmix.onemen at gmail.com>
Date: Wed Mar 23 11:46:54 2016 +0200
Update compatibility with treeStyleTab - instruct treeStyleTab to use 'kNEWTAB_OPEN_AS_NEXT_SIBLING' when our preference is to open the tab next
---
chrome/content/extensions/extensions.js | 43 +++++++++++++++++++++++++++++----
chrome/content/links/userInterface.js | 12 ++++-----
chrome/content/minit/minit.js | 11 +++++++--
chrome/content/minit/tablib.js | 40 ++++++++++++++++++------------
4 files changed, 77 insertions(+), 29 deletions(-)
diff --git a/chrome/content/extensions/extensions.js b/chrome/content/extensions/extensions.js
index 8f4aed7..8badcb9 100644
--- a/chrome/content/extensions/extensions.js
+++ b/chrome/content/extensions/extensions.js
@@ -77,6 +77,7 @@ var TMP_extensionsCompatibility = {
try {
if ("TreeStyleTabService" in window) {
this.treeStyleTab.onContentLoaded();
+ this.treeStyleTab.installed = true;
Tabmix.extensions.treeStyleTab = true;
Tabmix.extensions.verticalTabBar = true;
}
@@ -566,6 +567,7 @@ TMP_extensionsCompatibility.newsfox = {
* https://addons.mozilla.org/en-US/firefox/addon/tree-style-tab/
*/
TMP_extensionsCompatibility.treeStyleTab = {
+ installed: false,
errorMsg: "Error in Tabmix when trying to load compatible functions with TreeStyleTab extension",
preInit: function() {
@@ -766,10 +768,41 @@ TMP_extensionsCompatibility.treeStyleTab = {
'TreeStyleTabService.readyToOpenChildTab(gBrowser, true); $1 TreeStyleTabService.stopToOpenChildTab(gBrowser);'
).toCode();
}
+ },
- Tabmix.changeCode(window, "window.TMP_BrowserOpenTab")._replace(
- 'var newTab = gBrowser.addTab',
- 'gBrowser.treeStyleTab.onBeforeNewTabCommand();\n $&'
- ).toCode();
- }
+ onBeforeNewTabCommand: function(tab, openTabNext) {
+ if (!this.installed) {
+ return;
+ }
+ if (openTabNext) {
+ this.openNewTabNext(tab, true);
+ } else {
+ gBrowser.treeStyleTab.onBeforeNewTabCommand();
+ }
+ },
+
+ // instruct treeStyleTab to use 'kNEWTAB_OPEN_AS_NEXT_SIBLING' when our preference
+ // is to open the tab next
+ openNewTabNext: function(tab, openTabNext, clean) {
+ if (!this.installed || !openTabNext) {
+ return;
+ }
+
+ let tst = gBrowser.treeStyleTab;
+ let browser = tst.getBrowserFromTabBrowserElements(tab);
+ if (!browser) {
+ return;
+ }
+ let baseTab = tst.getTabFromBrowser(browser, tst.getTabBrowserFromChild(browser));
+
+ // clean previously ready state set by treeStyleTab
+ if (clean) {
+ tst.stopToOpenChildTab(baseTab);
+ let parentTab = tst.getParentTab(baseTab);
+ if (parentTab) {
+ tst.stopToOpenChildTab(parentTab);
+ }
+ }
+ tst.readyToOpenNextSiblingTabNow(baseTab);
+ },
};
diff --git a/chrome/content/links/userInterface.js b/chrome/content/links/userInterface.js
index b3d3ad7..a944536 100644
--- a/chrome/content/links/userInterface.js
+++ b/chrome/content/links/userInterface.js
@@ -158,6 +158,10 @@ function TMP_BrowserOpenTab(aTab, replaceLastTab) {
TabmixSvc.prefs.get("extensions.privateTab.makeNewEmptyTabsPrivate", 0) === 0) {
privateTab.readyToOpenTab(false);
}
+
+ let baseTab = aTab && aTab.localName == "tab" ? aTab : null;
+ let openTabNext = baseTab || !replaceLastTab && Tabmix.prefs.getBoolPref("openNewTabNext");
+ TMP_extensionsCompatibility.treeStyleTab.onBeforeNewTabCommand(baseTab || selectedTab, openTabNext);
var newTab = gBrowser.addTab(url, {
charset: loadBlank ? null : gBrowser.selectedBrowser.characterSet,
ownerTab: loadInBackground ? null : selectedTab,
@@ -176,12 +180,8 @@ function TMP_BrowserOpenTab(aTab, replaceLastTab) {
}
}
- if (aTab && aTab.localName == "tab")
- gBrowser.moveTabTo(newTab, aTab._tPos + 1);
- else if (!replaceLastTab && Tabmix.prefs.getBoolPref("openNewTabNext")) {
- // we used to move tab after lastRelatedTab but we don't need it on new tabs
- // and it mess with recently used tabs order
- gBrowser.moveTabTo(newTab, selectedTab._tPos + 1);
+ if (openTabNext) {
+ gBrowser.moveTabTo(newTab, (baseTab || selectedTab)._tPos + 1);
}
// make sure to update recently used tabs
// if user open many tabs quickly select event don't have time to fire
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index 5ac92ad..6365e26 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -1191,6 +1191,7 @@ Tabmix.navToolbox = {
Tabmix.originalFunctions.oldHandleCommand.toString().indexOf(TMP_fn) > -1)
return;
+ let $LF = "\n ";
// we don't do anything regarding IeTab and URL Suffix extensions
Tabmix.changeCode(obj, "gURLBar." + fn, {silent: this.urlBarInitialized})._replace(
'{',
@@ -1218,8 +1219,14 @@ Tabmix.navToolbox = {
'(where == "current" || !isMouseEvent && !loadNewTab && /^tab/.test(where))'
)._replace(
'openUILinkIn(url, where, params);',
- 'params.inBackground = Tabmix.prefs.getBoolPref("loadUrlInBackground");\
- $&'
+ 'params.inBackground = Tabmix.prefs.getBoolPref("loadUrlInBackground");' + $LF +
+ 'if (/^tab/.test(where)) {' + $LF +
+ ' let openTabNext = Tabmix.prefs.getBoolPref("openTabNext") &&' + $LF +
+ ' !Services.prefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent");' + $LF +
+ ' TMP_extensionsCompatibility.treeStyleTab' + $LF +
+ ' .openNewTabNext(gBrowser.selectedTab, openTabNext);' + $LF +
+ '}' + $LF +
+ '$&'
).toCode();
// don't call ChangeCode.isValidToChange after urlbar initialized,
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index 2270a32..7492066 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -571,22 +571,28 @@ var tablib = { // eslint-disable-line
arguments[1] = "tabshifted";
}
+ if (where == window) {
+ return Tabmix.originalFunctions.duplicateTabIn.apply(this, arguments);
+ }
+
+ let pref = Tabmix.callerTrace("gotoHistoryIndex", "BrowserForward", "BrowserBack") ?
+ "openTabNext" : "openDuplicateNext";
+ let openTabNext = Tabmix.prefs.getBoolPref(pref);
+ TMP_extensionsCompatibility.treeStyleTab.openNewTabNext(aTab, openTabNext, true);
+
let result = Tabmix.originalFunctions.duplicateTabIn.apply(this, arguments);
- if (where != window) {
- let pref = Tabmix.callerTrace("gotoHistoryIndex", "BrowserForward", "BrowserBack") ?
- "openTabNext" : "openDuplicateNext";
- let newTab = gBrowser.getTabForLastPanel();
- if (Tabmix.prefs.getBoolPref(pref)) {
- let pos = newTab._tPos > aTab._tPos ? 1 : 0;
- gBrowser.moveTabTo(newTab, aTab._tPos + pos);
- }
- let bgLoad = Tabmix.prefs.getBoolPref("loadDuplicateInBackground");
- let selectNewTab = where == "tab" ? !bgLoad : bgLoad;
- if (selectNewTab) {
- gBrowser.selectedTab = newTab;
- }
+ let newTab = gBrowser.getTabForLastPanel();
+ if (openTabNext) {
+ let pos = newTab._tPos > aTab._tPos ? 1 : 0;
+ gBrowser.moveTabTo(newTab, aTab._tPos + pos);
+ }
+ let bgLoad = Tabmix.prefs.getBoolPref("loadDuplicateInBackground");
+ let selectNewTab = where == "tab" ? !bgLoad : bgLoad;
+ if (selectNewTab) {
+ gBrowser.selectedTab = newTab;
}
+
return result;
};
@@ -934,8 +940,11 @@ var tablib = { // eslint-disable-line
aTab = this.mCurrentTab;
var newTab = null;
- // try to have SessionStore duplicate the given tab
+ let copyToNewWindow = window != aTab.ownerDocument.defaultView;
+ let openDuplicateNext = !disallowSelect && !copyToNewWindow && Tabmix.prefs.getBoolPref("openDuplicateNext");
+ TMP_extensionsCompatibility.treeStyleTab.openNewTabNext(aTab, openDuplicateNext);
+ // try to have SessionStore duplicate the given tab
if (!aHref && !aTabData) {
newTab = TabmixSvc.ss.duplicateTab(window, aTab, 0);
} else {
@@ -952,8 +961,7 @@ var tablib = { // eslint-disable-line
this.selectedBrowser.focus();
// move new tab to place before we select it
- var copyToNewWindow = window != aTab.ownerDocument.defaultView;
- if (!disallowSelect && !copyToNewWindow && Tabmix.prefs.getBoolPref("openDuplicateNext")) {
+ if (openDuplicateNext) {
let pos = newTab._tPos > aTab._tPos ? 1 : 0;
this.moveTabTo(newTab, aTab._tPos + pos);
}
--
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