Output debug log to the browser console also
This commit is contained in:
parent
120dc6b522
commit
e531d8cd93
@ -8,9 +8,11 @@ XPCOMUtils.defineLazyModuleGetter(this,
|
||||
let { ReferenceCounter } = Components.utils.import('resource://treestyletab-modules/ReferenceCounter.js', {});
|
||||
let { inherit } = Components.utils.import('resource://treestyletab-modules/lib/inherit.jsm', {});
|
||||
|
||||
function mydump(aString) {
|
||||
if (TreeStyleTabUtils.isDebugging('bookmark'))
|
||||
dump(aString);
|
||||
function log(...aArgs) {
|
||||
TreeStyleTabUtils.log.apply(utils, ['bookmark'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
TreeStyleTabUtils.logWithStackTrace.apply(utils, ['bookmark'].concat(aArgs));
|
||||
}
|
||||
|
||||
var TreeStyleTabBookmarksServiceEditable = inherit(TreeStyleTabBookmarksUIService, {
|
||||
@ -84,7 +86,7 @@ var TreeStyleTabBookmarksServiceEditable = inherit(TreeStyleTabBookmarksUIServic
|
||||
TreeStyleTabBookmarksServiceEditable.saveParentFor(gEditItemOverlay.itemId, true);
|
||||
}
|
||||
catch(e) {
|
||||
mydump(e+'\n');
|
||||
log(e);
|
||||
}
|
||||
return this.__treestyletab__onDialogAccept.apply(this, aArgs);
|
||||
};
|
||||
@ -92,7 +94,7 @@ var TreeStyleTabBookmarksServiceEditable = inherit(TreeStyleTabBookmarksUIServic
|
||||
BookmarkPropertiesPanel.__treestyletab__endBatch = BookmarkPropertiesPanel._endBatch;
|
||||
BookmarkPropertiesPanel._endBatch = function(...aArgs) {
|
||||
var id = this.__treestyletab__itemId || gEditItemOverlay.itemId;
|
||||
mydump('BookmarkPropertiesPanel._endBatch for '+id+'\n');
|
||||
log('BookmarkPropertiesPanel._endBatch for '+id);
|
||||
var batching = this._batching;
|
||||
var result = this.__treestyletab__endBatch.apply(this, aArgs);
|
||||
if (id >= 0 && !batching && !this._batching) {
|
||||
@ -101,7 +103,7 @@ var TreeStyleTabBookmarksServiceEditable = inherit(TreeStyleTabBookmarksUIServic
|
||||
TreeStyleTabBookmarksServiceEditable.saveParentFor(id, true);
|
||||
}
|
||||
catch(e) {
|
||||
mydump(e+'\n');
|
||||
log(e);
|
||||
}
|
||||
finally {
|
||||
this._batching = false;
|
||||
|
@ -57,6 +57,12 @@ XPCOMUtils.defineLazyGetter(this, 'prefs', function() {
|
||||
return window['piro.sakura.ne.jp'].prefs;
|
||||
});
|
||||
|
||||
function log(...aArgs) {
|
||||
utils.log.apply(utils, ['autoHide'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
utils.logWithStackTrace.apply(utils, ['autoHide'].concat(aArgs));
|
||||
}
|
||||
|
||||
var AutoHideConstants = Object.freeze(inherit(TreeStyleTabConstants, {
|
||||
kMODE : 'treestyletab-tabbar-autohide-mode',
|
||||
@ -570,11 +576,10 @@ AutoHideBrowser.prototype = inherit(AutoHideBase.prototype, {
|
||||
extraInfo.push('expanded-by-unknown');
|
||||
if (this.lastMouseDownTarget)
|
||||
extraInfo.push('mousedown');
|
||||
dump('showHideOnMouseMove: ' +
|
||||
log('showHideOnMouseMove: ' +
|
||||
'('+aCoordinates.screenX + ', ' + aCoordinates.screenY + ') => ' +
|
||||
humanReadablePosition.join(', ') +
|
||||
(extraInfo.length ? ('[' + extraInfo.join(', ') + ']') : '') +
|
||||
'\n');
|
||||
(extraInfo.length ? ('[' + extraInfo.join(', ') + ']') : ''));
|
||||
}
|
||||
|
||||
if (sv.isPopupShown() ||
|
||||
@ -905,10 +910,9 @@ AutoHideBrowser.prototype = inherit(AutoHideBase.prototype, {
|
||||
let givenReason = this._getHumanReadableReason(aReason);
|
||||
let unifiedReason = this._getHumanReadableReason(this.showHideReason);
|
||||
if (this.expanded)
|
||||
dump('autoHide: show by ' + aReason + '(' + givenReason + ' / ' + unifiedReason + ')\n');
|
||||
logWithStackTrace('autoHide: show by ' + aReason + '(' + givenReason + ' / ' + unifiedReason + ')');
|
||||
else
|
||||
dump('autoHide: hide by ' + aReason + '(' + givenReason + ' / ' + unifiedReason + ')\n');
|
||||
dump((new Error()).stack.replace(/^/gm, ' ').replace(/\s+$/, '') + '\n');
|
||||
logWithStackTrace('autoHide: hide by ' + aReason + '(' + givenReason + ' / ' + unifiedReason + ')');
|
||||
}
|
||||
|
||||
this.fireStateChangingEvent();
|
||||
|
@ -81,6 +81,13 @@ if (Services.appinfo.OS === 'WINNT') {
|
||||
else {
|
||||
this.AeroPeek = null;
|
||||
}
|
||||
|
||||
function log(...aArgs) {
|
||||
utils.log.apply(utils, ['base'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
utils.logWithStackTrace.apply(utils, ['base'].concat(aArgs));
|
||||
}
|
||||
|
||||
var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
|
||||
@ -148,8 +155,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
this.overrideExtensions();
|
||||
}
|
||||
catch(e) {
|
||||
if (utils.isDebugging('base'))
|
||||
dump(e+'\n');
|
||||
log(e);
|
||||
}
|
||||
},
|
||||
_initialized : false,
|
||||
@ -505,8 +511,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
|
||||
var message = 'ERROR: accessed after destruction!';
|
||||
var error = new Error(message);
|
||||
if (utils.isDebugging('base'))
|
||||
dump(message+'\n'+error.stack.replace(/^/gm, ' ')+'\n');
|
||||
logWithStackTrace(message);
|
||||
throw error;
|
||||
},
|
||||
|
||||
@ -877,10 +882,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
{
|
||||
var strip = this.tabStrip;
|
||||
if (!strip) {
|
||||
if (utils.isDebugging('base')) {
|
||||
dump('FAILED TO SET TABSTRIP ATTRIBUTE ' + aAttr + '=' + aValue + '\n');
|
||||
dump((new Error()).stack.replace(/^/gm, ' ') + '\n');
|
||||
}
|
||||
logWithStackTrace('FAILED TO SET TABSTRIP ATTRIBUTE ' + aAttr + '=' + aValue);
|
||||
return;
|
||||
}
|
||||
var isFeatureAttribute = aAttr.indexOf('treestyletab-') == 0;
|
||||
@ -1419,9 +1421,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
refId = aInsertBefore.getAttribute(this.kID);
|
||||
}
|
||||
|
||||
if (utils.isDebugging('base'))
|
||||
dump('Tree Style Tab: new child tab is requested.\n'+
|
||||
new Error().stack.replace(/^/gm, ' ')+'\n');
|
||||
logWithStackTrace('new child tab is requested.');
|
||||
|
||||
ownerBrowser.treeStyleTab.readiedToAttachNewTab = true;
|
||||
ownerBrowser.treeStyleTab.readiedToAttachMultiple = aMultiple || false ;
|
||||
@ -1460,9 +1460,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
|
||||
var ownerBrowser = this.getTabBrowserFromChild(browser);
|
||||
|
||||
if (utils.isDebugging('base'))
|
||||
dump('Tree Style Tab: new orphan tab is requested.\n'+
|
||||
new Error().stack.replace(/^/gm, ' ')+'\n');
|
||||
logWithStackTrace('new orphan tab is requested.');
|
||||
|
||||
ownerBrowser.treeStyleTab.readiedToAttachNewTab = false;
|
||||
|
||||
@ -1595,9 +1593,8 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
|
||||
var ownerBrowser = this.getTabBrowserFromChild(browser);
|
||||
|
||||
if (ownerBrowser.treeStyleTab.readiedToAttachNewTab && utils.isDebugging('base'))
|
||||
dump('Tree Style Tab: new child tab is canceled.\n'+
|
||||
new Error().stack.replace(/^/gm, ' ')+'\n');
|
||||
if (ownerBrowser.treeStyleTab.readiedToAttachNewTab)
|
||||
logWithStackTrace('new child tab is canceled.');
|
||||
|
||||
delete ownerBrowser.treeStyleTab.readiedToAttachNewTab;
|
||||
delete ownerBrowser.treeStyleTab.readiedToAttachNewTabGroup;
|
||||
@ -1790,8 +1787,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
aTab.label+'\n '+
|
||||
aTab.getAttribute(this.kID);
|
||||
}, this).join('\n');
|
||||
if (utils.isDebugging('base'))
|
||||
dump(message+'\n');
|
||||
log(message);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1803,8 +1799,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
aTab.label+'\n '+
|
||||
aTab.getAttribute(this.kID);
|
||||
}, this).join('\n');
|
||||
if (utils.isDebugging('base'))
|
||||
dump(message+'\n');
|
||||
log(message);
|
||||
}
|
||||
|
||||
tabs.push(parentTab);
|
||||
@ -1951,8 +1946,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
aTab.label+'\n '+
|
||||
aTab.getAttribute(this.kID);
|
||||
}, this).join('\n');
|
||||
if (utils.isDebugging('base'))
|
||||
dump(message+'\n');
|
||||
log(message);
|
||||
continue;
|
||||
}
|
||||
tabs.push(tab);
|
||||
|
@ -49,9 +49,11 @@ Cu.import('resource://treestyletab-modules/constants.js');
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
||||
|
||||
function mydump(aString) {
|
||||
if (utils.isDebugging('bookmark'))
|
||||
dump(aString);
|
||||
function log(...aArgs) {
|
||||
utils.log.apply(utils, ['bookmark'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
utils.logWithStackTrace.apply(utils, ['bookmark'].concat(aArgs));
|
||||
}
|
||||
|
||||
var TreeStyleTabBookmarksService = inherit(TreeStyleTabConstants, {
|
||||
@ -296,18 +298,18 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabConstants, {
|
||||
|
||||
result.behavior = TST.openGroupBookmarkBehavior();
|
||||
if (result.behavior & this.kGROUP_BOOKMARK_SUBTREE) {
|
||||
mydump('TSTBMService_handleTabsOpenProcess: open as a group\n');
|
||||
log('handleTabsOpenProcess: open as a group');
|
||||
let treeStructure = result.behavior & this.kGROUP_BOOKMARK_DONT_RESTORE_TREE_STRUCTURE ?
|
||||
null :
|
||||
this.getTreeStructureFromItems(aIDs) ;
|
||||
mydump(' treeStructure => '+JSON.stringify(treeStructure)+'\n');
|
||||
log(' treeStructure => '+JSON.stringify(treeStructure));
|
||||
if (treeStructure) {
|
||||
let parentTabs = treeStructure.filter(function(aParent) {
|
||||
return aParent < 0;
|
||||
});
|
||||
let haveMultipleTrees = parentTabs.length != treeStructure.length;
|
||||
if (result.behavior & this.kGROUP_BOOKMARK_USE_DUMMY) {
|
||||
mydump(' trying to use dummy group tab\n');
|
||||
log(' trying to use dummy group tab');
|
||||
let parentCount = 0;
|
||||
let childCount = 0;
|
||||
for (let i in treeStructure) {
|
||||
@ -316,8 +318,8 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabConstants, {
|
||||
else
|
||||
childCount++;
|
||||
}
|
||||
mydump(' parentCount: '+parentCount+'\n');
|
||||
mydump(' childCount: '+childCount+'\n');
|
||||
log(' parentCount: '+parentCount);
|
||||
log(' childCount: '+childCount);
|
||||
if (
|
||||
parentCount > 1 &&
|
||||
(
|
||||
@ -338,7 +340,7 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabConstants, {
|
||||
title: aFolderTitle,
|
||||
uri: uri
|
||||
})
|
||||
mydump(' updated treeStructure => '+JSON.stringify(treeStructure)+'\n');
|
||||
log(' updated treeStructure => '+JSON.stringify(treeStructure));
|
||||
}
|
||||
}
|
||||
else if (!haveMultipleTrees) {
|
||||
@ -388,7 +390,7 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabConstants, {
|
||||
|
||||
PlacesUIUtils.__treestyletab__openTabset = PlacesUIUtils._openTabset;
|
||||
PlacesUIUtils._openTabset = function(aItemsToOpen, aEvent, aWindow, ...aArgs) {
|
||||
mydump('TSTBookmarks_openTabset\n');
|
||||
log('TSTBookmarks_openTabset');
|
||||
|
||||
var uris = [];
|
||||
var ids = [];
|
||||
@ -400,12 +402,12 @@ PlacesUIUtils._openTabset = function(aItemsToOpen, aEvent, aWindow, ...aArgs) {
|
||||
if (!id && aIndex in nodes)
|
||||
id = nodes[aIndex].itemId;
|
||||
ids.push(id);
|
||||
mydump(' '+aIndex+': '+id+' / '+aItem.uri+'\n');
|
||||
log(' '+aIndex+': '+id+' / '+aItem.uri);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
mydump(' items => '+aItemsToOpen.length+'\n');
|
||||
log(' items => '+aItemsToOpen.length);
|
||||
|
||||
var allArgs = [aItemsToOpen, aEvent, aWindow].concat(aArgs);
|
||||
if (aItemsToOpen.length <= 0)
|
||||
@ -418,17 +420,17 @@ PlacesUIUtils._openTabset = function(aItemsToOpen, aEvent, aWindow, ...aArgs) {
|
||||
var BS = TreeStyleTabBookmarksService;
|
||||
|
||||
var where = w && w.whereToOpenLink(aEvent, false, true) || 'window';
|
||||
mydump(' where: '+where+'\n');
|
||||
log(' where: '+where);
|
||||
if (where === 'window')
|
||||
return this.__treestyletab__openTabset.apply(this, allArgs);
|
||||
|
||||
var result = BS.handleTabsOpenProcess(where, aEvent, w, ids, uris, aItemsToOpen, this.__treestyletab__folderName);
|
||||
mydump(' result: '+JSON.stringify(result)+'\n');
|
||||
log(' result: '+JSON.stringify(result));
|
||||
|
||||
var tabs = TST.doAndGetNewTabs((function() {
|
||||
this.__treestyletab__openTabset.apply(this, allArgs);
|
||||
}).bind(this), w.gBrowser);
|
||||
mydump(' tabs: '+tabs.length+'\n');
|
||||
log(' tabs: '+tabs.length);
|
||||
|
||||
if (!result.treeStructure)
|
||||
tabs = [];
|
||||
|
@ -75,9 +75,11 @@ function wait(aMilliSeconds) {
|
||||
});
|
||||
}
|
||||
|
||||
function mydump(aString) {
|
||||
if (utils.isDebugging('browser'))
|
||||
dump(aString);
|
||||
function log(...aArgs) {
|
||||
utils.log.apply(utils, ['browser'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
utils.logWithStackTrace.apply(utils, ['browser'].concat(aArgs));
|
||||
}
|
||||
|
||||
Cu.import('resource://treestyletab-modules/window.js');
|
||||
@ -1974,7 +1976,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
(aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE ? 'autohide ' : '' ) +
|
||||
(aReason & this.kTABBAR_UPDATE_BY_INITIALIZE ? 'initialize ' : '' ) +
|
||||
(aReason & this.kTABBAR_UPDATE_BY_TOGGLE_SIDEBAR ? 'toggle-sidebar ' : '' );
|
||||
mydump('TSTBrowser_updateFloatingTabbarInternal: ' + humanReadableReason + '\n');
|
||||
log('updateFloatingTabbarInternal: ' + humanReadableReason);
|
||||
}
|
||||
|
||||
var d = this.document;
|
||||
@ -3168,20 +3170,20 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
var pareintIndexInTree = hasStructure ? this.treeStructure.shift() : 0 ;
|
||||
var lastRelatedTab = b._lastRelatedTab;
|
||||
|
||||
mydump('TSTBrowser_onTabOpen\n ' + [
|
||||
log('onTabOpen\n ' + [
|
||||
'readiedToAttachNewTab: '+this.readiedToAttachNewTab,
|
||||
'parentTab: '+this.parentTab + ' (' + this.getTabById(this.parentTab) + ')',
|
||||
'insertBefore: '+this.insertBefore,
|
||||
'treeStructure: '+this.treeStructure
|
||||
].join('\n ') + '\n');
|
||||
].join('\n '));
|
||||
|
||||
if (typeof this.readiedToAttachNewTab !== 'boolean') {
|
||||
this.window.setTimeout((function() {
|
||||
if (!tab.owner)
|
||||
return;
|
||||
mydump('TSTBrowser_onTabOpen: new child tab opened by browser.tabs.insertRelatedAfterCurrent=true\n');
|
||||
log('onTabOpen: new child tab opened by browser.tabs.insertRelatedAfterCurrent=true');
|
||||
var nextTab = this.findNextTabForNewChild(tab, tab.owner);
|
||||
mydump(' next tab: '+(nextTab && nextTab._tPos)+'\n');
|
||||
log(' next tab: '+(nextTab && nextTab._tPos));
|
||||
this.attachTabTo(tab, tab.owner, {
|
||||
insertBefore: nextTab
|
||||
});
|
||||
@ -3403,7 +3405,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
var closeParentBehavior = this.getCloseParentBehaviorForTab(tab);
|
||||
|
||||
var backupAttributes = this._collectBackupAttributes(tab);
|
||||
mydump('onTabClose: backupAttributes = '+JSON.stringify(backupAttributes)+'\n');
|
||||
log('onTabClose: backupAttributes = '+JSON.stringify(backupAttributes));
|
||||
|
||||
if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN ||
|
||||
this.isSubtreeCollapsed(tab))
|
||||
@ -3631,7 +3633,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
|
||||
var prevPosition = aEvent.detail;
|
||||
if (tab.__treestyletab__isOpening && !this.isTabInternallyMoving(tab)) {
|
||||
mydump('onTabMove for new child tab: move back '+tab._tPos+' => '+prevPosition+'\n');
|
||||
log('onTabMove for new child tab: move back '+tab._tPos+' => '+prevPosition);
|
||||
tab.__treestyletab__internallyTabMovingCount++;
|
||||
b.moveTabTo(tab, prevPosition);
|
||||
tab.__treestyletab__internallyTabMovingCount--;
|
||||
@ -3639,8 +3641,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
}
|
||||
|
||||
tab.__treestyletab__previousPosition = prevPosition;
|
||||
mydump('onTabMove '+prevPosition+' => '+tab._tPos+' (internal moving count='+tab.__treestyletab__internallyTabMovingCount+', owner='+String(tab.owner)+')\n');
|
||||
mydump((new Error()).stack.replace(/^/gm, ' ')+'\n');
|
||||
logWithStackTrace('onTabMove '+prevPosition+' => '+tab._tPos+' (internal moving count='+tab.__treestyletab__internallyTabMovingCount+', owner='+String(tab.owner)+')');
|
||||
|
||||
// When the tab was moved before TabOpen event is fired, we have to update manually.
|
||||
var newlyOpened = !this.isTabInitialized(tab) && this.onTabOpen(null, tab);
|
||||
@ -3663,11 +3664,11 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
if (storedId && tab.getAttribute(this.kID) != storedId)
|
||||
restored = this.onTabRestoring(aEvent);
|
||||
}
|
||||
mydump(' newlyOpened: '+newlyOpened+'\n');
|
||||
mydump(' restored: '+restored+'\n');
|
||||
log(' newlyOpened: '+newlyOpened);
|
||||
log(' restored: '+restored);
|
||||
|
||||
if (this.hasChildTabs(tab) && !this.subTreeMovingCount) {
|
||||
mydump(' => move sub tree\n');
|
||||
log(' => move sub tree');
|
||||
this.moveTabSubtreeTo(tab, tab._tPos);
|
||||
}
|
||||
|
||||
@ -3703,7 +3704,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
if (!this.subTreeChildrenMovingCount)
|
||||
this.updateChildrenArray(parentTab);
|
||||
}
|
||||
mydump(' tabsToBeUpdated: '+tabsToBeUpdated.map(function(aTab) { return aTab._tPos; })+'\n');
|
||||
log(' tabsToBeUpdated: '+tabsToBeUpdated.map(function(aTab) { return aTab._tPos; }));
|
||||
|
||||
var updatedTabs = new WeakMap();
|
||||
tabsToBeUpdated.forEach(function(aTab) {
|
||||
@ -3736,7 +3737,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
|
||||
attachTabFromPosition : function TSTBrowser_attachTabFromPosition(aTab, aOldPosition)
|
||||
{
|
||||
mydump('attachTabFromPosition '+aOldPosition+' => '+aTab._tPos+'\n');
|
||||
log('attachTabFromPosition '+aOldPosition+' => '+aTab._tPos);
|
||||
var parent = this.getParentTab(aTab);
|
||||
|
||||
if (aOldPosition === void(0))
|
||||
@ -3747,7 +3748,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
var oldPos = this.getChildIndex(oldPositionTab, parent);
|
||||
var delta;
|
||||
if (oldPositionTab == aTab && pos == oldPos) { // no move?
|
||||
mydump(' => no move\n');
|
||||
log(' => no move');
|
||||
return;
|
||||
}
|
||||
else if (pos < 0 || oldPos < 0) {
|
||||
@ -3757,7 +3758,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
delta = Math.abs(pos - oldPos);
|
||||
}
|
||||
|
||||
mydump((new Error()).stack.replace(/^/gm, ' ')+'\n');
|
||||
logWithStackTrace(' moving');
|
||||
|
||||
var prevTab = this.getPreviousVisibleTab(aTab);
|
||||
var nextTab = this.getNextVisibleTab(aTab);
|
||||
@ -3766,45 +3767,45 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
if (tabs.length) {
|
||||
nextTab = this.getNextTab(tabs[tabs.length-1]);
|
||||
}
|
||||
mydump(' prevTab: '+(prevTab&&(prevTab._tPos+'('+prevTab.linkedBrowser.currentURI.spec+')'))+'\n');
|
||||
mydump(' nextTab: '+(nextTab&&(nextTab._tPos+'('+nextTab.linkedBrowser.currentURI.spec+')'))+'\n');
|
||||
log(' prevTab: '+(prevTab&&(prevTab._tPos+'('+prevTab.linkedBrowser.currentURI.spec+')')));
|
||||
log(' nextTab: '+(nextTab&&(nextTab._tPos+'('+nextTab.linkedBrowser.currentURI.spec+')')));
|
||||
|
||||
var prevParent = this.getParentTab(prevTab);
|
||||
var nextParent = this.getParentTab(nextTab);
|
||||
|
||||
var prevLevel = prevTab ? Number(prevTab.getAttribute(this.kNEST)) : -1 ;
|
||||
var nextLevel = nextTab ? Number(nextTab.getAttribute(this.kNEST)) : -1 ;
|
||||
mydump(' prevLevel: '+prevLevel+'\n');
|
||||
mydump(' nextLevel: '+nextLevel+'\n');
|
||||
log(' prevLevel: '+prevLevel);
|
||||
log(' nextLevel: '+nextLevel);
|
||||
|
||||
var newParent;
|
||||
|
||||
if (!prevTab) {
|
||||
mydump(' => moved to topmost position\n');
|
||||
log(' => moved to topmost position');
|
||||
newParent = null;
|
||||
}
|
||||
else if (!nextTab) {
|
||||
mydump(' => movedmoved to last position\n');
|
||||
log(' => movedmoved to last position');
|
||||
newParent = (delta > 1) ? prevParent : parent ;
|
||||
}
|
||||
else if (prevParent == nextParent) {
|
||||
mydump(' => moved into existing tree\n');
|
||||
log(' => moved into existing tree');
|
||||
newParent = prevParent;
|
||||
}
|
||||
else if (prevLevel > nextLevel) {
|
||||
mydump(' => moved to end of existing tree\n');
|
||||
log(' => moved to end of existing tree');
|
||||
if (this.mTabBrowser.selectedTab != aTab) {
|
||||
mydump(' => maybe newly opened tab\n');
|
||||
log(' => maybe newly opened tab');
|
||||
newParent = prevParent;
|
||||
}
|
||||
else {
|
||||
mydump(' => maybe drag and drop\n');
|
||||
log(' => maybe drag and drop');
|
||||
var realDelta = Math.abs(aTab._tPos - aOldPosition);
|
||||
newParent = realDelta < 2 ? prevParent : (parent || nextParent) ;
|
||||
}
|
||||
}
|
||||
else if (prevLevel < nextLevel) {
|
||||
mydump(' => moved to first child position of existing tree\n');
|
||||
log(' => moved to first child position of existing tree');
|
||||
newParent = prevTab || parent || nextParent;
|
||||
}
|
||||
|
||||
@ -4119,7 +4120,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
handleRestoredTab : function TSTBrowser_handleRestoredTab(aTab)
|
||||
{
|
||||
if (aTab.__treestyletab__restoreState === undefined) {
|
||||
mydump('handleRestoredTab: ' + aTab._tPos + ' is already restored!\n');
|
||||
log('handleRestoredTab: ' + aTab._tPos + ' is already restored!');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -4347,7 +4348,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
var restoringMultipleTabs = this.windowService.restoringTree;
|
||||
var position = this._prepareInsertionPosition(aTab, aMayBeDuplicated);
|
||||
var parent = position.parent;
|
||||
mydump('handleRestoredTab: found parent = ' + parent+'\n');
|
||||
log('handleRestoredTab: found parent = ' + parent);
|
||||
if (parent) {
|
||||
aTab.removeAttribute(this.kPARENT);
|
||||
parent = this.getTabById(parent);
|
||||
@ -4393,7 +4394,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
}
|
||||
|
||||
var ancestors = (this.getTabValue(aTab, this.kANCESTORS) || this.getTabValue(aTab, this.kPARENT)).split('|');
|
||||
mydump('handleRestoredTab: ancestors = ' + ancestors+'\n');
|
||||
log('handleRestoredTab: ancestors = ' + ancestors);
|
||||
var parent = null;
|
||||
for (let i in ancestors)
|
||||
{
|
||||
@ -4415,7 +4416,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
*/
|
||||
if (!parent) {
|
||||
parent = aTab.getAttribute(this.kPARENT);
|
||||
mydump('handleRestoredTab: parent = ' + parent+'\n');
|
||||
log('handleRestoredTab: parent = ' + parent);
|
||||
if (parent && !next)
|
||||
next = this.getNextSiblingTab(aTab);
|
||||
}
|
||||
@ -5171,9 +5172,9 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
}
|
||||
|
||||
if (isContentResize || isChromeResize) {
|
||||
mydump('TSTBrowser_onResize\n');
|
||||
mydump(' isContentResize = '+isContentResize+'\n');
|
||||
mydump(' isChromeResize = '+isChromeResize+'\n');
|
||||
log('TSTBrowser_onResize');
|
||||
log(' isContentResize = '+isContentResize);
|
||||
log(' isChromeResize = '+isChromeResize);
|
||||
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_WINDOW_RESIZE);
|
||||
this.updateInvertedTabContentsOrder(true);
|
||||
this.mTabBrowser.mTabContainer.adjustTabstrip();
|
||||
@ -5335,10 +5336,10 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
|
||||
onBeforeFullScreenToggle : function TSTBrowser_onBeforeFullScreenToggle(aEnterFS)
|
||||
{
|
||||
mydump('onBeforeFullScreenToggle / ' + this.position + '\n');
|
||||
log('onBeforeFullScreenToggle / ' + this.position);
|
||||
if (this.position != 'top') {
|
||||
mydump(' this.document.mozFullScreen => ' + this.document.mozFullScreen + '\n');
|
||||
mydump(' aEnterFS => ' + aEnterFS + '\n');
|
||||
log(' this.document.mozFullScreen => ' + this.document.mozFullScreen);
|
||||
log(' aEnterFS => ' + aEnterFS);
|
||||
// ignore entering to the DOM-fullscreen (ex. YouTube Player)
|
||||
if (!this.document.mozFullScreen) {
|
||||
if (aEnterFS)
|
||||
@ -7116,9 +7117,9 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
Components.utils.reportError(new Error('There is no property named "_browserEpochs"!!'));
|
||||
}
|
||||
|
||||
mydump('TSTBrowser::restoreTree\n');
|
||||
mydump(' level = '+level+'\n');
|
||||
mydump(' tabsToRestore = '+tabsToRestore+'\n');
|
||||
log('TSTBrowser::restoreTree');
|
||||
log(' level = '+level);
|
||||
log(' tabsToRestore = '+tabsToRestore);
|
||||
|
||||
if (
|
||||
level <= this.kRESTORE_TREE_LEVEL_NONE ||
|
||||
@ -7141,7 +7142,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
);
|
||||
});
|
||||
|
||||
mydump(' restoring member tabs = '+tabs.length+' ('+tabs.map(function(aTab) { return aTab._tPos; })+')\n');
|
||||
log(' restoring member tabs = '+tabs.length+' ('+tabs.map(function(aTab) { return aTab._tPos; })+')');
|
||||
|
||||
if (tabs.length <= 1)
|
||||
return;
|
||||
|
@ -42,6 +42,13 @@ Components.utils.import('resource://treestyletab-modules/constants.js');
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
||||
|
||||
function log(...aArgs) {
|
||||
utils.log.apply(utils, ['browserUIShowHideObserver'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
utils.logWithStackTrace.apply(utils, ['browserUIShowHideObserver'].concat(aArgs));
|
||||
}
|
||||
|
||||
function BrowserUIShowHideObserver(aOwner, aBox, aOptions) {
|
||||
this.owner = aOwner;
|
||||
this.box = aBox;
|
||||
@ -91,7 +98,7 @@ BrowserUIShowHideObserver.prototype = {
|
||||
{
|
||||
case 'childList':
|
||||
if (aMutation.target == this.box) {
|
||||
this.dumpMutation(aMutation, 'BrowserUIShowHideObserver_onMutation/childList');
|
||||
this.logMutation(aMutation, 'BrowserUIShowHideObserver_onMutation/childList');
|
||||
this.owner.browser.treeStyleTab.updateFloatingTabbar(TreeStyleTabConstants.kTABBAR_UPDATE_BY_WINDOW_RESIZE);
|
||||
}
|
||||
return;
|
||||
@ -102,7 +109,7 @@ BrowserUIShowHideObserver.prototype = {
|
||||
}
|
||||
}
|
||||
catch(error) {
|
||||
this.dumpMutation(aMutation, 'BrowserUIShowHideObserver_onMutation(error)');
|
||||
this.logMutation(aMutation, 'BrowserUIShowHideObserver_onMutation(error)');
|
||||
Components.utils.reportError(error);
|
||||
}
|
||||
}, this);
|
||||
@ -118,7 +125,7 @@ BrowserUIShowHideObserver.prototype = {
|
||||
delete this.owner;
|
||||
},
|
||||
|
||||
dumpMutation : function BrowserUIShowHideObserver_dumpMutation(aMutation, aDescription)
|
||||
logMutation : function BrowserUIShowHideObserver_logMutation(aMutation, aDescription)
|
||||
{
|
||||
if (!utils.isDebugging('browserUIShowHideObserver'))
|
||||
return;
|
||||
@ -132,10 +139,10 @@ BrowserUIShowHideObserver.prototype = {
|
||||
aMutation.attributeName + ', ' +
|
||||
aMutation.oldValue + ' => ' +
|
||||
target.getAttribute(aMutation.attributeName);
|
||||
dump(aDescription + ' ' +
|
||||
log(aDescription + ' ' +
|
||||
ownerInformation + ' / ' +
|
||||
targetInformation +
|
||||
attributeInformation + '\n');
|
||||
attributeInformation);
|
||||
},
|
||||
|
||||
onAttributeModified : function BrowserUIShowHideObserver_onAttributeModified(aMutation, aObserver)
|
||||
@ -220,7 +227,7 @@ BrowserUIShowHideObserver.prototype = {
|
||||
)
|
||||
return;
|
||||
|
||||
this.dumpMutation(aMutation, 'BrowserUIShowHideObserver_onAttributeModified');
|
||||
this.logMutation(aMutation, 'BrowserUIShowHideObserver_onAttributeModified');
|
||||
|
||||
this.handlingAttrChange = true;
|
||||
|
||||
|
@ -46,6 +46,13 @@ Cu.import('resource://gre/modules/Promise.jsm');
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
||||
|
||||
function log(...aArgs) {
|
||||
utils.log.apply(utils, ['contentBridge'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
utils.logWithStackTrace.apply(utils, ['contentBridge'].concat(aArgs));
|
||||
}
|
||||
|
||||
function ContentBridge(aTab, aTabBrowser)
|
||||
{
|
||||
this.init(aTab, aTabBrowser);
|
||||
@ -107,11 +114,9 @@ ContentBridge.prototype = inherit(TreeStyleTabConstants, {
|
||||
},
|
||||
handleMessage : function CB_handleMessage(aMessage)
|
||||
{
|
||||
if (utils.isDebugging('contentBridge')) {
|
||||
dump('*********************handleMessage*******************\n');
|
||||
dump('TARGET IS: '+aMessage.target.localName+'\n');
|
||||
dump(JSON.stringify(aMessage.json)+'\n');
|
||||
}
|
||||
log('*********************handleMessage*******************');
|
||||
log('TARGET IS: '+aMessage.target.localName);
|
||||
log(JSON.stringify(aMessage.json));
|
||||
|
||||
if (aMessage.target != this.mTab.linkedBrowser)
|
||||
return;
|
||||
|
@ -39,9 +39,11 @@ Components.utils.import('resource://treestyletab-modules/constants.js');
|
||||
|
||||
Components.utils.import('resource://treestyletab-modules/utils.js');
|
||||
|
||||
function mydump(aString) {
|
||||
if (TreeStyleTabUtils.isDebugging('fullscreenObserver'))
|
||||
dump(aString);
|
||||
function log(...aArgs) {
|
||||
TreeStyleTabUtils.log.apply(utils, ['fullscreenObserver'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
TreeStyleTabUtils.logWithStackTrace.apply(utils, ['fullscreenObserver'].concat(aArgs));
|
||||
}
|
||||
|
||||
function FullscreenObserver(aWindow) {
|
||||
@ -95,7 +97,7 @@ FullscreenObserver.prototype = {
|
||||
|
||||
onSizeModeChange : function FullscreenObserver_onSizeModeChange()
|
||||
{
|
||||
mydump('onSizeModeChange: '+this.window.document.documentElement.getAttribute('sizemode')+'\n');
|
||||
log('onSizeModeChange: '+this.window.document.documentElement.getAttribute('sizemode'));
|
||||
this.updateToolboxPosition();
|
||||
if (!this.window.gBrowser.treeStyleTab.notifyingRenderedEvent)
|
||||
this.window.gBrowser.treeStyleTab.updateFloatingTabbar(TreeStyleTabConstants.kTABBAR_UPDATE_BY_WINDOW_RESIZE);
|
||||
|
@ -63,6 +63,13 @@ const SSS = Cc['@mozilla.org/content/style-sheet-service;1']
|
||||
const SecMan = Cc['@mozilla.org/scriptsecuritymanager;1']
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
|
||||
function log(...aArgs) {
|
||||
utils.log.apply(utils, ['tabbarDNDObserver'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
utils.logWithStackTrace.apply(utils, ['tabbarDNDObserver'].concat(aArgs));
|
||||
}
|
||||
|
||||
function TabbarDNDObserver(aTabBrowser)
|
||||
{
|
||||
this.init(aTabBrowser);
|
||||
@ -187,8 +194,7 @@ try{
|
||||
return info.canDrop;
|
||||
}
|
||||
catch(e) {
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump('TabbarDND::canDrop\n'+e+'\n');
|
||||
log('canDrop', e);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
@ -262,8 +268,7 @@ catch(e) {
|
||||
|
||||
getDropActionInternal : function TabbarDND_getDropActionInternal(aEvent, aSourceTab)
|
||||
{
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump('getDropActionInternal: start\n');
|
||||
log('getDropActionInternal: start');
|
||||
var sv = this.treeStyleTab;
|
||||
var b = this.browser;
|
||||
var d = this.document;
|
||||
@ -304,21 +309,18 @@ catch(e) {
|
||||
var isNewTabAction = !aSourceTab || aSourceTab.ownerDocument != d;
|
||||
|
||||
if (!tab || tab.localName != 'tab') {
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' not on a tab\n');
|
||||
log(' not on a tab');
|
||||
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 (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' above the first tab\n');
|
||||
log(' above the first tab');
|
||||
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 (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' below the last tab\n');
|
||||
log(' below the last tab');
|
||||
info.target = info.parent = tabs[lastTabIndex];
|
||||
info.position = isInverted ? sv.kDROP_BEFORE : sv.kDROP_AFTER ;
|
||||
info.action = action;
|
||||
@ -328,30 +330,25 @@ catch(e) {
|
||||
let index = b.getNewIndex ?
|
||||
b.getNewIndex(aEvent) :
|
||||
b.tabContainer._getDropIndex(aEvent) ;
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' on the tab '+index+'\n');
|
||||
log(' on the tab '+index);
|
||||
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 (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' => after the last tab\n');
|
||||
log(' => after the last tab');
|
||||
} else if (index == firstTab._tPos) {
|
||||
if (index < lastTabIndex - 1)
|
||||
info.target = tab = tabs[index + 1];
|
||||
info.position = sv.kDROP_BEFORE;
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' => before the first tab\n');
|
||||
log(' => before the first tab');
|
||||
}
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' info.target = ' + info.target._tPos + '\n');
|
||||
log(' info.target = ' + info.target._tPos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' on the tab '+tab._tPos+'\n');
|
||||
log(' on the tab '+tab._tPos);
|
||||
sv.ensureTabInitialized(tab);
|
||||
info.target = tab;
|
||||
}
|
||||
@ -387,21 +384,19 @@ catch(e) {
|
||||
switch (info.position)
|
||||
{
|
||||
case sv.kDROP_ON:
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' position = on the tab\n');
|
||||
log(' position = on the tab');
|
||||
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 (utils.isDebugging('tabbarDNDObserver') && info.insertBefore)
|
||||
dump(' insertBefore = '+info.insertBefore._tPos+'\n');
|
||||
if (info.insertBefore)
|
||||
log(' insertBefore = '+info.insertBefore._tPos);
|
||||
break;
|
||||
|
||||
case sv.kDROP_BEFORE:
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' position = before the tab\n');
|
||||
log(' position = before the tab');
|
||||
/*
|
||||
<= detach from parent, and move
|
||||
[TARGET ]
|
||||
@ -437,13 +432,12 @@ catch(e) {
|
||||
info.action = sv.kACTION_MOVE | (info.parent ? sv.kACTION_ATTACH : sv.kACTION_PART );
|
||||
info.insertBefore = tab;
|
||||
}
|
||||
if (utils.isDebugging('tabbarDNDObserver') && info.insertBefore)
|
||||
dump(' insertBefore = '+info.insertBefore._tPos+'\n');
|
||||
if (info.insertBefore)
|
||||
log(' insertBefore = '+info.insertBefore._tPos);
|
||||
break;
|
||||
|
||||
case sv.kDROP_AFTER:
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' position = after the tab\n');
|
||||
log(' position = after the tab');
|
||||
/*
|
||||
[TARGET ]
|
||||
<= if the target has a parent, attach to it and and move
|
||||
@ -487,8 +481,8 @@ catch(e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (utils.isDebugging('tabbarDNDObserver') && info.insertBefore)
|
||||
dump(' insertBefore = '+info.insertBefore._tPos+'\n');
|
||||
if (info.insertBefore)
|
||||
log(' insertBefore = '+info.insertBefore._tPos);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -499,16 +493,14 @@ catch(e) {
|
||||
|
||||
performDrop : function TabbarDND_performDrop(aInfo, aDraggedTab)
|
||||
{
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump('performDrop: start\n');
|
||||
log('performDrop: start');
|
||||
var sv = this.treeStyleTab;
|
||||
var b = this.browser;
|
||||
var w = this.window;
|
||||
|
||||
var tabsInfo = this.getDraggedTabsInfoFromOneTab(aDraggedTab, aInfo);
|
||||
if (!tabsInfo.draggedTab) {
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' => no dragged tab\n');
|
||||
log(' => no dragged tab');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -565,8 +557,7 @@ catch(e) {
|
||||
sourceBrowser == targetBrowser &&
|
||||
sourceService.getNextVisibleTab(draggedTabs[draggedTabs.length-1]) == aInfo.insertBefore
|
||||
) {
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump(' => no change\n');
|
||||
log(' => no change');
|
||||
// then, do nothing
|
||||
return true;
|
||||
}
|
||||
@ -1053,8 +1044,7 @@ try{
|
||||
return (info.position == sv.kDROP_ON || sv.position != 'top')
|
||||
}
|
||||
catch(e) {
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump('TabbarDND::onDragOver\n'+e+'\n');
|
||||
log('onDragOver', e);
|
||||
}
|
||||
},
|
||||
|
||||
@ -1100,10 +1090,9 @@ catch(e) {
|
||||
|
||||
var draggedTab = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
|
||||
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump('TabbarDND::onDrop\n' +
|
||||
' dt.dropEffect: ' + dt.dropEffect + '\n' +
|
||||
' draggedTab: ' + draggedTab + '\n');
|
||||
log('TabbarDND::onDrop',
|
||||
' dt.dropEffect: ' + dt.dropEffect,
|
||||
' draggedTab: ' + draggedTab);
|
||||
|
||||
if (dt.dropEffect != 'link' &&
|
||||
dt.dropEffect != 'move' &&
|
||||
@ -1173,9 +1162,8 @@ catch(e) {
|
||||
if (aURI.indexOf(this.BOOKMARK_FOLDER) == 0) {
|
||||
let newTabs = sv.getNewTabsWithOperation(function() {
|
||||
var data = aURI.replace(self.BOOKMARK_FOLDER, '');
|
||||
if (utils.isDebugging('tabbarDNDObserver'))
|
||||
dump('TabbarDND::handleLinksOrBookmarks\n' +
|
||||
' bookmark folder data: ' + data + '\n');
|
||||
log('TabbarDND::handleLinksOrBookmarks' +
|
||||
' bookmark folder data: ' + data);
|
||||
data = JSON.parse(data);
|
||||
w.PlacesUIUtils._openTabset(data.children, { type : 'drop' }, w, data.title);
|
||||
}, b);
|
||||
|
@ -63,6 +63,8 @@ XPCOMUtils.defineLazyModuleGetter(this, 'Task',
|
||||
'resource://gre/modules/Task.jsm');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'Promise',
|
||||
'resource://gre/modules/Promise.jsm');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'Services',
|
||||
'resource://gre/modules/Services.jsm');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabConstants',
|
||||
'resource://treestyletab-modules/constants.js', 'TreeStyleTabConstants');
|
||||
|
||||
@ -250,6 +252,21 @@ var TreeStyleTabUtils = {
|
||||
return this.getTreePref('debug.' + aModule) || this.getTreePref('debug.all');
|
||||
},
|
||||
|
||||
log : function utils_log(aModule, ...aArgs)
|
||||
{
|
||||
if (!this.isDebugging(aModule))
|
||||
return;
|
||||
|
||||
var logString = '[treestyletab:' + aModule+'] '+ aArgs.join(', ');
|
||||
Serivces.console.logStringMessage(logString);
|
||||
dump(logString+'\n');
|
||||
},
|
||||
logWithStackTrace : function utils_logWithStackTrace(aModule, ...aArgs)
|
||||
{
|
||||
var stack = (new Error()).stack.replace(/^/gm, ' '));
|
||||
return this.log.apply(this, [aModule].concat(aArgs).concat([stack]));
|
||||
},
|
||||
|
||||
/* string bundle */
|
||||
get treeBundle () {
|
||||
return stringBundle.get('chrome://treestyletab/locale/treestyletab.properties');
|
||||
|
@ -71,6 +71,13 @@ XPCOMUtils.defineLazyModuleGetter(this, 'ContentBridge', 'resource://treestyleta
|
||||
XPCOMUtils.defineLazyServiceGetter(this, 'SessionStore',
|
||||
'@mozilla.org/browser/sessionstore;1', 'nsISessionStore');
|
||||
|
||||
function log(...aArgs) {
|
||||
utils.log.apply(utils, ['window'].concat(aArgs));
|
||||
}
|
||||
function logWithStackTrace(...aArgs) {
|
||||
utils.logWithStackTrace.apply(utils, ['window'].concat(aArgs));
|
||||
}
|
||||
|
||||
function TreeStyleTabWindow(aWindow)
|
||||
{
|
||||
this.window = aWindow;
|
||||
@ -1336,8 +1343,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
if (!aTab)
|
||||
return;
|
||||
|
||||
if (utils.isDebugging('window'))
|
||||
dump('TSTWindow_onBeforeOpenLinkWithTab '+[aTab, JSON.stringify(aParams), this.checkToOpenChildTab(aTab)]+'\n');
|
||||
log('onBeforeOpenLinkWithTab '+[aTab, JSON.stringify(aParams), this.checkToOpenChildTab(aTab)]);
|
||||
|
||||
if (!this.checkToOpenChildTab(aTab)) {
|
||||
if (!aParams.fromChrome)
|
||||
@ -1349,8 +1355,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
|
||||
onBeforeOpenNewTabByThirdParty : function TSTWindow_onBeforeOpenNewTabByThirdParty(aOwner)
|
||||
{
|
||||
if (utils.isDebugging('window'))
|
||||
dump('TSTWindow_onBeforeOpenNewTabByThirdParty '+[aOwner, this.checkToOpenChildTab(aTab)]+'\n');
|
||||
log('onBeforeOpenNewTabByThirdParty '+[aOwner, this.checkToOpenChildTab(aTab)]);
|
||||
|
||||
if (!this.checkToOpenChildTab(aOwner)) {
|
||||
this.handleNewTabFromCurrent(aOwner);
|
||||
@ -1363,17 +1368,14 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
var opener = null;
|
||||
if (aOpener) {
|
||||
if (aOpener instanceof Ci.nsIDOMWindow) {
|
||||
if (utils.isDebugging('window'))
|
||||
dump('TSTWindow_onBeforeBrowserAccessOpenURI: opener is DOMWindow\n');
|
||||
log('onBeforeBrowserAccessOpenURI: opener is DOMWindow');
|
||||
opener = aOpener;
|
||||
hasOwnerTab = this.getTabFromFrame(opener.top);
|
||||
if (utils.isDebugging('window'))
|
||||
dump(' opener =>'+[opener,hasOwnerTab]+'\n');
|
||||
log(' opener =>'+[opener,hasOwnerTab]);
|
||||
}
|
||||
else if (Ci.nsIOpenURIInFrameParams &&
|
||||
aOpener instanceof Ci.nsIOpenURIInFrameParams) {
|
||||
if (utils.isDebugging('window'))
|
||||
dump('TSTWindow_onBeforeBrowserAccessOpenURI: opener is nsIOpenURIInFrameParams\n');
|
||||
log('TSTWindow_onBeforeBrowserAccessOpenURI: opener is nsIOpenURIInFrameParams');
|
||||
// from remote contents, we have to detect its opener from the URI.
|
||||
let referrer = aOpener.referrer;
|
||||
if (referrer) {
|
||||
@ -1388,8 +1390,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (utils.isDebugging('window'))
|
||||
dump(' opener =>'+[opener,hasOwnerTab]+'\n');
|
||||
log(' opener =>'+[opener,hasOwnerTab]);
|
||||
}
|
||||
}
|
||||
if (aOpener &&
|
||||
@ -1404,8 +1405,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
{
|
||||
var where = String(this.window.whereToOpenLink(aEvent, false, true));
|
||||
|
||||
if (utils.isDebugging('window'))
|
||||
dump('TSTWindow_onBeforeViewMedia '+[aEvent, aOwner, where]+'\n');
|
||||
log('onBeforeViewMedia '+[aEvent, aOwner, where]);
|
||||
|
||||
if (where.indexOf('tab') == 0)
|
||||
this.handleNewTabFromCurrent(aOwner);
|
||||
@ -1415,8 +1415,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
|
||||
onBeforeBrowserSearch : function TSTWindow_onBeforeBrowserSearch(aTerm, aForceNewTab)
|
||||
{
|
||||
if (utils.isDebugging('window'))
|
||||
dump('TSTWindow_onBeforeBrowserSearch '+[aTerm, aForceNewTab, this.shouldOpenSearchResultAsChild(aTerm)]+'\n');
|
||||
log('onBeforeBrowserSearch '+[aTerm, aForceNewTab, this.shouldOpenSearchResultAsChild(aTerm)]);
|
||||
|
||||
if ((arguments.length == 1 || aForceNewTab) &&
|
||||
this.shouldOpenSearchResultAsChild(aTerm))
|
||||
@ -1609,10 +1608,9 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
|
||||
createSubtree : function TSTWindow_createSubtree(aTabs)
|
||||
{
|
||||
if (utils.isDebugging('window'))
|
||||
dump('TSTWindow_createSubtree\n'+aTabs.map(function(aTab) {
|
||||
return ' '+aTab._tPos+': '+aTab.linkedBrowser.currentURI.spec;
|
||||
}).join('\n')+'\n');
|
||||
log('TSTWindow_createSubtree\n'+aTabs.map(function(aTab) {
|
||||
return ' '+aTab._tPos+': '+aTab.linkedBrowser.currentURI.spec;
|
||||
}).join('\n'));
|
||||
|
||||
var rootTabs = this.getRootTabs(aTabs);
|
||||
|
||||
@ -1633,8 +1631,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
||||
var parentInTargets = aTabs.indexOf(this.getParentTab(aDescendantTab)) > -1;
|
||||
if (inTargets || (inTargets == parentInTargets))
|
||||
return;
|
||||
if (utils.isDebugging('window'))
|
||||
dump(' detaching unselected descendant: '+aDescendantTab._tPos+': '+aDescendantTab.linkedBrowser.currentURI.spec+'\n');
|
||||
log(' detaching unselected descendant: '+aDescendantTab._tPos+': '+aDescendantTab.linkedBrowser.currentURI.spec);
|
||||
if (parentTab)
|
||||
b.treeStyleTab.attachTabTo(aDescendantTab, parentTab, {
|
||||
dontExpand : true,
|
||||
|
Loading…
Reference in New Issue
Block a user