Control debug prints via preferences
This commit is contained in:
parent
5bdda35fe6
commit
de777e7ff2
@ -703,3 +703,11 @@ pref("extensions.treestyletab.compatibility.TotalToolbar", true);
|
||||
*/
|
||||
pref("extensions.treestyletab.prefsVersion", 0);
|
||||
|
||||
/**
|
||||
* Flags to activate debug dumps for each module.
|
||||
*/
|
||||
pref("extensions.treestyletab.debug.all", false);
|
||||
pref("extensions.treestyletab.debug.autoHide", false);
|
||||
pref("extensions.treestyletab.debug.browser", false);
|
||||
pref("extensions.treestyletab.debug.browserUIShowHideObserver", false);
|
||||
pref("extensions.treestyletab.debug.tabbarDNDObserver", false);
|
||||
|
@ -36,8 +36,6 @@
|
||||
|
||||
var EXPORTED_SYMBOLS = ['AutoHideBrowser', 'AutoHideWindow'];
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
@ -503,7 +501,7 @@ AutoHideBrowser.prototype = inherit(AutoHideBase.prototype, {
|
||||
showHideOnMouseMove : function AHB_showHideOnMouseMove(aCoordinates)
|
||||
{
|
||||
var position = this.getMousePosition(aCoordinates);
|
||||
if (DEBUG) {
|
||||
if (utils.isDebugging('autoHide')) {
|
||||
let humanReadablePosition = [];
|
||||
if (position & this.MOUSE_POSITION_OUTSIDE)
|
||||
humanReadablePosition.push('outside');
|
||||
@ -839,7 +837,7 @@ AutoHideBrowser.prototype = inherit(AutoHideBase.prototype, {
|
||||
this.showHideReason = aReason || this.showHideReason || this.kSHOWN_BY_UNKNOWN;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
if (utils.isDebugging('autoHide')) {
|
||||
let givenReason = this._getHumanReadableReason(aReason);
|
||||
let unifiedReason = this._getHumanReadableReason(this.showHideReason);
|
||||
if (this.expanded)
|
||||
|
@ -38,8 +38,6 @@
|
||||
|
||||
var EXPORTED_SYMBOLS = ['TreeStyleTabBrowser'];
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
@ -1952,7 +1950,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
{
|
||||
aReason = aReason || this.kTABBAR_UPDATE_BY_UNKNOWN_REASON;
|
||||
|
||||
if (DEBUG) {
|
||||
if (utils.isDebugging('browser')) {
|
||||
let humanReadableReason =
|
||||
(aReason & this.kTABBAR_UPDATE_BY_RESET ? 'reset ' : '' ) +
|
||||
(aReason & this.kTABBAR_UPDATE_BY_PREF_CHANGE ? 'prefchange ' : '' ) +
|
||||
@ -3228,7 +3226,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
var closeParentBehavior = this.getCloseParentBehaviorForTab(tab);
|
||||
|
||||
var backupAttributes = this._collectBackupAttributes(tab);
|
||||
if (DEBUG)
|
||||
if (utils.isDebugging('browser'))
|
||||
dump('onTabClose: backupAttributes = '+JSON.stringify(backupAttributes)+'\n');
|
||||
|
||||
if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN ||
|
||||
@ -3893,7 +3891,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
handleRestoredTab : function TSTBrowser_handleRestoredTab(aTab)
|
||||
{
|
||||
if (aTab.__treestyletab__restoreState === undefined) {
|
||||
if (DEBUG)
|
||||
if (utils.isDebugging('browser'))
|
||||
dump('handleRestoredTab: ' + aTab._tPos + ' is already restored!\n');
|
||||
return false;
|
||||
}
|
||||
@ -4122,7 +4120,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
var restoringMultipleTabs = this.windowService.restoringTree;
|
||||
var position = this._prepareInsertionPosition(aTab, aMayBeDuplicated);
|
||||
var parent = position.parent;
|
||||
if (DEBUG)
|
||||
if (utils.isDebugging('browser'))
|
||||
dump('handleRestoredTab: found parent = ' + parent+'\n');
|
||||
if (parent) {
|
||||
aTab.removeAttribute(this.kPARENT);
|
||||
@ -4169,7 +4167,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
}
|
||||
|
||||
var ancestors = (this.getTabValue(aTab, this.kANCESTORS) || this.getTabValue(aTab, this.kPARENT)).split('|');
|
||||
if (DEBUG)
|
||||
if (utils.isDebugging('browser'))
|
||||
dump('handleRestoredTab: ancestors = ' + ancestors+'\n');
|
||||
var parent = null;
|
||||
for (let i in ancestors)
|
||||
@ -4192,7 +4190,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
*/
|
||||
if (!parent) {
|
||||
parent = aTab.getAttribute(this.kPARENT);
|
||||
if (DEBUG)
|
||||
if (utils.isDebugging('browser'))
|
||||
dump('handleRestoredTab: parent = ' + parent+'\n');
|
||||
if (parent && !next)
|
||||
next = this.getNextSiblingTab(aTab);
|
||||
|
@ -36,8 +36,6 @@
|
||||
|
||||
var EXPORTED_SYMBOLS = ['BrowserUIShowHideObserver'];
|
||||
|
||||
var DEBUG = false;
|
||||
|
||||
Components.utils.import('resource://treestyletab-modules/constants.js');
|
||||
|
||||
function BrowserUIShowHideObserver(aOwner, aBox) {
|
||||
@ -63,7 +61,7 @@ BrowserUIShowHideObserver.prototype = {
|
||||
childList : true,
|
||||
attributes : true,
|
||||
subtree : true,
|
||||
attributeOldValue: DEBUG,
|
||||
attributeOldValue: utils.isDebugging('browserUIShowHideObserver'),
|
||||
attributeFilter : [
|
||||
'hidden',
|
||||
'collapsed',
|
||||
@ -149,7 +147,7 @@ BrowserUIShowHideObserver.prototype = {
|
||||
)
|
||||
return;
|
||||
|
||||
if (DEBUG) {
|
||||
if (utils.isDebugging('browserUIShowHideObserver')) {
|
||||
dump('BrowserUIShowHideObserver_onAttributeModified ' +
|
||||
target.localName + '#' + target.id + '.' + target.className + ', ' +
|
||||
aMutation.attributeName + ', ' +
|
||||
|
@ -35,8 +35,6 @@
|
||||
|
||||
var EXPORTED_SYMBOLS = ['ContentBridge'];
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
@ -37,8 +37,6 @@
|
||||
|
||||
var EXPORTED_SYMBOLS = ['TabbarDNDObserver'];
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
@ -262,7 +260,8 @@ catch(e) {
|
||||
|
||||
getDropActionInternal : function TabbarDND_getDropActionInternal(aEvent, aSourceTab)
|
||||
{
|
||||
if (DEBUG) dump('getDropActionInternal: start\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump('getDropActionInternal: start\n');
|
||||
var sv = this.treeStyleTab;
|
||||
var b = this.browser;
|
||||
var d = this.document;
|
||||
@ -303,18 +302,21 @@ catch(e) {
|
||||
var isNewTabAction = !aSourceTab || aSourceTab.ownerDocument != d;
|
||||
|
||||
if (!tab || tab.localName != 'tab') {
|
||||
if (DEBUG) dump(' not on a tab\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' not on a tab\n');
|
||||
let action = isTabMoveFromOtherWindow ? sv.kACTION_STAY : (sv.kACTION_MOVE | sv.kACTION_PART) ;
|
||||
if (isNewTabAction) action |= sv.kACTION_NEWTAB;
|
||||
if (aEvent[sv.screenPositionProp] < sv.getTabActualScreenPosition(firstTab)) {
|
||||
if (DEBUG) dump(' above the first tab\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' above the first tab\n');
|
||||
info.target = info.parent = info.insertBefore = firstTab;
|
||||
info.position = isInverted ? sv.kDROP_AFTER : sv.kDROP_BEFORE ;
|
||||
info.action = action;
|
||||
return info;
|
||||
}
|
||||
else if (aEvent[sv.screenPositionProp] > sv.getTabActualScreenPosition(tabs[lastTabIndex]) + tabs[lastTabIndex].boxObject[sv.sizeProp]) {
|
||||
if (DEBUG) dump(' below the last tab\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' below the last tab\n');
|
||||
info.target = info.parent = tabs[lastTabIndex];
|
||||
info.position = isInverted ? sv.kDROP_BEFORE : sv.kDROP_AFTER ;
|
||||
info.action = action;
|
||||
@ -324,25 +326,30 @@ catch(e) {
|
||||
let index = b.getNewIndex ?
|
||||
b.getNewIndex(aEvent) :
|
||||
b.tabContainer._getDropIndex(aEvent) ;
|
||||
if (DEBUG) dump(' on the tab '+index+'\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' on the tab '+index+'\n');
|
||||
index = Math.min(index, lastTabIndex);
|
||||
info.target = tab = tabs[index];
|
||||
if (index == tabs[lastTabIndex]._tPos) {
|
||||
if (index > 0)
|
||||
info.target = tab = tabs[index - 1];
|
||||
info.position = sv.kDROP_AFTER;
|
||||
if (DEBUG) dump(' => after the last tab\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' => after the last tab\n');
|
||||
} else if (index == firstTab._tPos) {
|
||||
if (index < lastTabIndex - 1)
|
||||
info.target = tab = tabs[index + 1];
|
||||
info.position = sv.kDROP_BEFORE;
|
||||
if (DEBUG) dump(' => before the first tab\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' => before the first tab\n');
|
||||
}
|
||||
if (DEBUG) dump(' info.target = ' + info.target._tPos + '\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' info.target = ' + info.target._tPos + '\n');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (DEBUG) dump(' on the tab '+tab._tPos+'\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' on the tab '+tab._tPos+'\n');
|
||||
sv.ensureTabInitialized(tab);
|
||||
info.target = tab;
|
||||
}
|
||||
@ -378,18 +385,21 @@ catch(e) {
|
||||
switch (info.position)
|
||||
{
|
||||
case sv.kDROP_ON:
|
||||
if (DEBUG) dump(' position = on the tab\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' position = on the tab\n');
|
||||
var visible = sv.getNextVisibleTab(tab);
|
||||
info.action = sv.kACTION_STAY | sv.kACTION_ATTACH;
|
||||
info.parent = tab;
|
||||
info.insertBefore = utils.getTreePref('insertNewChildAt') == sv.kINSERT_FISRT ?
|
||||
(sv.getFirstChildTab(tab) || visible) :
|
||||
(sv.getNextSiblingTab(tab) || sv.getNextTab(sv.getLastDescendantTab(tab) || tab));
|
||||
if (DEBUG && info.insertBefore) dump(' insertBefore = '+info.insertBefore._tPos+'\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver') && info.insertBefore)
|
||||
dump(' insertBefore = '+info.insertBefore._tPos+'\n');
|
||||
break;
|
||||
|
||||
case sv.kDROP_BEFORE:
|
||||
if (DEBUG) dump(' position = before the tab\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' position = before the tab\n');
|
||||
/*
|
||||
<= detach from parent, and move
|
||||
[TARGET ]
|
||||
@ -425,11 +435,13 @@ catch(e) {
|
||||
info.action = sv.kACTION_MOVE | (info.parent ? sv.kACTION_ATTACH : sv.kACTION_PART );
|
||||
info.insertBefore = tab;
|
||||
}
|
||||
if (DEBUG && info.insertBefore) dump(' insertBefore = '+info.insertBefore._tPos+'\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver') && info.insertBefore)
|
||||
dump(' insertBefore = '+info.insertBefore._tPos+'\n');
|
||||
break;
|
||||
|
||||
case sv.kDROP_AFTER:
|
||||
if (DEBUG) dump(' position = after the tab\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' position = after the tab\n');
|
||||
/*
|
||||
[TARGET ]
|
||||
<= if the target has a parent, attach to it and and move
|
||||
@ -473,7 +485,8 @@ catch(e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DEBUG && info.insertBefore) dump(' insertBefore = '+info.insertBefore._tPos+'\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver') && info.insertBefore)
|
||||
dump(' insertBefore = '+info.insertBefore._tPos+'\n');
|
||||
break;
|
||||
}
|
||||
|
||||
@ -484,14 +497,16 @@ catch(e) {
|
||||
|
||||
performDrop : function TabbarDND_performDrop(aInfo, aDraggedTab)
|
||||
{
|
||||
if (DEBUG) dump('performDrop: start\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump('performDrop: start\n');
|
||||
var sv = this.treeStyleTab;
|
||||
var b = this.browser;
|
||||
var w = this.window;
|
||||
|
||||
var tabsInfo = this.getDraggedTabsInfoFromOneTab(aDraggedTab, aInfo);
|
||||
if (!tabsInfo.draggedTab) {
|
||||
if (DEBUG) dump(' => no dragged tab\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' => no dragged tab\n');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -548,7 +563,8 @@ catch(e) {
|
||||
sourceBrowser == targetBrowser &&
|
||||
sourceService.getNextVisibleTab(draggedTabs[draggedTabs.length-1]) == aInfo.insertBefore
|
||||
) {
|
||||
if (DEBUG) dump(' => no change\n');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' => no change\n');
|
||||
// then, do nothing
|
||||
return true;
|
||||
}
|
||||
|
@ -230,6 +230,11 @@ var TreeStyleTabUtils = {
|
||||
this.setTreePref('prefsVersion', TST_PREF_VERSION);
|
||||
},
|
||||
|
||||
isDebugging : function utils_isDebugging(aModule)
|
||||
{
|
||||
return this.getTreePref('debug.' + aModule) || this.getTreePref('debug.all');
|
||||
},
|
||||
|
||||
/* string bundle */
|
||||
get treeBundle () {
|
||||
return stringBundle.get('chrome://treestyletab/locale/treestyletab.properties');
|
||||
|
Loading…
Reference in New Issue
Block a user