[Pkg-mozext-commits] [tabmixplus] 04/73: Use Tabmix.callerTrace instead of isCallerInList, getCallerNameByIndex and callerName
David Prévot
taffit at moszumanska.debian.org
Mon May 9 02:30:49 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 bcbe7aba945f7798b2f7e4c1a39c5cac4313c6f4
Author: onemen <tabmix.onemen at gmail.com>
Date: Wed Mar 23 08:46:50 2016 +0200
Use Tabmix.callerTrace instead of isCallerInList, getCallerNameByIndex and callerName
---
chrome/content/links/setup.js | 2 +-
chrome/content/minit/tablib.js | 12 ++++++------
chrome/content/places/places.js | 13 +++++++------
chrome/content/tab/tab.js | 4 ++--
modules/Places.jsm | 4 ++--
modules/log.jsm | 32 ++++++++++++++------------------
6 files changed, 32 insertions(+), 35 deletions(-)
diff --git a/chrome/content/links/setup.js b/chrome/content/links/setup.js
index 97e9628..59f7972 100644
--- a/chrome/content/links/setup.js
+++ b/chrome/content/links/setup.js
@@ -341,7 +341,7 @@ Tabmix.adjustTabstrip = function tabContainer_adjustTabstrip(skipUpdateScrollSta
* Don't use return in this function
* TreeStyleTabe add some code at the end
*/
- let transitionend = Tabmix.callerName() == "onxbltransitionend";
+ let transitionend = Tabmix.callerTrace("onxbltransitionend");
if (tabsCount == 1) {
let tab = this.selectedItem;
if (!aUrl) {
diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index ffc0993..1d27cb4 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -499,7 +499,7 @@ var tablib = { // eslint-disable-line
// before our mousedown handler can prevent it
Tabmix.changeCode(tabBar, "gBrowser.tabContainer._selectNewTab")._replace(
'{',
- '{if(!Tabmix.prefs.getBoolPref("selectTabOnMouseDown") && Tabmix.isCallerInList("onxblmousedown")) return;'
+ '{if(!Tabmix.prefs.getBoolPref("selectTabOnMouseDown") && Tabmix.callerTrace("onxblmousedown")) return;'
).toCode();
Tabmix.changeCode(tabBar, "gBrowser.tabContainer.visible", {setter: true})._replace(
@@ -574,7 +574,7 @@ var tablib = { // eslint-disable-line
let result = Tabmix.originalFunctions.duplicateTabIn.apply(this, arguments);
if (where != window) {
- let pref = Tabmix.isCallerInList("gotoHistoryIndex", "BrowserForward", "BrowserBack") ?
+ let pref = Tabmix.callerTrace("gotoHistoryIndex", "BrowserForward", "BrowserBack") ?
"openTabNext" : "openDuplicateNext";
let newTab = gBrowser.getTabForLastPanel();
if (Tabmix.prefs.getBoolPref(pref)) {
@@ -786,7 +786,7 @@ var tablib = { // eslint-disable-line
Tabmix.changeCode(window, "goQuitApplication")._replace(
'var appStartup',
- 'let closedtByToolkit = Tabmix.isCallerInList("toolkitCloseallOnUnload");' +
+ 'let closedtByToolkit = Tabmix.callerTrace("toolkitCloseallOnUnload");' +
'if (!TabmixSessionManager.canQuitApplication(closedtByToolkit))' +
' return false;' +
'$&'
@@ -1460,8 +1460,9 @@ var tablib = { // eslint-disable-line
let warnAboutClosingTabs = function(whatToClose, aTab, aDomain) {
// see tablib.closeWindow comment
- if (Tabmix.isCallerInList("BG__onQuitRequest"))
+ if (Tabmix.callerTrace("BG__onQuitRequest")) {
return true;
+ }
var closing = this.closingTabsEnum;
// try to cach call from other extensions to warnAboutClosingTabs (before Firefox 24)
if (typeof (whatToClose) == "boolean")
@@ -1865,8 +1866,7 @@ var tablib = { // eslint-disable-line
// we always show our prompt on Mac
var showPrompt = TabmixSvc.isMac || !isAfterFirefoxPrompt();
// get caller caller name and make sure we are not on restart
- var quitType = Tabmix.getCallerNameByIndex(2);
- var askBeforSave = quitType != "restartApp" && quitType != "restart";
+ var askBeforSave = !Tabmix.callerTrace("restartApp", "restart");
var isLastWindow = Tabmix.isLastBrowserWindow;
var result = TabmixSessionManager.deinit(isLastWindow, askBeforSave);
var canClose = result.canClose;
diff --git a/chrome/content/places/places.js b/chrome/content/places/places.js
index e78ceaf..fd19b6a 100644
--- a/chrome/content/places/places.js
+++ b/chrome/content/places/places.js
@@ -63,7 +63,7 @@ var TMP_Places = {
let $LF = '\n ';
Tabmix.changeCode(PlacesCommandHook, "uniqueCurrentPages", {getter: true})._replace(
'URIs.push(tab.linkedBrowser.currentURI);',
- 'if (Tabmix.getCallerNameByIndex(2) == "PCH_updateBookmarkAllTabsCommand") {' + $LF +
+ 'if (Tabmix.callerTrace("PCH_updateBookmarkAllTabsCommand")) {' + $LF +
' $&' + $LF +
'} else {' + $LF +
' let uri = tab.linkedBrowser.currentURI;' + $LF +
@@ -683,11 +683,12 @@ Tabmix.onContentLoaded = {
)._replace(
'return shift ? "tabshifted" : "tab";',
'{' + $LF +
+ 'let callerTrace = Tabmix.callerTrace();' + $LF +
'let list = ["openUILink", "handleLinkClick", "TMP_tabshifted", "TMP_contentLinkClick"];' + $LF +
- 'let pref = Tabmix.isCallerInList(list) ?' + $LF +
+ 'let pref = callerTrace.contain(list) ?' + $LF +
' "extensions.tabmix.inversefocusLinks" : "extensions.tabmix.inversefocusOther";' + $LF +
'let notOneClickSearch = !getBoolPref("browser.search.showOneOffButtons", false) ||' + $LF +
- ' Tabmix.callerName() != "onPopupClick";' + $LF +
+ ' !callerTrace.contain("onPopupClick");' + $LF +
'if (notOneClickSearch && getBoolPref(pref, true))' + $LF +
' shift = !shift;' + $LF +
'$&' + $LF +
@@ -703,11 +704,11 @@ Tabmix.onContentLoaded = {
Tabmix.changeCode(fnObj, fnName)._replace(
'{',
'{\n' +
- ' let tabmixCaller = Tabmix.getCallerNameByIndex(2);\n' +
- ' if (tabmixCaller == "BG_observe") {\n' +
+ ' let callerTrace = Tabmix.callerTrace();\n' +
+ ' if (callerTrace.contain("BG_observe")) {\n' +
' params.inBackground = getBoolPref("browser.tabs.loadInBackground");\n' +
' } else if (where == "current" &&\n' +
- ' tabmixCaller == "ReaderParent.toggleReaderMode") {\n' +
+ ' callerTrace.contain("ReaderParent.toggleReaderMode")) {\n' +
' gBrowser.selectedBrowser.tabmix_allowLoad = true;\n' +
' }\n'
)._replace(
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index 966281c..78fb5de 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -826,8 +826,8 @@ Tabmix.tabsUtils = {
Services.prefs.getBoolPref("browser.tabs.animate")) {
// after 250ms new tab is fully opened
if (!this.adjustNewtabButtonTimeout) {
- let timeout = 250, callerName = Tabmix.callerName();
- if (callerName == "onxbloverflow") {
+ let timeout = 250;
+ if (Tabmix.callerTrace("onxbloverflow")) {
let timeFromLastTabOpened = Date.now() - Tabmix._lastTabOpenedTime;
if (timeFromLastTabOpened < 250)
timeout = 0;
diff --git a/modules/Places.jsm b/modules/Places.jsm
index 0596589..eb6f417 100644
--- a/modules/Places.jsm
+++ b/modules/Places.jsm
@@ -181,9 +181,9 @@ PlacesUtilsInternal = {
' if (TMP_Event) aWhere = TMP_Places.isBookmarklet(aNode.uri) ? "current" :\n' +
' TMP_Places.fixWhereToOpen(TMP_Event, aWhere);\n' +
' else if (aWhere == "current" && !TMP_Places.isBookmarklet(aNode.uri)) {\n' +
- ' let caller = browserWindow.Tabmix.getCallerNameByIndex(2);\n' +
- ' if (caller != "PC_doCommand")\n' +
+ ' if (!browserWindow.Tabmix.callerTrace("PC_doCommand")) {\n' +
' aWhere = TMP_Places.fixWhereToOpen(null, aWhere);\n' +
+ ' }\n' +
' }\n' +
' }\n' +
' if (browserWindow && aWhere == "current")\n' +
diff --git a/modules/log.jsm b/modules/log.jsm
index 9bc9ed7..cb04e5d 100644
--- a/modules/log.jsm
+++ b/modules/log.jsm
@@ -135,20 +135,6 @@ this.console = {
return fnName;
},
-/*
- _nameFromComponentsStack: function(Cs) {
- return Cs.name ||
- Cs.filename.substr(Cs.filename.lastIndexOf("/") + 1) + ":" + Cs.lineNumber;
- },
-
- callerName: function() {
- try {
- var name = this._nameFromComponentsStack(Components.stack.caller.caller);
- } catch (ex) { }
- return name || "";
- },
-*/
-
callerName: function TMP_console_callerName() {
return this.getCallerNameByIndex(1);
},
@@ -177,14 +163,24 @@ this.console = {
return false;
},
- callerTrace: function TMP_console_callerTrace() {
- let stack = this._getStackExcludingInternal().join("\n");
+ callerTrace: function TMP_console_callerTrace(...args) {
+ let stack = this._getStackExcludingInternal();
- return {
+ let stackUtil = {
contain: function(...names) {
- return names.some(name => stack.indexOf(name) > -1);
+ if (Array.isArray(names[0])) {
+ names = names[0];
+ }
+ let _isCallerInList = function(caller) {
+ return names.some(name => caller.startsWith(name + "@"));
+ };
+ return stack.some(_isCallerInList);
},
};
+ if (args.length) {
+ return stackUtil.contain.apply(null, args);
+ }
+ return stackUtil;
},
/*
--
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