Output more debug messages

This commit is contained in:
Piro / YUKI Hiroshi 2015-11-28 02:23:03 +09:00
parent 1b815f963c
commit 191bb0ce26

View File

@ -75,6 +75,11 @@ function wait(aMilliSeconds) {
}); });
} }
function mydump(aString) {
if (utils.isDebugging('browser'))
dump(aString);
}
Cu.import('resource://treestyletab-modules/window.js'); Cu.import('resource://treestyletab-modules/window.js');
function TreeStyleTabBrowser(aWindowService, aTabBrowser) function TreeStyleTabBrowser(aWindowService, aTabBrowser)
@ -1948,7 +1953,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
{ {
aReason = aReason || this.kTABBAR_UPDATE_BY_UNKNOWN_REASON; aReason = aReason || this.kTABBAR_UPDATE_BY_UNKNOWN_REASON;
if (utils.isDebugging('browser')) { {
let humanReadableReason = let humanReadableReason =
(aReason & this.kTABBAR_UPDATE_BY_RESET ? 'reset ' : '' ) + (aReason & this.kTABBAR_UPDATE_BY_RESET ? 'reset ' : '' ) +
(aReason & this.kTABBAR_UPDATE_BY_PREF_CHANGE ? 'prefchange ' : '' ) + (aReason & this.kTABBAR_UPDATE_BY_PREF_CHANGE ? 'prefchange ' : '' ) +
@ -1960,7 +1965,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
(aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE ? 'autohide ' : '' ) + (aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE ? 'autohide ' : '' ) +
(aReason & this.kTABBAR_UPDATE_BY_INITIALIZE ? 'initialize ' : '' ) + (aReason & this.kTABBAR_UPDATE_BY_INITIALIZE ? 'initialize ' : '' ) +
(aReason & this.kTABBAR_UPDATE_BY_TOGGLE_SIDEBAR ? 'toggle-sidebar ' : '' ); (aReason & this.kTABBAR_UPDATE_BY_TOGGLE_SIDEBAR ? 'toggle-sidebar ' : '' );
dump('TSTBrowser_updateFloatingTabbarInternal: ' + humanReadableReason + '\n'); mydump('TSTBrowser_updateFloatingTabbarInternal: ' + humanReadableReason + '\n');
} }
var d = this.document; var d = this.document;
@ -3150,14 +3155,12 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var pareintIndexInTree = hasStructure ? this.treeStructure.shift() : 0 ; var pareintIndexInTree = hasStructure ? this.treeStructure.shift() : 0 ;
var lastRelatedTab = b._lastRelatedTab; var lastRelatedTab = b._lastRelatedTab;
if (utils.isDebugging('browser')) { mydump('TSTBrowser_onTabOpen\n ' + [
dump('TSTBrowser_onTabOpen\n ' + [
'readiedToAttachNewTab: '+this.readiedToAttachNewTab, 'readiedToAttachNewTab: '+this.readiedToAttachNewTab,
'parentTab: '+this.parentTab + ' (' + this.getTabById(this.parentTab) + ')', 'parentTab: '+this.parentTab + ' (' + this.getTabById(this.parentTab) + ')',
'insertBefore: '+this.insertBefore, 'insertBefore: '+this.insertBefore,
'treeStructure: '+this.treeStructure 'treeStructure: '+this.treeStructure
].join('\n ') + '\n'); ].join('\n ') + '\n');
}
if (this.readiedToAttachNewTab) { if (this.readiedToAttachNewTab) {
if (pareintIndexInTree < 0) { // there is no parent, so this is a new parent! if (pareintIndexInTree < 0) { // there is no parent, so this is a new parent!
@ -3340,8 +3343,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var closeParentBehavior = this.getCloseParentBehaviorForTab(tab); var closeParentBehavior = this.getCloseParentBehaviorForTab(tab);
var backupAttributes = this._collectBackupAttributes(tab); var backupAttributes = this._collectBackupAttributes(tab);
if (utils.isDebugging('browser')) mydump('onTabClose: backupAttributes = '+JSON.stringify(backupAttributes)+'\n');
dump('onTabClose: backupAttributes = '+JSON.stringify(backupAttributes)+'\n');
if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN || if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN ||
this.isSubtreeCollapsed(tab)) this.isSubtreeCollapsed(tab))
@ -3658,10 +3660,8 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
delta = Math.abs(pos - oldPos); delta = Math.abs(pos - oldPos);
} }
if (utils.isDebugging('browser')) { mydump('attachTabFromPosition '+aTab._tPos+' / '+aOldPosition+'\n');
dump('attachTabFromPosition '+aTab._tPos+' / '+aOldPosition+'\n'); mydump((new Error()).stack.replace(/^/gm, ' ')+'\n');
dump((new Error()).stack.replace(/^/gm, ' ')+'\n');
}
var prevTab = this.getPreviousTab(aTab); var prevTab = this.getPreviousTab(aTab);
var nextTab = this.getNextTab(aTab); var nextTab = this.getNextTab(aTab);
@ -3679,25 +3679,32 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var newParent; var newParent;
if (!prevTab) { // moved to topmost position if (!prevTab) {
mydump(' => moved to topmost position\n');
newParent = null; newParent = null;
} }
else if (!nextTab) { // moved to last position else if (!nextTab) {
mydump(' => movedmoved to last position\n');
newParent = (delta > 1) ? prevParent : parent ; newParent = (delta > 1) ? prevParent : parent ;
} }
else if (prevParent == nextParent) { // moved into existing tree else if (prevParent == nextParent) {
mydump(' => moved into existing tree\n');
newParent = prevParent; newParent = prevParent;
} }
else if (prevLevel > nextLevel) { // moved to end of existing tree else if (prevLevel > nextLevel) {
if (this.mTabBrowser.selectedTab != aTab) { // maybe newly opened tab mydump(' => moved to end of existing tree\n');
if (this.mTabBrowser.selectedTab != aTab) {
mydump(' => maybe newly opened tab\n');
newParent = prevParent; newParent = prevParent;
} }
else { // maybe drag and drop else {
mydump(' => maybe drag and drop\n');
var realDelta = Math.abs(aTab._tPos - aOldPosition); var realDelta = Math.abs(aTab._tPos - aOldPosition);
newParent = realDelta < 2 ? prevParent : (parent || nextParent) ; newParent = realDelta < 2 ? prevParent : (parent || nextParent) ;
} }
} }
else if (prevLevel < nextLevel) { // moved to first child position of existing tree else if (prevLevel < nextLevel) {
mydump(' => moved to first child position of existing tree\n');
newParent = parent || nextParent; newParent = parent || nextParent;
} }
@ -4012,8 +4019,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
handleRestoredTab : function TSTBrowser_handleRestoredTab(aTab) handleRestoredTab : function TSTBrowser_handleRestoredTab(aTab)
{ {
if (aTab.__treestyletab__restoreState === undefined) { if (aTab.__treestyletab__restoreState === undefined) {
if (utils.isDebugging('browser')) mydump('handleRestoredTab: ' + aTab._tPos + ' is already restored!\n');
dump('handleRestoredTab: ' + aTab._tPos + ' is already restored!\n');
return false; return false;
} }
@ -4241,8 +4247,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var restoringMultipleTabs = this.windowService.restoringTree; var restoringMultipleTabs = this.windowService.restoringTree;
var position = this._prepareInsertionPosition(aTab, aMayBeDuplicated); var position = this._prepareInsertionPosition(aTab, aMayBeDuplicated);
var parent = position.parent; var parent = position.parent;
if (utils.isDebugging('browser')) mydump('handleRestoredTab: found parent = ' + parent+'\n');
dump('handleRestoredTab: found parent = ' + parent+'\n');
if (parent) { if (parent) {
aTab.removeAttribute(this.kPARENT); aTab.removeAttribute(this.kPARENT);
parent = this.getTabById(parent); parent = this.getTabById(parent);
@ -4288,8 +4293,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
} }
var ancestors = (this.getTabValue(aTab, this.kANCESTORS) || this.getTabValue(aTab, this.kPARENT)).split('|'); var ancestors = (this.getTabValue(aTab, this.kANCESTORS) || this.getTabValue(aTab, this.kPARENT)).split('|');
if (utils.isDebugging('browser')) mydump('handleRestoredTab: ancestors = ' + ancestors+'\n');
dump('handleRestoredTab: ancestors = ' + ancestors+'\n');
var parent = null; var parent = null;
for (let i in ancestors) for (let i in ancestors)
{ {
@ -4311,8 +4315,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
*/ */
if (!parent) { if (!parent) {
parent = aTab.getAttribute(this.kPARENT); parent = aTab.getAttribute(this.kPARENT);
if (utils.isDebugging('browser')) mydump('handleRestoredTab: parent = ' + parent+'\n');
dump('handleRestoredTab: parent = ' + parent+'\n');
if (parent && !next) if (parent && !next)
next = this.getNextSiblingTab(aTab); next = this.getNextSiblingTab(aTab);
} }
@ -5068,11 +5071,9 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
} }
if (isContentResize || isChromeResize) { if (isContentResize || isChromeResize) {
if (utils.isDebugging('browser')) { mydump('TSTBrowser_onResize\n');
dump('TSTBrowser_onResize\n'); mydump(' isContentResize = '+isContentResize+'\n');
dump(' isContentResize = '+isContentResize+'\n'); mydump(' isChromeResize = '+isChromeResize+'\n');
dump(' isChromeResize = '+isChromeResize+'\n');
}
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_WINDOW_RESIZE); this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_WINDOW_RESIZE);
this.updateInvertedTabContentsOrder(true); this.updateInvertedTabContentsOrder(true);
this.mTabBrowser.mTabContainer.adjustTabstrip(); this.mTabBrowser.mTabContainer.adjustTabstrip();
@ -7010,11 +7011,9 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
Components.utils.reportError(new Error('There is no property named "_browserEpochs"!!')); Components.utils.reportError(new Error('There is no property named "_browserEpochs"!!'));
} }
if (utils.isDebugging('browser')) { mydump('TSTBrowser::restoreTree\n');
dump('TSTBrowser::restoreTree\n'); mydump(' level = '+level+'\n');
dump(' level = '+level+'\n'); mydump(' tabsToRestore = '+tabsToRestore+'\n');
dump(' tabsToRestore = '+tabsToRestore+'\n');
}
if ( if (
level <= this.kRESTORE_TREE_LEVEL_NONE || level <= this.kRESTORE_TREE_LEVEL_NONE ||
@ -7037,8 +7036,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
); );
}); });
if (utils.isDebugging('browser')) mydump(' restoring member tabs = '+tabs.length+' ('+tabs.map(function(aTab) { return aTab._tPos; })+')\n');
dump(' restoring member tabs = '+tabs.length+' ('+tabs.map(function(aTab) { return aTab._tPos; })+')\n');
if (tabs.length <= 1) if (tabs.length <= 1)
return; return;