2011-05-25 16:54:46 -04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Tree Style Tab.
|
|
|
|
*
|
2012-10-13 14:31:06 -04:00
|
|
|
* The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
|
2014-03-24 05:29:46 -04:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2012-2014
|
2011-05-25 16:54:46 -04:00
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
2012-10-13 14:31:06 -04:00
|
|
|
* Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com>
|
2013-11-09 14:28:07 -05:00
|
|
|
* Tetsuharu OHZEKI <https://github.com/saneyuki>
|
2011-05-25 16:54:46 -04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ******/
|
|
|
|
|
|
|
|
const EXPORTED_SYMBOLS = ['TreeStyleTabWindow'];
|
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
2013-01-05 21:47:50 -05:00
|
|
|
const Cu = Components.utils;
|
2011-05-25 16:54:46 -04:00
|
|
|
|
2013-01-05 21:47:50 -05:00
|
|
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
2014-04-02 06:25:51 -04:00
|
|
|
Cu.import('resource://treestyletab-modules/lib/inherit.jsm');
|
2013-01-05 21:47:50 -05:00
|
|
|
|
|
|
|
XPCOMUtils.defineLazyGetter(this, 'window', function() {
|
|
|
|
Cu.import('resource://treestyletab-modules/lib/namespace.jsm');
|
|
|
|
return getNamespaceFor('piro.sakura.ne.jp');
|
|
|
|
});
|
|
|
|
XPCOMUtils.defineLazyGetter(this, 'prefs', function() {
|
|
|
|
Cu.import('resource://treestyletab-modules/lib/prefs.js');
|
|
|
|
return window['piro.sakura.ne.jp'].prefs;
|
2013-01-05 21:56:20 -05:00
|
|
|
});
|
2011-05-25 16:54:46 -04:00
|
|
|
|
2013-01-02 19:29:05 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'UninstallationListener',
|
|
|
|
'resource://treestyletab-modules/lib/UninstallationListener.js');
|
2013-01-02 19:06:21 -05:00
|
|
|
|
2013-01-05 21:47:50 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'Services', 'resource://gre/modules/Services.jsm');
|
2012-09-17 11:31:48 -04:00
|
|
|
|
2013-01-05 21:47:50 -05:00
|
|
|
Cu.import('resource://treestyletab-modules/base.js');
|
2012-11-11 08:48:42 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabBrowser', 'resource://treestyletab-modules/browser.js');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'AutoHideWindow', 'resource://treestyletab-modules/autoHide.js');
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabThemeManager', 'resource://treestyletab-modules/themeManager.js');
|
2013-11-30 11:09:05 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'FullscreenObserver', 'resource://treestyletab-modules/fullscreenObserver.js');
|
2013-03-02 08:12:28 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'BrowserUIShowHideObserver', 'resource://treestyletab-modules/browserUIShowHideObserver.js');
|
2012-10-19 08:38:35 -04:00
|
|
|
|
2014-03-31 01:56:44 -04:00
|
|
|
function TreeStyleTabWindow(aWindow)
|
2011-05-25 16:54:46 -04:00
|
|
|
{
|
|
|
|
this.window = aWindow;
|
|
|
|
this.document = aWindow.document;
|
|
|
|
|
|
|
|
this._restoringTabs = [];
|
|
|
|
this._shownPopups = [];
|
|
|
|
this.restoringCount = 0;
|
|
|
|
|
|
|
|
aWindow.addEventListener('DOMContentLoaded', this, true);
|
|
|
|
aWindow.addEventListener('load', this, false);
|
|
|
|
aWindow.TreeStyleTabService = this;
|
2011-05-25 23:11:08 -04:00
|
|
|
|
2012-11-11 08:48:42 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(aWindow, 'TreeStyleTabBrowser', 'resource://treestyletab-modules/browser.js');
|
2011-05-25 16:54:46 -04:00
|
|
|
}
|
|
|
|
|
2014-04-02 06:25:51 -04:00
|
|
|
TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
|
2008-11-09 23:48:11 -05:00
|
|
|
|
2012-10-29 14:11:39 -04:00
|
|
|
base : TreeStyleTabBase,
|
2011-05-25 16:54:46 -04:00
|
|
|
|
|
|
|
window : null,
|
|
|
|
document : null,
|
|
|
|
|
2007-10-21 04:16:10 -04:00
|
|
|
/* API */
|
2011-05-25 16:54:46 -04:00
|
|
|
|
|
|
|
changeTabbarPosition : function TSTWindow_changeTabbarPosition(aNewPosition) /* PUBLIC API (obsolete, for backward compatibility) */
|
2009-04-21 02:42:52 -04:00
|
|
|
{
|
2011-01-22 10:46:29 -05:00
|
|
|
this.position = aNewPosition;
|
2009-04-21 02:42:52 -04:00
|
|
|
},
|
2011-05-25 16:54:46 -04:00
|
|
|
|
2011-01-22 10:46:29 -05:00
|
|
|
get position() /* PUBLIC API */
|
2009-12-17 21:46:36 -05:00
|
|
|
{
|
2011-02-04 05:50:21 -05:00
|
|
|
return this.preInitialized && this.browser.treeStyleTab ?
|
|
|
|
this.browser.treeStyleTab.position :
|
2012-10-29 14:11:39 -04:00
|
|
|
this.base.position ;
|
2009-12-17 21:46:36 -05:00
|
|
|
},
|
2011-01-22 10:46:29 -05:00
|
|
|
set position(aValue)
|
2010-03-24 13:20:30 -04:00
|
|
|
{
|
2011-05-25 16:54:46 -04:00
|
|
|
if ('UndoTabService' in this.window && this.window.UndoTabService.isUndoable()) {
|
2012-10-29 14:11:39 -04:00
|
|
|
var current = this.base.position;
|
2010-01-13 02:06:50 -05:00
|
|
|
var self = this;
|
2011-05-25 16:54:46 -04:00
|
|
|
this.window.UndoTabService.doOperation(
|
2010-01-13 02:06:50 -05:00
|
|
|
function() {
|
2012-10-29 14:11:39 -04:00
|
|
|
self.base.position = aValue;
|
2010-03-24 13:20:30 -04:00
|
|
|
},
|
|
|
|
{
|
2013-01-02 21:08:25 -05:00
|
|
|
label : utils.treeBundle.getString('undo_changeTabbarPosition_label'),
|
2010-03-24 13:20:30 -04:00
|
|
|
name : 'treestyletab-changeTabbarPosition',
|
|
|
|
data : {
|
|
|
|
oldPosition : current,
|
|
|
|
newPosition : aValue
|
|
|
|
}
|
2010-01-13 02:06:50 -05:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2011-01-22 10:46:29 -05:00
|
|
|
else {
|
2012-10-29 14:11:39 -04:00
|
|
|
this.base.position = aValue;
|
2011-01-22 10:46:29 -05:00
|
|
|
}
|
|
|
|
return aValue;
|
|
|
|
},
|
2009-12-25 11:38:14 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
undoChangeTabbarPosition : function TSTWindow_undoChangeTabbarPosition() /* PUBLIC API */
|
2009-12-25 11:38:14 -05:00
|
|
|
{
|
2012-10-29 14:11:39 -04:00
|
|
|
return this.base.undoChangeTabbarPosition();
|
2009-12-25 14:27:34 -05:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
redoChangeTabbarPosition : function TSTWindow_redoChangeTabbarPosition() /* PUBLIC API */
|
2009-12-25 14:27:34 -05:00
|
|
|
{
|
2012-10-29 14:11:39 -04:00
|
|
|
return this.base.redoChangeTabbarPosition();
|
2009-12-18 04:14:02 -05:00
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
|
|
|
get treeViewEnabled() /* PUBLIC API */
|
|
|
|
{
|
2012-10-29 14:11:39 -04:00
|
|
|
return this.base.treeViewEnabled;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
|
|
|
set treeViewEnabled(aValue)
|
|
|
|
{
|
2012-10-29 14:11:39 -04:00
|
|
|
return this.base.treeViewEnabled = aValue;
|
2009-12-25 12:55:55 -05:00
|
|
|
},
|
2009-12-25 13:13:33 -05:00
|
|
|
|
|
|
|
get useTMPSessionAPI() /* PUBLIC API */
|
|
|
|
{
|
2012-10-29 14:11:39 -04:00
|
|
|
return this.base.useTMPSessionAPI;
|
2009-12-25 13:13:33 -05:00
|
|
|
},
|
|
|
|
set useTMPSessionAPI(aValue)
|
|
|
|
{
|
2012-10-29 14:11:39 -04:00
|
|
|
return this.base.useTMPSessionAPI = aValue;
|
2009-12-25 13:13:33 -05:00
|
|
|
},
|
2010-05-08 01:37:41 -04:00
|
|
|
|
|
|
|
get browser()
|
|
|
|
{
|
2011-05-25 17:23:02 -04:00
|
|
|
var w = this.window;
|
2012-01-23 20:15:25 -05:00
|
|
|
this.assertBeforeDestruction(w);
|
2011-05-25 17:23:02 -04:00
|
|
|
return 'SplitBrowser' in w ? w.SplitBrowser.activeBrowser :
|
|
|
|
w.gBrowser ;
|
2010-05-08 01:37:41 -04:00
|
|
|
},
|
2012-01-30 13:38:41 -05:00
|
|
|
|
2014-03-31 01:56:44 -04:00
|
|
|
get browserToolbox()
|
2013-03-02 08:12:28 -05:00
|
|
|
{
|
|
|
|
var w = this.window;
|
|
|
|
return w.gToolbox || w.gNavToolbox;
|
|
|
|
},
|
|
|
|
|
2014-03-31 01:56:44 -04:00
|
|
|
get browserBox()
|
2013-10-08 12:30:52 -04:00
|
|
|
{
|
|
|
|
return this.document.getElementById('browser');
|
|
|
|
},
|
|
|
|
|
2014-03-31 01:56:44 -04:00
|
|
|
get browserBottomBox()
|
2012-07-29 01:47:11 -04:00
|
|
|
{
|
|
|
|
return this.document.getElementById('browser-bottombox');
|
|
|
|
},
|
|
|
|
|
2012-01-30 13:38:41 -05:00
|
|
|
get isPopupWindow()
|
|
|
|
{
|
2014-01-31 08:02:33 -05:00
|
|
|
return (
|
|
|
|
this.document &&
|
|
|
|
this.document.documentElement.getAttribute('chromehidden') != '' &&
|
2014-02-03 03:14:38 -05:00
|
|
|
!this.window.gBrowser.treeStyleTab.isVisible
|
2014-01-31 08:02:33 -05:00
|
|
|
);
|
2012-01-30 13:38:41 -05:00
|
|
|
},
|
2007-10-30 08:58:09 -04:00
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
/* backward compatibility */
|
2011-05-25 16:54:46 -04:00
|
|
|
getTempTreeStyleTab : function TSTWindow_getTempTreeStyleTab(aTabBrowser)
|
2007-11-14 14:34:36 -05:00
|
|
|
{
|
2012-11-11 08:48:42 -05:00
|
|
|
return aTabBrowser.treeStyleTab || new TreeStyleTabBrowser(this, aTabBrowser);
|
2007-11-14 14:34:36 -05:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
initTabAttributes : function TSTWindow_initTabAttributes(aTab, aTabBrowser)
|
2007-11-14 14:34:36 -05:00
|
|
|
{
|
2007-11-17 08:32:41 -05:00
|
|
|
var b = aTabBrowser || this.getTabBrowserFromChild(aTab);
|
2007-11-14 14:34:36 -05:00
|
|
|
this.getTempTreeStyleTab(b).initTabAttributes(aTab);
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
initTabContents : function TSTWindow_initTabContents(aTab, aTabBrowser)
|
2007-11-14 14:34:36 -05:00
|
|
|
{
|
2007-11-17 08:32:41 -05:00
|
|
|
var b = aTabBrowser || this.getTabBrowserFromChild(aTab);
|
2007-11-14 14:34:36 -05:00
|
|
|
this.getTempTreeStyleTab(b).initTabContents(aTab);
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
initTabContentsOrder : function TSTWindow_initTabContentsOrder(aTab, aTabBrowser)
|
2007-11-14 14:34:36 -05:00
|
|
|
{
|
2007-11-17 08:32:41 -05:00
|
|
|
var b = aTabBrowser || this.getTabBrowserFromChild(aTab);
|
2007-11-14 14:34:36 -05:00
|
|
|
this.getTempTreeStyleTab(b).initTabContentsOrder(aTab);
|
|
|
|
},
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
/* Utilities */
|
2008-03-09 01:36:52 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
stopRendering : function TSTWindow_stopRendering()
|
2009-12-21 00:33:32 -05:00
|
|
|
{
|
2011-05-25 16:54:46 -04:00
|
|
|
this.window['piro.sakura.ne.jp'].stopRendering.stop();
|
2009-12-21 00:33:32 -05:00
|
|
|
},
|
2011-05-25 16:54:46 -04:00
|
|
|
startRendering : function TSTWindow_startRendering()
|
2009-12-21 00:33:32 -05:00
|
|
|
{
|
2011-05-25 16:54:46 -04:00
|
|
|
this.window['piro.sakura.ne.jp'].stopRendering.start();
|
2009-12-21 00:33:32 -05:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
getPropertyPixelValue : function TSTWindow_getPropertyPixelValue(aElementOrStyle, aProp)
|
2009-04-07 12:09:17 -04:00
|
|
|
{
|
2011-05-25 16:54:46 -04:00
|
|
|
var style = aElementOrStyle instanceof Ci.nsIDOMCSSStyleDeclaration ?
|
2009-04-07 12:09:17 -04:00
|
|
|
aElementOrStyle :
|
2011-05-25 16:54:46 -04:00
|
|
|
this.window.getComputedStyle(aElementOrStyle, null) ;
|
2009-04-07 12:09:17 -04:00
|
|
|
return Number(style.getPropertyValue(aProp).replace(/px$/, ''));
|
|
|
|
},
|
2010-04-21 07:43:13 -04:00
|
|
|
|
|
|
|
get isToolbarCustomizing()
|
|
|
|
{
|
2013-03-02 08:12:28 -05:00
|
|
|
var toolbox = this.browserToolbox;
|
2010-09-17 05:34:41 -04:00
|
|
|
return toolbox && toolbox.customizing;
|
2010-04-21 07:43:13 -04:00
|
|
|
},
|
2010-04-22 04:12:31 -04:00
|
|
|
|
2012-02-09 14:01:13 -05:00
|
|
|
get maximized()
|
2011-12-14 01:26:58 -05:00
|
|
|
{
|
2011-12-14 01:33:25 -05:00
|
|
|
var sizemode = this.document.documentElement.getAttribute('sizemode');
|
2011-12-14 01:26:58 -05:00
|
|
|
return (
|
|
|
|
this.window.fullScreen ||
|
|
|
|
this.window.windowState == this.window.STATE_MAXIMIZED ||
|
2011-12-14 01:33:25 -05:00
|
|
|
sizemode == 'maximized' ||
|
|
|
|
sizemode == 'fullscreen'
|
2011-12-14 01:26:58 -05:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
maxTabbarWidth : function TSTWindow_maxTabbarWidth(aWidth, aTabBrowser)
|
2010-04-22 04:12:31 -04:00
|
|
|
{
|
|
|
|
aTabBrowser = aTabBrowser || this.browser;
|
2011-12-14 01:26:58 -05:00
|
|
|
var safePadding = 20; // for window border, etc.
|
2011-12-14 01:28:47 -05:00
|
|
|
var windowWidth = this.maximized ? this.window.screen.availWidth - safePadding : this.window.outerWidth ;
|
2011-05-25 16:54:46 -04:00
|
|
|
var rootWidth = parseInt(this.document.documentElement.getAttribute('width') || 0);
|
2010-09-13 05:47:04 -04:00
|
|
|
var max = Math.max(windowWidth, rootWidth);
|
2010-09-12 23:54:04 -04:00
|
|
|
return Math.max(0, Math.min(aWidth, max * this.MAX_TABBAR_SIZE_RATIO));
|
2010-04-22 04:12:31 -04:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
maxTabbarHeight : function TSTWindow_maxTabbarHeight(aHeight, aTabBrowser)
|
2010-04-22 04:12:31 -04:00
|
|
|
{
|
|
|
|
aTabBrowser = aTabBrowser || this.browser;
|
2011-12-14 01:26:58 -05:00
|
|
|
var safePadding = 20; // for window border, etc.
|
2011-12-14 01:28:47 -05:00
|
|
|
var windowHeight = this.maximized ? this.window.screen.availHeight - safePadding : this.window.outerHeight ;
|
2011-05-25 16:54:46 -04:00
|
|
|
var rootHeight = parseInt(this.document.documentElement.getAttribute('height') || 0);
|
2010-09-13 05:47:04 -04:00
|
|
|
var max = Math.max(windowHeight, rootHeight);
|
2010-09-12 23:54:04 -04:00
|
|
|
return Math.max(0, Math.min(aHeight, max * this.MAX_TABBAR_SIZE_RATIO));
|
2010-04-22 04:12:31 -04:00
|
|
|
},
|
2010-12-09 01:05:46 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
shouldOpenSearchResultAsChild : function TSTWindow_shouldOpenSearchResultAsChild(aTerm)
|
2010-12-09 01:05:46 -05:00
|
|
|
{
|
2014-03-31 02:10:51 -04:00
|
|
|
aTerm = aTerm.trim();
|
2011-08-29 11:39:17 -04:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
var mode = utils.getTreePref('autoAttach.searchResult');
|
2011-01-05 21:15:56 -05:00
|
|
|
if (mode == this.kSEARCH_RESULT_ATTACH_ALWAYS) {
|
2010-12-09 01:19:38 -05:00
|
|
|
return true;
|
2011-01-05 21:15:56 -05:00
|
|
|
}
|
|
|
|
else if (!aTerm || mode == this.kSEARCH_RESULT_DO_NOT_ATTACH) {
|
2010-12-09 01:18:37 -05:00
|
|
|
return false;
|
2011-01-05 21:15:56 -05:00
|
|
|
}
|
2010-12-09 01:18:37 -05:00
|
|
|
|
2014-03-24 05:27:45 -04:00
|
|
|
var selection = this.window.getBrowserSelection();
|
2014-03-31 02:10:51 -04:00
|
|
|
return selection.trim() == aTerm;
|
2010-12-09 01:05:46 -05:00
|
|
|
},
|
2010-12-09 06:13:04 -05:00
|
|
|
kSEARCH_RESULT_DO_NOT_ATTACH : 0,
|
|
|
|
kSEARCH_RESULT_ATTACH_IF_SELECTED : 1,
|
|
|
|
kSEARCH_RESULT_ATTACH_ALWAYS : 2,
|
2011-05-25 11:52:28 -04:00
|
|
|
|
|
|
|
get isAutoHide()
|
|
|
|
{
|
2011-05-25 16:54:46 -04:00
|
|
|
return this.window.fullScreen ?
|
2011-05-25 11:52:28 -04:00
|
|
|
(
|
2013-01-05 21:47:50 -05:00
|
|
|
prefs.getPref('browser.fullscreen.autohide') &&
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('tabbar.autoHide.mode.fullscreen')
|
2011-05-25 11:52:28 -04:00
|
|
|
) :
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('tabbar.autoHide.mode');
|
2011-05-25 11:52:28 -04:00
|
|
|
},
|
2011-05-26 10:22:42 -04:00
|
|
|
|
|
|
|
get autoHideWindow()
|
|
|
|
{
|
|
|
|
if (!this._autoHideWindow) {
|
2012-11-11 08:48:42 -05:00
|
|
|
this._autoHideWindow = new AutoHideWindow(this.window);
|
2011-05-26 10:22:42 -04:00
|
|
|
}
|
|
|
|
return this._autoHideWindow;
|
|
|
|
},
|
|
|
|
|
|
|
|
get themeManager()
|
|
|
|
{
|
|
|
|
if (!this._themeManager) {
|
2012-11-11 08:48:42 -05:00
|
|
|
this._themeManager = new TreeStyleTabThemeManager(this.window);
|
2011-05-26 10:22:42 -04:00
|
|
|
}
|
|
|
|
return this._themeManager;
|
|
|
|
},
|
2009-07-22 00:25:39 -04:00
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
/* Initializing */
|
2008-11-09 23:48:11 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
preInit : function TSTWindow_preInit()
|
2008-02-25 20:14:12 -05:00
|
|
|
{
|
2013-09-17 05:17:20 -04:00
|
|
|
if (this.preInitialized)
|
|
|
|
return;
|
2008-10-14 00:57:35 -04:00
|
|
|
this.preInitialized = true;
|
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
var w = this.window;
|
|
|
|
w.removeEventListener('DOMContentLoaded', this, true);
|
|
|
|
if (w.location.href.indexOf('chrome://browser/content/browser.xul') != 0)
|
2010-09-12 22:17:38 -04:00
|
|
|
return;
|
2008-02-25 20:14:12 -05:00
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
w.addEventListener('SSTabRestoring', this, true);
|
2008-11-09 23:48:11 -05:00
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
w.TreeStyleTabWindowHelper.preInit();
|
2009-07-06 11:36:43 -04:00
|
|
|
|
2011-05-26 10:22:42 -04:00
|
|
|
// initialize theme
|
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.style');
|
2009-07-27 03:22:56 -04:00
|
|
|
},
|
|
|
|
preInitialized : false,
|
2012-02-09 14:01:13 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
init : function TSTWindow_init()
|
2007-10-16 13:22:28 -04:00
|
|
|
{
|
2011-05-25 17:23:02 -04:00
|
|
|
var w = this.window;
|
|
|
|
w.removeEventListener('load', this, false);
|
2011-06-13 11:59:34 -04:00
|
|
|
|
2011-06-13 13:04:37 -04:00
|
|
|
w.addEventListener('unload', this, false);
|
2011-05-25 16:54:46 -04:00
|
|
|
|
2011-05-26 10:22:42 -04:00
|
|
|
if (
|
|
|
|
w.location.href.indexOf('chrome://browser/content/browser.xul') != 0 ||
|
|
|
|
!this.browser
|
|
|
|
)
|
|
|
|
return;
|
2007-10-16 13:22:28 -04:00
|
|
|
|
2013-09-17 05:17:20 -04:00
|
|
|
if (this.initialized)
|
|
|
|
return;
|
2008-10-14 00:57:35 -04:00
|
|
|
|
|
|
|
if (!this.preInitialized) {
|
|
|
|
this.preInit();
|
|
|
|
}
|
2011-05-25 17:23:02 -04:00
|
|
|
w.removeEventListener('SSTabRestoring', this, true);
|
2011-05-25 16:54:46 -04:00
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
var d = this.document;
|
|
|
|
d.addEventListener('popupshowing', this, false);
|
|
|
|
d.addEventListener('popuphiding', this, true);
|
|
|
|
d.addEventListener(this.kEVENT_TYPE_TAB_COLLAPSED_STATE_CHANGED, this, false);
|
|
|
|
d.addEventListener(this.kEVENT_TYPE_TABBAR_POSITION_CHANGED, this, false);
|
|
|
|
d.addEventListener(this.kEVENT_TYPE_TABBAR_STATE_CHANGED, this, false);
|
|
|
|
d.addEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, this, false);
|
2013-11-28 11:43:43 -05:00
|
|
|
w.addEventListener('beforecustomization', this, true);
|
|
|
|
w.addEventListener('aftercustomization', this, false);
|
2011-05-25 16:54:46 -04:00
|
|
|
|
2014-07-26 13:44:23 -04:00
|
|
|
w.messageManager.addMessageListener('SessionStore:restoreTabContentStarted', this);
|
2014-03-31 01:54:14 -04:00
|
|
|
|
2013-11-30 11:09:05 -05:00
|
|
|
this.fullscreenObserver = new FullscreenObserver(this.window);
|
2013-03-02 08:12:28 -05:00
|
|
|
this.initUIShowHideObserver();
|
2012-07-29 01:47:11 -04:00
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
var appcontent = d.getElementById('appcontent');
|
2007-11-14 10:09:47 -05:00
|
|
|
appcontent.addEventListener('SubBrowserAdded', this, false);
|
|
|
|
appcontent.addEventListener('SubBrowserRemoveRequest', this, false);
|
2010-03-24 13:20:30 -04:00
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
w.addEventListener('UIOperationHistoryUndo:TabbarOperations', this, false);
|
|
|
|
w.addEventListener('UIOperationHistoryRedo:TabbarOperations', this, false);
|
2007-10-17 09:25:50 -04:00
|
|
|
|
2013-01-05 21:47:50 -05:00
|
|
|
prefs.addPrefListener(this);
|
2007-10-16 13:22:28 -04:00
|
|
|
|
2009-09-09 01:08:26 -04:00
|
|
|
this.initUninstallationListener();
|
2009-09-09 00:45:54 -04:00
|
|
|
|
2011-05-25 21:47:28 -04:00
|
|
|
w.TreeStyleTabWindowHelper.onBeforeBrowserInit();
|
2011-05-25 16:54:46 -04:00
|
|
|
this.initTabBrowser(this.browser);
|
2011-05-25 21:47:28 -04:00
|
|
|
w.TreeStyleTabWindowHelper.onAfterBrowserInit();
|
2008-03-03 03:26:51 -05:00
|
|
|
|
2008-11-09 23:48:11 -05:00
|
|
|
this.processRestoredTabs();
|
2010-05-15 10:05:02 -04:00
|
|
|
this.updateTabsOnTop();
|
2008-11-09 23:48:11 -05:00
|
|
|
|
2011-05-25 11:52:28 -04:00
|
|
|
// Init autohide service only if it have to be activated.
|
|
|
|
if (this.isAutoHide)
|
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.autoHide.mode');
|
2011-07-29 01:44:31 -04:00
|
|
|
|
2009-12-25 06:27:23 -05:00
|
|
|
this.onPrefChange('extensions.treestyletab.autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut');
|
2012-04-09 04:59:06 -04:00
|
|
|
|
|
|
|
this.initialized = true;
|
2007-10-16 13:22:28 -04:00
|
|
|
},
|
2008-10-14 00:57:35 -04:00
|
|
|
initialized : false,
|
2009-12-25 13:13:33 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
initUninstallationListener : function TSTWindow_initUninstallationListener()
|
2009-09-09 00:45:54 -04:00
|
|
|
{
|
|
|
|
var restorePrefs = function() {
|
2012-04-09 07:18:52 -04:00
|
|
|
if (prefs.getPref('extensions.treestyletab.tabsOnTop.originalState')) {
|
|
|
|
prefs.clearPref('extensions.treestyletab.tabsOnTop.originalState');
|
2011-05-04 17:25:40 -04:00
|
|
|
try {
|
2013-01-02 19:07:55 -05:00
|
|
|
this.browser.treeStyleTab.position = 'top';
|
2011-05-04 17:25:40 -04:00
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
}
|
2013-01-02 19:07:55 -05:00
|
|
|
this.window.TabsOnTop.enabled = true;
|
2011-05-04 17:25:40 -04:00
|
|
|
}
|
2013-01-02 19:07:55 -05:00
|
|
|
}.bind(this);
|
2013-01-02 19:29:05 -05:00
|
|
|
new UninstallationListener({
|
2009-09-09 01:08:26 -04:00
|
|
|
id : 'treestyletab@piro.sakura.ne.jp',
|
2009-09-09 00:45:54 -04:00
|
|
|
onuninstalled : restorePrefs,
|
|
|
|
ondisabled : restorePrefs
|
|
|
|
});
|
|
|
|
},
|
2009-12-25 13:13:33 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
initTabBrowser : function TSTWindow_initTabBrowser(aTabBrowser)
|
2007-10-16 13:22:28 -04:00
|
|
|
{
|
2013-09-17 05:17:20 -04:00
|
|
|
if (aTabBrowser.localName != 'tabbrowser')
|
|
|
|
return;
|
2012-11-11 08:48:42 -05:00
|
|
|
(new TreeStyleTabBrowser(this, aTabBrowser)).init();
|
2010-04-30 00:49:00 -04:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
updateAllTabsButton : function TSTWindow_updateAllTabsButton(aTabBrowser)
|
2010-04-30 00:49:00 -04:00
|
|
|
{
|
2011-05-25 17:23:02 -04:00
|
|
|
var d = this.document;
|
2010-04-30 00:49:00 -04:00
|
|
|
aTabBrowser = aTabBrowser || this.browser;
|
2012-01-13 03:38:12 -05:00
|
|
|
var allTabsButton = d.getElementById('alltabs-button') ||
|
2010-04-30 00:49:00 -04:00
|
|
|
( // Tab Mix Plus
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('compatibility.TMP') &&
|
2011-05-25 17:23:02 -04:00
|
|
|
d.getAnonymousElementByAttribute(aTabBrowser.mTabContainer, 'anonid', 'alltabs-button')
|
2010-04-30 00:49:00 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
if (allTabsButton && allTabsButton.hasChildNodes() && aTabBrowser.treeStyleTab)
|
|
|
|
allTabsButton.firstChild.setAttribute('position', aTabBrowser.treeStyleTab.isVertical ? 'before_start' : 'after_end' );
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
updateAllTabsPopup : function TSTWindow_updateAllTabsPopup(aEvent)
|
2010-04-30 00:49:00 -04:00
|
|
|
{
|
2013-09-17 05:17:20 -04:00
|
|
|
if (!utils.getTreePref('enableSubtreeIndent.allTabsPopup'))
|
|
|
|
return;
|
2010-04-30 00:49:00 -04:00
|
|
|
|
2013-11-18 03:01:23 -05:00
|
|
|
Array.forEach(aEvent.originalTarget.childNodes, function(aItem) {
|
|
|
|
if (aItem.classList.contains('alltabs-item') && 'tab' in aItem)
|
2014-07-01 15:44:43 -04:00
|
|
|
aItem.style.marginLeft = aItem.tab.getAttribute(this.kNEST) + 'em';
|
2013-11-18 03:01:23 -05:00
|
|
|
}, this);
|
2008-09-26 10:13:29 -04:00
|
|
|
},
|
2012-07-29 01:47:11 -04:00
|
|
|
|
2013-03-02 08:12:28 -05:00
|
|
|
initUIShowHideObserver : function TSTWindow_initUIShowHideObserver()
|
2012-12-19 14:03:05 -05:00
|
|
|
{
|
2013-09-13 06:37:21 -04:00
|
|
|
this.rootElementObserver = new BrowserUIShowHideObserver(this, this.document.documentElement);
|
|
|
|
|
2013-03-02 08:12:28 -05:00
|
|
|
var toolbox = this.browserToolbox;
|
|
|
|
if (toolbox)
|
|
|
|
this.browserToolboxObserver = new BrowserUIShowHideObserver(this, toolbox);
|
|
|
|
|
2013-10-08 12:30:52 -04:00
|
|
|
var browserBox = this.browserBox;
|
|
|
|
if (browserBox)
|
|
|
|
this.browserBoxObserver = new BrowserUIShowHideObserver(this, browserBox);
|
|
|
|
|
2013-03-02 08:12:28 -05:00
|
|
|
var bottomBox = this.browserBottomBox;
|
|
|
|
if (bottomBox)
|
|
|
|
this.browserBottomBoxObserver = new BrowserUIShowHideObserver(this, bottomBox);
|
2012-07-29 01:47:11 -04:00
|
|
|
},
|
2008-10-14 13:48:19 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
destroy : function TSTWindow_destroy()
|
2007-10-16 13:22:28 -04:00
|
|
|
{
|
2011-05-27 17:08:45 -04:00
|
|
|
var w = this.window;
|
2011-05-25 16:54:46 -04:00
|
|
|
if (this.browser) {
|
2012-10-29 14:11:39 -04:00
|
|
|
this.base.inWindowDestoructionProcess = true;
|
2011-05-25 16:54:46 -04:00
|
|
|
try {
|
2011-05-25 17:23:02 -04:00
|
|
|
w.removeEventListener('unload', this, false);
|
2007-11-08 09:24:54 -05:00
|
|
|
|
2011-05-26 10:22:42 -04:00
|
|
|
this.autoHideWindow.destroy();
|
|
|
|
delete this._autoHideWindow;
|
|
|
|
|
|
|
|
this.themeManager.destroy();
|
|
|
|
delete this._themeManager;
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
this.browser.treeStyleTab.saveCurrentState();
|
|
|
|
this.destroyTabBrowser(this.browser);
|
2007-10-16 13:22:28 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOHIDE);
|
|
|
|
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE);
|
2008-03-08 03:57:17 -05:00
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
let d = this.document;
|
|
|
|
d.removeEventListener('popupshowing', this, false);
|
|
|
|
d.removeEventListener('popuphiding', this, true);
|
|
|
|
d.removeEventListener(this.kEVENT_TYPE_TAB_COLLAPSED_STATE_CHANGED, this, false);
|
|
|
|
d.removeEventListener(this.kEVENT_TYPE_TABBAR_POSITION_CHANGED, this, false);
|
|
|
|
d.removeEventListener(this.kEVENT_TYPE_TABBAR_STATE_CHANGED, this, false);
|
|
|
|
d.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, this, false);
|
2013-11-28 11:43:43 -05:00
|
|
|
w.removeEventListener('beforecustomization', this, true);
|
|
|
|
w.removeEventListener('aftercustomization', this, false);
|
2010-11-30 05:05:00 -05:00
|
|
|
|
2014-07-26 13:44:23 -04:00
|
|
|
w.messageManager.removeMessageListener('SessionStore:restoreTabContentStarted', this);
|
2014-03-31 01:54:14 -04:00
|
|
|
|
2013-11-30 11:09:05 -05:00
|
|
|
this.fullscreenObserver.destroy();
|
|
|
|
delete this.fullscreenObserver;
|
|
|
|
|
2013-09-13 06:37:21 -04:00
|
|
|
this.rootElementObserver.destroy();
|
|
|
|
delete this.rootElementObserver;
|
|
|
|
|
2013-03-02 08:12:28 -05:00
|
|
|
if (this.browserToolboxObserver) {
|
|
|
|
this.browserToolboxObserver.destroy();
|
|
|
|
delete this.browserToolboxObserver;
|
|
|
|
}
|
2013-10-08 12:30:52 -04:00
|
|
|
if (this.browserBoxObserver) {
|
|
|
|
this.browserBoxObserver.destroy();
|
|
|
|
delete this.browserBoxObserver;
|
|
|
|
}
|
2012-07-29 01:47:11 -04:00
|
|
|
if (this.browserBottomBoxObserver) {
|
2013-03-02 08:12:28 -05:00
|
|
|
this.browserBottomBoxObserver.destroy();
|
2012-07-29 01:47:11 -04:00
|
|
|
delete this.browserBottomBoxObserver;
|
|
|
|
}
|
|
|
|
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = this._tabFocusAllowance.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
w.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, this._tabFocusAllowance[i], false);
|
2012-02-04 13:15:38 -05:00
|
|
|
}
|
2007-10-22 05:59:43 -04:00
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
var appcontent = d.getElementById('appcontent');
|
2011-05-25 16:54:46 -04:00
|
|
|
appcontent.removeEventListener('SubBrowserAdded', this, false);
|
|
|
|
appcontent.removeEventListener('SubBrowserRemoveRequest', this, false);
|
2010-03-24 13:20:30 -04:00
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
w.removeEventListener('UIOperationHistoryUndo:TabbarOperations', this, false);
|
|
|
|
w.removeEventListener('UIOperationHistoryRedo:TabbarOperations', this, false);
|
2007-10-16 13:22:28 -04:00
|
|
|
|
2013-01-05 21:47:50 -05:00
|
|
|
prefs.removePrefListener(this);
|
2011-05-25 16:54:46 -04:00
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
finally {
|
2012-10-29 14:11:39 -04:00
|
|
|
this.base.inWindowDestoructionProcess = false;
|
2011-05-25 16:54:46 -04:00
|
|
|
}
|
2010-05-08 04:30:39 -04:00
|
|
|
}
|
2011-05-25 16:54:46 -04:00
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
delete w.TreeStyleTabService;
|
2011-05-25 16:54:46 -04:00
|
|
|
delete this.window;
|
|
|
|
delete this.document;
|
2007-10-16 13:22:28 -04:00
|
|
|
},
|
2008-11-09 23:48:11 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
destroyTabBrowser : function TSTWindow_destroyTabBrowser(aTabBrowser)
|
2007-10-16 13:22:28 -04:00
|
|
|
{
|
2013-09-17 05:17:20 -04:00
|
|
|
if (aTabBrowser.localName != 'tabbrowser')
|
|
|
|
return;
|
2007-11-14 14:34:36 -05:00
|
|
|
aTabBrowser.treeStyleTab.destroy();
|
|
|
|
delete aTabBrowser.treeStyleTab;
|
2007-10-16 13:22:28 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Event Handling */
|
2008-09-26 10:13:29 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
handleEvent : function TSTWindow_handleEvent(aEvent)
|
2007-10-16 13:22:28 -04:00
|
|
|
{
|
|
|
|
switch (aEvent.type)
|
|
|
|
{
|
2008-02-25 20:14:12 -05:00
|
|
|
case 'DOMContentLoaded':
|
2010-05-08 04:30:39 -04:00
|
|
|
return this.preInit();
|
2008-02-25 20:14:12 -05:00
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
case 'load':
|
2010-09-16 06:46:15 -04:00
|
|
|
return this.init();
|
2007-10-16 13:22:28 -04:00
|
|
|
|
|
|
|
case 'unload':
|
2010-05-08 04:30:39 -04:00
|
|
|
return this.destroy();
|
2007-10-16 13:22:28 -04:00
|
|
|
|
2008-11-09 23:48:11 -05:00
|
|
|
case 'SSTabRestoring':
|
2010-05-08 04:30:39 -04:00
|
|
|
return this.onTabRestored(aEvent);
|
2008-11-09 23:48:11 -05:00
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
case 'popupshowing':
|
2010-09-10 06:21:26 -04:00
|
|
|
this.onPopupShown(aEvent.originalTarget);
|
2010-04-30 00:49:00 -04:00
|
|
|
if ((aEvent.originalTarget.getAttribute('anonid') || aEvent.originalTarget.id) == 'alltabs-popup')
|
|
|
|
this.updateAllTabsPopup(aEvent);
|
2009-05-12 14:47:36 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
case 'popuphiding':
|
2010-09-10 06:21:26 -04:00
|
|
|
return this.onPopupHidden(aEvent.originalTarget);
|
2007-10-17 09:25:50 -04:00
|
|
|
|
2010-11-30 05:05:00 -05:00
|
|
|
case this.kEVENT_TYPE_TAB_COLLAPSED_STATE_CHANGED:
|
2010-04-06 09:38:05 -04:00
|
|
|
return this.updateAeroPeekPreviews();
|
|
|
|
|
2010-11-30 05:05:00 -05:00
|
|
|
case this.kEVENT_TYPE_TABBAR_POSITION_CHANGED:
|
|
|
|
case this.kEVENT_TYPE_TABBAR_STATE_CHANGED:
|
2010-05-15 10:05:02 -04:00
|
|
|
return this.updateTabsOnTop();
|
|
|
|
|
2010-11-30 05:05:00 -05:00
|
|
|
case this.kEVENT_TYPE_FOCUS_NEXT_TAB:
|
|
|
|
return this.onFocusNextTab(aEvent);
|
|
|
|
|
2008-03-08 03:57:17 -05:00
|
|
|
case 'keydown':
|
2010-05-08 04:30:39 -04:00
|
|
|
return this.onKeyDown(aEvent);
|
2008-03-08 03:57:17 -05:00
|
|
|
|
|
|
|
case 'keyup':
|
|
|
|
case 'keypress':
|
2010-05-08 04:30:39 -04:00
|
|
|
return this.onKeyRelease(aEvent);
|
2008-03-08 03:57:17 -05:00
|
|
|
|
2014-02-06 10:40:23 -05:00
|
|
|
case 'blur':
|
|
|
|
return this.simulateKeyRelease();
|
|
|
|
|
2010-09-12 23:54:04 -04:00
|
|
|
case 'mousedown':
|
|
|
|
return this.onTabbarResizeStart(aEvent);
|
|
|
|
|
|
|
|
case 'mouseup':
|
|
|
|
return this.onTabbarResizeEnd(aEvent);
|
|
|
|
|
|
|
|
case 'mousemove':
|
|
|
|
return this.onTabbarResizing(aEvent);
|
|
|
|
|
|
|
|
case 'dblclick':
|
|
|
|
return this.onTabbarReset(aEvent);
|
|
|
|
|
2011-05-24 14:27:53 -04:00
|
|
|
case 'click':
|
2011-05-24 22:53:22 -04:00
|
|
|
return this.handleNewTabActionOnButton(aEvent);
|
2011-05-24 14:27:53 -04:00
|
|
|
|
2013-11-28 11:43:43 -05:00
|
|
|
|
|
|
|
case 'beforecustomization':
|
|
|
|
this.window.TreeStyleTabWindowHelper.destroyToolbarItems();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case 'aftercustomization':
|
|
|
|
this.window.TreeStyleTabWindowHelper.initToolbarItems();
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
2007-10-17 09:25:50 -04:00
|
|
|
case 'SubBrowserAdded':
|
2010-05-08 04:30:39 -04:00
|
|
|
return this.initTabBrowser(aEvent.originalTarget.browser);
|
2007-10-17 09:25:50 -04:00
|
|
|
|
|
|
|
case 'SubBrowserRemoveRequest':
|
2010-05-08 04:30:39 -04:00
|
|
|
return this.destroyTabBrowser(aEvent.originalTarget.browser);
|
2010-01-13 02:06:50 -05:00
|
|
|
|
|
|
|
case 'UIOperationHistoryUndo:TabbarOperations':
|
|
|
|
switch (aEvent.entry.name)
|
|
|
|
{
|
|
|
|
case 'treestyletab-changeTabbarPosition':
|
2011-01-22 10:46:29 -05:00
|
|
|
this.position = aEvent.entry.data.oldPosition;
|
|
|
|
return;
|
|
|
|
case 'treestyletab-changeTabbarPosition-private':
|
|
|
|
aEvent.entry.data.target.treeStyleTab.position = aEvent.entry.data.oldPosition;
|
2010-01-13 02:06:50 -05:00
|
|
|
return;
|
|
|
|
}
|
2010-05-08 04:30:39 -04:00
|
|
|
return;
|
2010-01-13 02:06:50 -05:00
|
|
|
|
|
|
|
case 'UIOperationHistoryRedo:TabbarOperations':
|
|
|
|
switch (aEvent.entry.name)
|
|
|
|
{
|
|
|
|
case 'treestyletab-changeTabbarPosition':
|
2011-01-22 10:46:29 -05:00
|
|
|
this.position = aEvent.entry.data.newPosition;
|
|
|
|
return;
|
|
|
|
case 'treestyletab-changeTabbarPosition-private':
|
|
|
|
aEvent.entry.data.target.treeStyleTab.position = aEvent.entry.data.newPosition;
|
2010-01-13 02:06:50 -05:00
|
|
|
return;
|
|
|
|
}
|
2010-05-08 04:30:39 -04:00
|
|
|
return;
|
2007-10-16 13:22:28 -04:00
|
|
|
}
|
|
|
|
},
|
2008-11-09 23:48:11 -05:00
|
|
|
|
2009-08-14 02:12:08 -04:00
|
|
|
keyEventListening : false,
|
|
|
|
keyEventListeningFlags : 0,
|
|
|
|
|
|
|
|
LISTEN_FOR_AUTOHIDE : 1,
|
|
|
|
LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE : 2,
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
startListenKeyEventsFor : function TSTWindow_startListenKeyEventsFor(aReason)
|
2009-08-14 02:12:08 -04:00
|
|
|
{
|
2013-09-17 05:17:20 -04:00
|
|
|
if (this.keyEventListeningFlags & aReason)
|
|
|
|
return;
|
2009-08-14 02:12:08 -04:00
|
|
|
if (!this.keyEventListening) {
|
2011-05-25 17:23:02 -04:00
|
|
|
let w = this.window;
|
|
|
|
w.addEventListener('keydown', this, true);
|
|
|
|
w.addEventListener('keyup', this, true);
|
|
|
|
w.addEventListener('keypress', this, true);
|
2014-02-06 10:40:23 -05:00
|
|
|
w.addEventListener('blur', this, true);
|
2009-08-14 02:12:08 -04:00
|
|
|
this.keyEventListening = true;
|
|
|
|
}
|
|
|
|
this.keyEventListeningFlags |= aReason;
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
endListenKeyEventsFor : function TSTWindow_endListenKeyEventsFor(aReason)
|
2009-08-14 02:12:08 -04:00
|
|
|
{
|
2013-09-17 05:17:20 -04:00
|
|
|
if (!(this.keyEventListeningFlags & aReason))
|
|
|
|
return;
|
2009-08-14 02:12:08 -04:00
|
|
|
this.keyEventListeningFlags ^= aReason;
|
|
|
|
if (!this.keyEventListeningFlags && this.keyEventListening) {
|
2011-05-25 17:23:02 -04:00
|
|
|
let w = this.window;
|
|
|
|
w.removeEventListener('keydown', this, true);
|
|
|
|
w.removeEventListener('keyup', this, true);
|
|
|
|
w.removeEventListener('keypress', this, true);
|
2014-02-06 10:40:23 -05:00
|
|
|
w.removeEventListener('blur', this, true);
|
2009-08-14 02:12:08 -04:00
|
|
|
this.keyEventListening = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onKeyDown : function TSTWindow_onKeyDown(aEvent)
|
2008-03-08 03:57:17 -05:00
|
|
|
{
|
2010-09-15 06:41:52 -04:00
|
|
|
/**
|
|
|
|
* On Mac OS X, default accel key is the Command key (metaKey), but
|
|
|
|
* Cmd-Tab is used to switch applications by the OS itself. So Firefox
|
|
|
|
* uses Ctrl-Tab to switch tabs on all platforms.
|
|
|
|
*/
|
|
|
|
// this.accelKeyPressed = this.isAccelKeyPressed(aEvent);
|
|
|
|
this.accelKeyPressed = aEvent.ctrlKey || aEvent.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_CONTROL;
|
2009-09-03 03:25:37 -04:00
|
|
|
|
2011-12-02 15:01:38 -05:00
|
|
|
var left = aEvent.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_LEFT;
|
|
|
|
var right = aEvent.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_RIGHT;
|
|
|
|
var up = aEvent.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_UP;
|
|
|
|
var down = aEvent.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_DOWN;
|
|
|
|
if (
|
2013-11-06 08:10:04 -05:00
|
|
|
Services.focus.focusedElement == this.browser.selectedTab &&
|
2011-12-02 15:01:38 -05:00
|
|
|
(up || down || left || right)
|
|
|
|
)
|
|
|
|
this.arrowKeyEventOnTab = {
|
|
|
|
keyCode : aEvent.keyCode,
|
|
|
|
left : left,
|
|
|
|
right : right,
|
|
|
|
up : up,
|
|
|
|
down : down,
|
|
|
|
altKey : aEvent.altKey,
|
|
|
|
ctrlKey : aEvent.ctrlKey,
|
|
|
|
metaKey : aEvent.metaKey,
|
|
|
|
shiftKey : aEvent.shiftKey
|
|
|
|
};
|
|
|
|
|
2009-12-26 00:21:31 -05:00
|
|
|
var b = this.browser;
|
2011-01-11 05:29:14 -05:00
|
|
|
var data = {
|
|
|
|
sourceEvent : aEvent
|
|
|
|
};
|
2010-12-20 06:54:42 -05:00
|
|
|
|
2011-01-11 05:29:14 -05:00
|
|
|
/* PUBLIC API */
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN, b, true, false, data);
|
2010-12-20 06:54:42 -05:00
|
|
|
// for backward compatibility
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN.replace(/^nsDOM/, ''), b, true, false, data);
|
2008-03-08 03:57:17 -05:00
|
|
|
},
|
2008-03-09 08:18:58 -04:00
|
|
|
accelKeyPressed : false,
|
2011-12-02 15:01:38 -05:00
|
|
|
arrowKeyEventOnTab : null,
|
2008-03-08 05:07:28 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onKeyRelease : function TSTWindow_onKeyRelease(aEvent)
|
2008-03-08 03:57:17 -05:00
|
|
|
{
|
|
|
|
var b = this.browser;
|
2013-09-17 05:17:20 -04:00
|
|
|
if (!b || !b.treeStyleTab)
|
|
|
|
return;
|
2008-03-08 03:57:17 -05:00
|
|
|
var sv = b.treeStyleTab;
|
|
|
|
|
|
|
|
var scrollDown,
|
|
|
|
scrollUp;
|
|
|
|
|
2010-09-15 06:41:52 -04:00
|
|
|
// this.accelKeyPressed = this.isAccelKeyPressed(aEvent);
|
|
|
|
this.accelKeyPressed = aEvent.ctrlKey || aEvent.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_CONTROL;
|
2011-12-02 15:01:38 -05:00
|
|
|
this.window.setTimeout(function(aSelf) {
|
|
|
|
aSelf.arrowKeyEventOnTab = null;
|
|
|
|
}, 10, this);
|
2008-03-09 08:34:10 -04:00
|
|
|
|
2009-05-12 14:21:44 -04:00
|
|
|
var standBy = scrollDown = scrollUp = (!aEvent.altKey && this.accelKeyPressed);
|
2008-03-08 03:57:17 -05:00
|
|
|
|
|
|
|
scrollDown = scrollDown && (
|
|
|
|
!aEvent.shiftKey &&
|
|
|
|
(
|
|
|
|
aEvent.keyCode == aEvent.DOM_VK_TAB ||
|
|
|
|
aEvent.keyCode == aEvent.DOM_VK_PAGE_DOWN
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
scrollUp = scrollUp && (
|
|
|
|
aEvent.shiftKey ? (aEvent.keyCode == aEvent.DOM_VK_TAB) : (aEvent.keyCode == aEvent.DOM_VK_PAGE_UP)
|
|
|
|
);
|
|
|
|
|
2009-11-09 10:07:14 -05:00
|
|
|
var onlyShiftKey = (!aEvent.shiftKey && aEvent.keyCode == 16 && (aEvent.type == 'keyup' || aEvent.charCode == 0));
|
2009-09-03 03:25:37 -04:00
|
|
|
|
2011-01-11 05:29:14 -05:00
|
|
|
var data = {
|
|
|
|
scrollDown : scrollDown,
|
|
|
|
scrollUp : scrollUp,
|
|
|
|
standBy : standBy,
|
|
|
|
onlyShiftKey : onlyShiftKey,
|
|
|
|
sourceEvent : aEvent
|
|
|
|
};
|
|
|
|
|
2008-03-08 03:57:17 -05:00
|
|
|
if (
|
|
|
|
scrollDown ||
|
|
|
|
scrollUp ||
|
|
|
|
( // when you release "shift" key
|
2009-09-03 03:25:37 -04:00
|
|
|
standBy && onlyShiftKey
|
2008-03-08 03:57:17 -05:00
|
|
|
)
|
|
|
|
) {
|
2009-09-03 03:25:37 -04:00
|
|
|
/* PUBLIC API */
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START, b, true, false, data);
|
2011-01-10 23:20:01 -05:00
|
|
|
// for backward compatibility
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START.replace(/^nsDOM/, ''), b, true, false, data);
|
2008-03-08 03:57:17 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-08 11:13:29 -04:00
|
|
|
if (aEvent.type == 'keypress' ?
|
|
|
|
// ignore keypress on Ctrl-R, Ctrl-T, etc.
|
|
|
|
aEvent.charCode != 0 :
|
|
|
|
// ignore keyup not on the Ctrl key
|
|
|
|
aEvent.keyCode != Ci.nsIDOMKeyEvent.DOM_VK_CONTROL
|
|
|
|
)
|
|
|
|
return;
|
|
|
|
|
2009-08-14 02:12:08 -04:00
|
|
|
// when you just release accel key...
|
|
|
|
|
2009-09-03 03:25:37 -04:00
|
|
|
/* PUBLIC API */
|
|
|
|
let (event) {
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END, b, true, false, data);
|
2011-01-10 23:20:01 -05:00
|
|
|
// for backward compatibility
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END.replace(/^nsDOM/, ''), b, true, false, data);
|
2009-09-03 03:25:37 -04:00
|
|
|
}
|
2009-08-14 02:12:08 -04:00
|
|
|
|
|
|
|
if (this._tabShouldBeExpandedAfterKeyReleased) {
|
|
|
|
let tab = this._tabShouldBeExpandedAfterKeyReleased;
|
|
|
|
if (this.hasChildTabs(tab) &&
|
2009-10-25 22:36:42 -04:00
|
|
|
this.isSubtreeCollapsed(tab)) {
|
2009-08-14 02:12:08 -04:00
|
|
|
this.getTabBrowserFromChild(tab)
|
|
|
|
.treeStyleTab
|
|
|
|
.collapseExpandTreesIntelligentlyFor(tab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this._tabShouldBeExpandedAfterKeyReleased = null;
|
2008-03-08 03:57:17 -05:00
|
|
|
},
|
2014-02-06 10:40:23 -05:00
|
|
|
// When the window lose its focus, we cannot detect any key-release events.
|
|
|
|
// So we have to simulate key-release event manually.
|
|
|
|
// See: https://github.com/piroor/treestyletab/issues/654
|
|
|
|
simulateKeyRelease : function TSTWindow_simulateKeyRelease()
|
|
|
|
{
|
|
|
|
if (!this.accelKeyPressed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.accelKeyPressed = false;
|
|
|
|
var data = {
|
|
|
|
scrollDown : false,
|
|
|
|
scrollUp : false,
|
|
|
|
standBy : false,
|
|
|
|
onlyShiftKey : false,
|
|
|
|
sourceEvent : null
|
|
|
|
};
|
|
|
|
/* PUBLIC API */
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END, this.browser, true, false, data);
|
2014-02-06 10:40:23 -05:00
|
|
|
// for backward compatibility
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END.replace(/^nsDOM/, ''), this.browser, true, false, data);
|
2014-02-06 10:40:23 -05:00
|
|
|
},
|
2008-09-26 10:13:29 -04:00
|
|
|
|
2009-08-14 02:30:03 -04:00
|
|
|
get shouldListenKeyEventsForAutoExpandByFocusChange()
|
|
|
|
{
|
2009-08-14 10:51:01 -04:00
|
|
|
return !this.ctrlTabPreviewsEnabled &&
|
2011-11-29 12:21:33 -05:00
|
|
|
(
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut') ||
|
|
|
|
utils.getTreePref('autoCollapseExpandSubtreeOnSelect')
|
2011-11-29 12:21:33 -05:00
|
|
|
);
|
2009-08-14 02:30:03 -04:00
|
|
|
},
|
|
|
|
|
2009-08-14 10:51:01 -04:00
|
|
|
get ctrlTabPreviewsEnabled()
|
|
|
|
{
|
2011-05-25 16:54:46 -04:00
|
|
|
return 'allTabs' in this.window &&
|
2013-01-05 21:47:50 -05:00
|
|
|
prefs.getPref('browser.ctrlTab.previews');
|
2009-08-14 10:51:01 -04:00
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
2014-03-31 01:54:14 -04:00
|
|
|
receiveMessage : function TSTWindow_receiveMessage(aMessage)
|
|
|
|
{
|
|
|
|
var browser = aMessage.target;
|
|
|
|
var tabbrowser = this.getTabBrowserFromChild(browser);
|
|
|
|
if (!tabbrowser)
|
|
|
|
return;
|
|
|
|
var tab = tabbrowser.treeStyleTab.getTabFromBrowser(browser);
|
|
|
|
if (!tab)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (aMessage.name)
|
|
|
|
{
|
|
|
|
case 'SessionStore:restoreTabContentStarted':
|
|
|
|
return tabbrowser.treeStyleTab.onRestoreTabContentStarted(tab);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onTabbarResizeStart : function TSTWindow_onTabbarResizeStart(aEvent)
|
2009-09-08 05:59:23 -04:00
|
|
|
{
|
2011-04-26 12:09:30 -04:00
|
|
|
if (aEvent.button != 0)
|
|
|
|
return;
|
|
|
|
|
2011-02-13 21:06:59 -05:00
|
|
|
if (!this.isEventFiredOnGrippy(aEvent))
|
|
|
|
aEvent.stopPropagation();
|
2010-09-12 23:54:04 -04:00
|
|
|
|
|
|
|
if ('setCapture' in aEvent.currentTarget)
|
|
|
|
aEvent.currentTarget.setCapture(true);
|
|
|
|
|
|
|
|
aEvent.currentTarget.addEventListener('mousemove', this, false);
|
|
|
|
|
|
|
|
var b = this.getTabBrowserFromChild(aEvent.currentTarget);
|
|
|
|
var box = aEvent.currentTarget.id == 'treestyletab-tabbar-resizer-splitter' ?
|
|
|
|
this.getTabStrip(b) :
|
2010-09-13 10:45:33 -04:00
|
|
|
b.treeStyleTab.tabStripPlaceHolder || b.tabContainer ;
|
2010-09-12 23:54:04 -04:00
|
|
|
this.tabbarResizeStartWidth = box.boxObject.width;
|
|
|
|
this.tabbarResizeStartHeight = box.boxObject.height;
|
|
|
|
this.tabbarResizeStartX = aEvent.screenX;
|
|
|
|
this.tabbarResizeStartY = aEvent.screenY;
|
2010-09-10 06:21:26 -04:00
|
|
|
},
|
2011-05-25 16:54:46 -04:00
|
|
|
onTabbarResizeEnd : function TSTWindow_onTabbarResizeEnd(aEvent)
|
2010-09-10 06:21:26 -04:00
|
|
|
{
|
2010-09-12 23:54:04 -04:00
|
|
|
if (this.tabbarResizeStartWidth < 0)
|
|
|
|
return;
|
|
|
|
|
2011-04-06 09:04:02 -04:00
|
|
|
var target = aEvent.currentTarget;
|
|
|
|
var b = this.getTabBrowserFromChild(target);
|
|
|
|
|
2010-09-10 06:21:26 -04:00
|
|
|
aEvent.stopPropagation();
|
2011-04-06 09:04:02 -04:00
|
|
|
if ('releaseCapture' in target)
|
|
|
|
target.releaseCapture();
|
2010-09-12 23:54:04 -04:00
|
|
|
|
2011-04-06 09:04:02 -04:00
|
|
|
target.removeEventListener('mousemove', this, false);
|
2010-09-12 23:54:04 -04:00
|
|
|
|
|
|
|
this.tabbarResizeStartWidth = -1;
|
|
|
|
this.tabbarResizeStartHeight = -1;
|
|
|
|
this.tabbarResizeStartX = -1;
|
|
|
|
this.tabbarResizeStartY = -1;
|
|
|
|
|
2011-04-06 09:04:02 -04:00
|
|
|
this.Deferred.next(function() {
|
|
|
|
b.treeStyleTab.fixTooNarrowTabbar();
|
2012-02-06 12:13:46 -05:00
|
|
|
}).error(this.defaultDeferredErrorHandler);
|
2010-09-10 06:21:26 -04:00
|
|
|
},
|
2011-05-25 16:54:46 -04:00
|
|
|
onTabbarResizing : function TSTWindow_onTabbarResizing(aEvent)
|
2010-09-10 06:21:26 -04:00
|
|
|
{
|
2010-09-12 23:54:04 -04:00
|
|
|
var target = aEvent.currentTarget;
|
|
|
|
var b = this.getTabBrowserFromChild(target);
|
2010-09-10 06:21:26 -04:00
|
|
|
|
2010-09-12 23:54:04 -04:00
|
|
|
var expanded = target.id == 'treestyletab-tabbar-resizer-splitter';
|
|
|
|
if (expanded)
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
|
|
|
|
var width = this.tabbarResizeStartWidth;
|
|
|
|
var height = this.tabbarResizeStartHeight;
|
2011-01-22 10:46:29 -05:00
|
|
|
var pos = b.treeStyleTab.position;
|
2010-09-10 06:21:26 -04:00
|
|
|
if (b.treeStyleTab.isVertical) {
|
2010-09-12 23:54:04 -04:00
|
|
|
let delta = aEvent.screenX - this.tabbarResizeStartX;
|
2010-09-10 06:21:26 -04:00
|
|
|
width += (pos == 'left' ? delta : -delta );
|
2010-09-12 23:54:04 -04:00
|
|
|
width = this.maxTabbarWidth(width, b);
|
|
|
|
if (expanded || b.treeStyleTab.autoHide.expanded) {
|
2011-04-06 08:05:59 -04:00
|
|
|
this.setPrefForActiveWindow(function() {
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('tabbar.width', width);
|
2011-04-06 08:05:59 -04:00
|
|
|
});
|
2010-09-12 23:54:04 -04:00
|
|
|
if (b.treeStyleTab.autoHide.mode == b.treeStyleTab.autoHide.kMODE_SHRINK &&
|
|
|
|
b.treeStyleTab.tabStripPlaceHolder)
|
2012-10-23 12:43:56 -04:00
|
|
|
b.treeStyleTab.tabStripPlaceHolder.setAttribute('width', utils.getTreePref('tabbar.shrunkenWidth'));
|
2010-09-12 23:54:04 -04:00
|
|
|
}
|
|
|
|
else {
|
2011-04-06 08:05:59 -04:00
|
|
|
this.setPrefForActiveWindow(function() {
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('tabbar.shrunkenWidth', width);
|
2011-04-06 08:05:59 -04:00
|
|
|
});
|
2010-09-12 23:54:04 -04:00
|
|
|
}
|
2010-09-10 06:21:26 -04:00
|
|
|
}
|
|
|
|
else {
|
2010-09-12 23:54:04 -04:00
|
|
|
let delta = aEvent.screenY - this.tabbarResizeStartY;
|
2010-09-10 06:21:26 -04:00
|
|
|
height += (pos == 'top' ? delta : -delta );
|
2011-04-06 08:05:59 -04:00
|
|
|
this.setPrefForActiveWindow(function() {
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('tabbar.height', this.maxTabbarHeight(height, b));
|
2011-04-06 08:05:59 -04:00
|
|
|
});
|
2010-09-10 06:21:26 -04:00
|
|
|
}
|
2010-12-03 09:50:42 -05:00
|
|
|
b.treeStyleTab.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_TABBAR_RESIZE);
|
2010-09-10 06:21:26 -04:00
|
|
|
},
|
2010-09-12 23:54:04 -04:00
|
|
|
tabbarResizeStartWidth : -1,
|
|
|
|
tabbarResizeStartHeight : -1,
|
|
|
|
tabbarResizeStartX : -1,
|
|
|
|
tabbarResizeStartY : -1,
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onTabbarReset : function TSTWindow_onTabbarReset(aEvent)
|
2010-09-12 23:54:04 -04:00
|
|
|
{
|
2012-08-28 09:21:46 -04:00
|
|
|
if (aEvent.button != 0)
|
|
|
|
return;
|
2010-09-12 23:54:04 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aEvent.currentTarget);
|
|
|
|
if (b) {
|
|
|
|
b.treeStyleTab.resetTabbarSize();
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
}
|
|
|
|
},
|
2010-09-10 06:21:26 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onFocusNextTab : function TSTWindow_onFocusNextTab(aEvent)
|
2010-11-30 05:05:00 -05:00
|
|
|
{
|
2011-02-06 21:02:18 -05:00
|
|
|
var tab = aEvent.originalTarget;
|
|
|
|
var b = this.getTabBrowserFromChild(tab);
|
2010-11-30 05:05:00 -05:00
|
|
|
if (
|
2013-01-05 21:47:50 -05:00
|
|
|
prefs.getPref('browser.tabs.selectOwnerOnClose') &&
|
2010-11-30 05:05:00 -05:00
|
|
|
tab.owner &&
|
|
|
|
(
|
2011-02-06 21:02:18 -05:00
|
|
|
!b._removingTabs ||
|
|
|
|
b._removingTabs.indexOf(tab.owner) < 0
|
2010-11-30 05:05:00 -05:00
|
|
|
)
|
|
|
|
)
|
|
|
|
aEvent.preventDefault();
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
showHideSubtreeMenuItem : function TSTWindow_showHideSubtreeMenuItem(aMenuItem, aTabs)
|
2007-10-20 12:47:08 -04:00
|
|
|
{
|
2007-11-14 14:34:36 -05:00
|
|
|
if (!aMenuItem ||
|
|
|
|
aMenuItem.getAttribute('hidden') == 'true' ||
|
|
|
|
!aTabs ||
|
|
|
|
!aTabs.length)
|
2007-11-12 10:29:12 -05:00
|
|
|
return;
|
2007-10-20 12:47:08 -04:00
|
|
|
|
2009-12-25 06:19:50 -05:00
|
|
|
var hasSubtree = false;
|
2007-11-14 14:34:36 -05:00
|
|
|
for (var i = 0, maxi = aTabs.length; i < maxi; i++)
|
2007-10-20 12:47:08 -04:00
|
|
|
{
|
2013-09-17 05:17:20 -04:00
|
|
|
if (!this.hasChildTabs(aTabs[i]))
|
|
|
|
continue;
|
2009-12-25 06:19:50 -05:00
|
|
|
hasSubtree = true;
|
2007-10-20 12:47:08 -04:00
|
|
|
break;
|
|
|
|
}
|
2009-12-25 06:19:50 -05:00
|
|
|
if (hasSubtree)
|
2007-11-14 14:34:36 -05:00
|
|
|
aMenuItem.removeAttribute('hidden');
|
|
|
|
else
|
|
|
|
aMenuItem.setAttribute('hidden', true);
|
2007-10-20 12:47:08 -04:00
|
|
|
},
|
2013-11-06 10:27:24 -05:00
|
|
|
showHideSubTreeMenuItem : function(...aArgs) {
|
|
|
|
return this.showHideSubtreeMenuItem.apply(this, aArgs);
|
|
|
|
}, // obsolete, for backward compatibility
|
2009-05-13 02:09:17 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
updateAeroPeekPreviews : function TSTWindow_updateAeroPeekPreviews()
|
2010-04-06 09:38:05 -04:00
|
|
|
{
|
2011-05-25 17:23:02 -04:00
|
|
|
var w = this.window;
|
2010-04-06 09:38:05 -04:00
|
|
|
if (
|
|
|
|
this.updateAeroPeekPreviewsTimer ||
|
2013-01-05 21:47:50 -05:00
|
|
|
!prefs.getPref('browser.taskbar.previews.enable') ||
|
2012-10-23 12:43:56 -04:00
|
|
|
!utils.getTreePref('taskbarPreviews.hideCollapsedTabs') ||
|
2011-05-25 17:23:02 -04:00
|
|
|
!('Win7Features' in w) ||
|
|
|
|
!w.Win7Features ||
|
2010-04-06 09:38:05 -04:00
|
|
|
!this.AeroPeek ||
|
|
|
|
!this.AeroPeek.windows
|
|
|
|
)
|
|
|
|
return;
|
|
|
|
|
2011-05-25 17:23:02 -04:00
|
|
|
this.updateAeroPeekPreviewsTimer = w.setTimeout(function(aSelf) {
|
2010-04-06 09:38:05 -04:00
|
|
|
aSelf.updateAeroPeekPreviewsTimer = null;
|
2010-04-06 09:59:13 -04:00
|
|
|
try {
|
|
|
|
aSelf.updateAeroPeekPreviewsInternal();
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
dump(e+'\n');
|
|
|
|
aSelf.updateAeroPeekPreviews();
|
|
|
|
}
|
|
|
|
}, 250, this);
|
2010-04-06 09:38:05 -04:00
|
|
|
},
|
|
|
|
updateAeroPeekPreviewsTimer : null,
|
2011-05-25 16:54:46 -04:00
|
|
|
updateAeroPeekPreviewsInternal : function TSTWindow_updateAeroPeekPreviewsInternal()
|
2010-04-06 09:38:05 -04:00
|
|
|
{
|
2010-05-06 05:56:39 -04:00
|
|
|
if (
|
2013-01-05 21:47:50 -05:00
|
|
|
!prefs.getPref('browser.taskbar.previews.enable') ||
|
2012-10-23 12:43:56 -04:00
|
|
|
!utils.getTreePref('taskbarPreviews.hideCollapsedTabs')
|
2010-05-06 05:56:39 -04:00
|
|
|
)
|
|
|
|
return;
|
|
|
|
|
2010-04-06 09:38:05 -04:00
|
|
|
this.AeroPeek.windows.some(function(aTabWindow) {
|
2011-05-25 16:54:46 -04:00
|
|
|
if (aTabWindow.win == this.window) {
|
2012-02-04 16:31:03 -05:00
|
|
|
let previews = aTabWindow.previews;
|
|
|
|
for (let i = 0, maxi = previews.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let preview = previews[i];
|
2013-09-17 05:17:20 -04:00
|
|
|
if (!preview)
|
|
|
|
continue;
|
2012-02-04 13:15:38 -05:00
|
|
|
let tab = preview.controller.wrappedJSObject.tab;
|
|
|
|
preview.visible = !this.isCollapsed(tab);
|
|
|
|
}
|
2010-04-06 09:38:05 -04:00
|
|
|
this.AeroPeek.checkPreviewCount();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}, this);
|
|
|
|
},
|
2010-05-15 10:05:02 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
updateTabsOnTop : function TSTWindow_updateTabsOnTop()
|
2010-05-15 10:05:02 -04:00
|
|
|
{
|
2012-04-09 07:18:52 -04:00
|
|
|
if (
|
|
|
|
this.isPopupWindow ||
|
|
|
|
this.tabsOnTopChangingByUI ||
|
2013-11-19 09:23:25 -05:00
|
|
|
this.tabsOnTopChangingByTST
|
2012-04-09 07:18:52 -04:00
|
|
|
)
|
2010-05-15 10:05:02 -04:00
|
|
|
return;
|
|
|
|
|
2013-11-19 09:23:25 -05:00
|
|
|
var TabsOnTop = this.window.TabsOnTop;
|
|
|
|
var TabsInTitlebar = this.window.TabsInTitlebar;
|
|
|
|
var isTopTabbar = this.browser.treeStyleTab.position == 'top';
|
|
|
|
|
2012-04-09 07:18:52 -04:00
|
|
|
this.tabsOnTopChangingByTST = true;
|
|
|
|
|
|
|
|
try {
|
2013-11-19 09:23:25 -05:00
|
|
|
if (TabsOnTop) {
|
|
|
|
let originalState = utils.getTreePref('tabsOnTop.originalState');
|
|
|
|
if (originalState === null) {
|
|
|
|
let current = prefs.getDefaultPref('browser.tabs.onTop') === null ?
|
|
|
|
TabsOnTop.enabled :
|
|
|
|
prefs.getPref('browser.tabs.onTop') ;
|
|
|
|
utils.setTreePref('tabsOnTop.originalState', originalState = current);
|
|
|
|
}
|
2010-05-15 10:05:02 -04:00
|
|
|
|
2013-11-19 09:23:25 -05:00
|
|
|
if (!isTopTabbar || !this.browser.treeStyleTab.fixed) {
|
|
|
|
if (TabsOnTop.enabled)
|
|
|
|
TabsOnTop.enabled = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (TabsOnTop.enabled != originalState)
|
|
|
|
TabsOnTop.enabled = originalState;
|
|
|
|
utils.clearTreePref('tabsOnTop.originalState');
|
|
|
|
}
|
2011-05-04 17:25:40 -04:00
|
|
|
}
|
2013-11-20 09:38:12 -05:00
|
|
|
if (TabsInTitlebar) {
|
2013-11-28 11:22:18 -05:00
|
|
|
let allowed = isTopTabbar && this.browser.treeStyleTab.fixed;
|
2014-04-01 14:43:42 -04:00
|
|
|
if (
|
2014-05-05 04:46:29 -04:00
|
|
|
(this.window.TabsOnBottom && utils.getTreePref('compatibility.TabsOnBottom')) ||
|
2014-04-01 14:43:42 -04:00
|
|
|
('navbarontop' in this.window && utils.getTreePref('compatibility.NavbarOnTitlebar')) ||
|
|
|
|
('classicthemerestorerjs' in this.window && utils.getTreePref('compatibility.ClassicThemeRestorer'))
|
|
|
|
)
|
2013-12-06 04:10:54 -05:00
|
|
|
allowed = true;
|
2013-11-20 10:01:39 -05:00
|
|
|
TabsInTitlebar.allowedBy('TreeStyleTab-tabsOnTop', allowed);
|
2013-11-20 09:38:12 -05:00
|
|
|
}
|
2010-05-15 10:05:02 -04:00
|
|
|
}
|
2012-04-09 07:18:52 -04:00
|
|
|
finally {
|
|
|
|
this.tabsOnTopChangingByTST = false;
|
2010-05-15 10:05:02 -04:00
|
|
|
}
|
|
|
|
},
|
2010-09-10 06:21:26 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onPopupShown : function TSTWindow_onPopupShown(aPopup)
|
2010-09-10 06:21:26 -04:00
|
|
|
{
|
|
|
|
if (!aPopup.boxObject ||
|
|
|
|
this.evaluateXPath(
|
2012-09-23 03:08:08 -04:00
|
|
|
'parent::*/ancestor-or-self::*[local-name()="tooltip" or local-name()="panel" or local-name()="popup" or local-name()="menupopup"]',
|
2010-09-10 06:48:49 -04:00
|
|
|
aPopup,
|
2011-04-06 01:02:00 -04:00
|
|
|
Ci.nsIDOMXPathResult.BOOLEAN_TYPE
|
2010-09-10 06:21:26 -04:00
|
|
|
).booleanValue)
|
|
|
|
return;
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
this.window.setTimeout(function(aSelf) {
|
2010-09-10 09:06:43 -04:00
|
|
|
if ((!aPopup.boxObject.width && !aPopup.boxObject.height) ||
|
|
|
|
aPopup.boxObject.popupState == 'closed')
|
2010-09-10 06:21:26 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
var id = aPopup.id;
|
2011-05-25 16:54:46 -04:00
|
|
|
var item = id && aSelf.document.getElementById(id) ? id : aPopup ;
|
|
|
|
var index = aSelf._shownPopups.indexOf(item);
|
2010-09-10 06:21:26 -04:00
|
|
|
if (index < 0)
|
2011-05-25 16:54:46 -04:00
|
|
|
aSelf._shownPopups.push(item);
|
2010-09-10 06:21:26 -04:00
|
|
|
}, 10, this);
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onPopupHidden : function TSTWindow_onPopupHidden(aPopup)
|
2010-09-10 06:21:26 -04:00
|
|
|
{
|
|
|
|
var id = aPopup.id;
|
2011-05-25 16:54:46 -04:00
|
|
|
aPopup = id && this.document.getElementById(id) ? id : aPopup ;
|
|
|
|
var index = this._shownPopups.indexOf(aPopup);
|
2010-09-10 06:21:26 -04:00
|
|
|
if (index > -1)
|
2011-05-25 16:54:46 -04:00
|
|
|
this._shownPopups.splice(index, 1);
|
2010-09-10 06:21:26 -04:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
isPopupShown : function TSTWindow_isPopupShown()
|
2010-09-10 06:21:26 -04:00
|
|
|
{
|
2011-05-25 16:54:46 -04:00
|
|
|
this._shownPopups = this._shownPopups.filter(function(aItem) {
|
2010-09-10 06:21:26 -04:00
|
|
|
if (typeof aItem == 'string')
|
2011-05-25 16:54:46 -04:00
|
|
|
aItem = this.document.getElementById(aItem);
|
2012-12-04 21:35:37 -05:00
|
|
|
return (
|
|
|
|
aItem &&
|
|
|
|
aItem.getAttribute(this.kIGNORE_POPUP_STATE) != 'true' &&
|
|
|
|
aItem.boxObject &&
|
|
|
|
(aItem.boxObject.width || aItem.boxObject.height) &&
|
|
|
|
aItem.state != 'closed'
|
|
|
|
);
|
2011-06-05 12:05:22 -04:00
|
|
|
}, this);
|
2011-05-25 16:54:46 -04:00
|
|
|
return this._shownPopups.length > 0;
|
2010-09-10 06:21:26 -04:00
|
|
|
},
|
2011-01-25 10:01:37 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onBeforeNewTabCommand : function TSTWindow_onBeforeNewTabCommand(aTabBrowser)
|
2011-05-24 22:27:33 -04:00
|
|
|
{
|
2012-02-28 12:28:05 -05:00
|
|
|
var self = this.windowService || this;
|
|
|
|
if (self._clickEventOnNewTabButtonHandled)
|
|
|
|
return;
|
|
|
|
|
2011-05-24 22:27:33 -04:00
|
|
|
var b = aTabBrowser || this.browser;
|
2013-03-05 12:54:04 -05:00
|
|
|
this.readyToOpenRelatedTabAs(b.selectedTab, utils.getTreePref('autoAttach.newTabCommand'));
|
2011-01-25 10:01:37 -05:00
|
|
|
},
|
2011-05-04 14:55:40 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
handleNewTabActionOnButton : function TSTWindow_handleNewTabActionOnButton(aEvent)
|
2011-05-04 14:55:40 -04:00
|
|
|
{
|
2011-05-24 22:53:22 -04:00
|
|
|
// ignore non new-tab commands (middle click, Ctrl-click)
|
|
|
|
if (aEvent.button != 1 && (aEvent.button != 0 || !this.isAccelKeyPressed(aEvent)))
|
|
|
|
return;
|
|
|
|
|
2012-02-28 12:28:05 -05:00
|
|
|
var newTabButton = this.getNewTabButtonFromEvent(aEvent);
|
|
|
|
if (newTabButton) {
|
2013-03-05 12:54:04 -05:00
|
|
|
this.readyToOpenRelatedTabAs(this.browser.selectedTab, utils.getTreePref('autoAttach.newTabButton'));
|
2012-02-28 12:28:05 -05:00
|
|
|
let self = this.windowService || this;
|
|
|
|
self._clickEventOnNewTabButtonHandled = true;
|
|
|
|
this.Deferred.next(function() {
|
|
|
|
self._clickEventOnNewTabButtonHandled = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (aEvent.target.id == 'urlbar-go-button' || aEvent.target.id == 'go-button') {
|
2013-03-05 12:54:04 -05:00
|
|
|
this.readyToOpenRelatedTabAs(this.browser.selectedTab, utils.getTreePref('autoAttach.goButton'));
|
2012-02-28 12:28:05 -05:00
|
|
|
}
|
2011-05-04 14:55:40 -04:00
|
|
|
},
|
2012-02-28 12:28:05 -05:00
|
|
|
_clickEventOnNewTabButtonHandled : false,
|
2011-05-24 14:27:53 -04:00
|
|
|
|
2012-09-23 01:57:29 -04:00
|
|
|
onBeforeTabDuplicate : function TSTWindow_onBeforeTabDuplicate(aTab, aWhere, aDelta)
|
2011-05-24 14:27:53 -04:00
|
|
|
{
|
2012-09-14 23:32:58 -04:00
|
|
|
if (aWhere && aWhere.indexOf('tab') != 0)
|
|
|
|
return;
|
|
|
|
|
2011-05-24 22:53:22 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
2012-09-23 01:57:29 -04:00
|
|
|
var behaviorPref = !aDelta ? 'autoAttach.duplicateTabCommand' :
|
|
|
|
aDelta < 0 ? 'autoAttach.duplicateTabCommand.back' :
|
|
|
|
'autoAttach.duplicateTabCommand.forward'
|
2012-10-23 12:43:56 -04:00
|
|
|
var behavior = utils.getTreePref(behaviorPref);
|
2013-03-05 12:54:04 -05:00
|
|
|
this.readyToOpenRelatedTabAs(aTab || b.selectedTab, behavior);
|
2011-05-24 14:27:53 -04:00
|
|
|
},
|
2012-09-14 23:09:15 -04:00
|
|
|
|
|
|
|
onBeforeOpenLink : function TSTWindow_onBeforeOpenLink(aWhere, aOwner)
|
|
|
|
{
|
|
|
|
if (aWhere == 'tab' || aWhere == 'tabshifted')
|
2013-03-05 12:37:21 -05:00
|
|
|
this.handleNewTabFromCurrent(aOwner);
|
2012-09-14 23:09:15 -04:00
|
|
|
},
|
|
|
|
|
2014-09-30 02:12:29 -04:00
|
|
|
onBeforeOpenLinkWithTab : function TSTWindow_onBeforeOpenLinkWithTab(aTab, aFromChrome)
|
2012-09-14 23:09:15 -04:00
|
|
|
{
|
2014-09-30 02:12:29 -04:00
|
|
|
if (!aFromChrome && aTab && !this.checkToOpenChildTab(aTab))
|
2014-08-27 19:12:39 -04:00
|
|
|
this.handleNewTabFromCurrent(aTab);
|
2012-09-14 23:09:15 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
onBeforeOpenNewTabByThirdParty : function TSTWindow_onBeforeOpenNewTabByThirdParty(aOwner)
|
|
|
|
{
|
|
|
|
if (!this.checkToOpenChildTab(aOwner))
|
2013-03-05 12:37:21 -05:00
|
|
|
this.handleNewTabFromCurrent(aOwner);
|
2012-09-14 23:09:15 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
onBeforeBrowserAccessOpenURI : function TSTWindow_onBeforeBrowserAccessOpenURI(aOpener, aWhere)
|
|
|
|
{
|
2013-05-10 12:55:41 -04:00
|
|
|
if (aOpener &&
|
2013-07-02 06:47:41 -04:00
|
|
|
this.getTabFromFrame(aOpener.top) &&
|
2013-05-10 12:55:41 -04:00
|
|
|
aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWTAB)
|
2013-03-05 12:37:21 -05:00
|
|
|
this.handleNewTabFromCurrent(aOpener);
|
2012-09-14 23:09:15 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
onBeforeViewMedia : function TSTWindow_onBeforeViewMedia(aEvent, aOwner)
|
|
|
|
{
|
|
|
|
if (String(this.window.whereToOpenLink(aEvent, false, true)).indexOf('tab') == 0)
|
2013-03-05 12:37:21 -05:00
|
|
|
this.handleNewTabFromCurrent(aOwner);
|
2012-09-14 23:09:15 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
onBeforeBrowserSearch : function TSTWindow_onBeforeBrowserSearch(aTerm, aForceNewTab)
|
|
|
|
{
|
2012-09-15 08:53:22 -04:00
|
|
|
if ((arguments.length == 1 || aForceNewTab) &&
|
2012-09-14 23:09:15 -04:00
|
|
|
this.shouldOpenSearchResultAsChild(aTerm))
|
2013-03-05 12:37:21 -05:00
|
|
|
this.handleNewTabFromCurrent();
|
2012-09-14 23:09:15 -04:00
|
|
|
},
|
2007-10-20 12:47:08 -04:00
|
|
|
|
2012-08-28 08:53:25 -04:00
|
|
|
/* Tree Style Tabの初期化が行われる前に復元されたセッションについてツリー構造を復元 */
|
2008-11-09 23:48:11 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onTabRestored : function TSTWindow_onTabRestored(aEvent)
|
2008-11-09 23:48:11 -05:00
|
|
|
{
|
|
|
|
this._restoringTabs.push(aEvent.originalTarget);
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
processRestoredTabs : function TSTWindow_processRestoredTabs()
|
2008-11-09 23:48:11 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = this._restoringTabs.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let tab = this._restoringTabs[i];
|
2008-11-09 23:48:11 -05:00
|
|
|
try {
|
2012-02-04 13:15:38 -05:00
|
|
|
let b = this.getTabBrowserFromChild(aTab);
|
2013-09-17 05:17:20 -04:00
|
|
|
if (b)
|
|
|
|
b.treeStyleTab.handleRestoredTab(aTab);
|
2008-11-09 23:48:11 -05:00
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
}
|
2012-02-04 13:15:38 -05:00
|
|
|
}
|
2008-11-09 23:48:11 -05:00
|
|
|
this._restoringTabs = [];
|
|
|
|
},
|
|
|
|
|
2007-11-14 14:34:36 -05:00
|
|
|
/* Commands */
|
2008-11-09 23:48:11 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
setTabbarWidth : function TSTWindow_setTabbarWidth(aWidth, aForceExpanded) /* PUBLIC API */
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
2011-05-25 16:54:46 -04:00
|
|
|
this.browser.treeStyleTab.autoHide.setWidth(aWidth, aForceExpanded);
|
2009-12-25 13:13:33 -05:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
setContentWidth : function TSTWindow_setContentWidth(aWidth, aKeepWindowSize) /* PUBLIC API */
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
2011-05-25 17:23:02 -04:00
|
|
|
var w = this.window;
|
2011-05-25 16:54:46 -04:00
|
|
|
var treeStyleTab = this.browser.treeStyleTab;
|
2010-03-23 09:33:00 -04:00
|
|
|
var strip = treeStyleTab.tabStrip;
|
|
|
|
var tabbarWidth = treeStyleTab.splitterWidth + (treeStyleTab.isVertical ? strip.boxObject.width : 0 );
|
2011-05-25 16:54:46 -04:00
|
|
|
var contentWidth = this.browser.boxObject.width - tabbarWidth;
|
2009-12-25 13:13:33 -05:00
|
|
|
if (aKeepWindowSize ||
|
2011-05-25 17:23:02 -04:00
|
|
|
w.fullScreen ||
|
|
|
|
w.windowState != Ci.nsIDOMChromeWindow.STATE_NORMAL) {
|
2011-05-25 16:54:46 -04:00
|
|
|
this.setTabbarWidth(Math.max(10, this.browser.boxObject.width - aWidth));
|
2009-12-25 13:13:33 -05:00
|
|
|
}
|
2011-05-25 17:23:02 -04:00
|
|
|
else if (tabbarWidth + aWidth <= w.screen.availWidth) {
|
|
|
|
w.resizeBy(aWidth - contentWidth, 0);
|
2009-12-25 13:13:33 -05:00
|
|
|
}
|
|
|
|
else {
|
2011-05-25 17:23:02 -04:00
|
|
|
w.resizeBy(w.screen.availWidth - w.outerWidth, 0);
|
2011-05-25 16:54:46 -04:00
|
|
|
this.setTabbarWidth(this.browser.boxObject.width - aWidth);
|
2009-12-25 13:13:33 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
toggleAutoHide : function TSTWindow_toggleAutoHide(aTabBrowser) /* PUBLIC API, for backward compatibility */
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
this.autoHideWindow.toggleMode(aTabBrowser || this.browser);
|
2009-12-25 13:13:33 -05:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
toggleFixed : function TSTWindow_toggleFixed(aTabBrowser) /* PUBLIC API */
|
2009-12-25 13:13:33 -05:00
|
|
|
{
|
2010-05-08 02:22:49 -04:00
|
|
|
var b = aTabBrowser || this.browser;
|
|
|
|
var orient = b.treeStyleTab.isVertical ? 'vertical' : 'horizontal' ;
|
2009-12-25 13:13:33 -05:00
|
|
|
|
2010-05-08 02:22:49 -04:00
|
|
|
var newFixed = b.getAttribute(this.kFIXED+'-'+orient) != 'true';
|
2011-05-25 16:54:46 -04:00
|
|
|
this.setTabbrowserAttribute(this.kFIXED+'-'+orient, newFixed || null, b);
|
2011-04-06 08:05:59 -04:00
|
|
|
this.setPrefForActiveWindow(function() {
|
|
|
|
b.treeStyleTab.fixed = newFixed;
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('tabbar.fixed.'+orient, newFixed);
|
2011-04-06 08:05:59 -04:00
|
|
|
});
|
2010-05-08 02:22:49 -04:00
|
|
|
|
|
|
|
b.treeStyleTab.updateTabbarState();
|
2009-12-25 13:13:33 -05:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
removeTabSubtree : function TSTWindow_removeTabSubtree(aTabOrTabs, aOnlyChildren)
|
2007-10-19 22:44:14 -04:00
|
|
|
{
|
2010-09-18 11:17:48 -04:00
|
|
|
var tabs = this.gatherSubtreeMemberTabs(aTabOrTabs, aOnlyChildren);
|
2009-06-17 04:59:18 -04:00
|
|
|
if (!this.warnAboutClosingTabs(tabs.length))
|
2007-10-19 22:44:14 -04:00
|
|
|
return;
|
|
|
|
|
2010-09-18 11:17:48 -04:00
|
|
|
if (aOnlyChildren)
|
|
|
|
tabs = this.gatherSubtreeMemberTabs(aTabOrTabs);
|
|
|
|
|
2012-02-04 16:31:03 -05:00
|
|
|
var allSubtrees = this.splitTabsToSubtrees(tabs);
|
|
|
|
for (let i = 0, maxi = allSubtrees.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let subtreeTabs = allSubtrees[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
if (!this.fireTabSubtreeClosingEvent(subtreeTabs[0], subtreeTabs))
|
|
|
|
continue;
|
|
|
|
let b = this.getTabBrowserFromChild(subtreeTabs[0]);
|
2009-12-27 06:22:44 -05:00
|
|
|
if (aOnlyChildren)
|
2012-02-04 13:15:38 -05:00
|
|
|
subtreeTabs = subtreeTabs.slice(1);
|
|
|
|
if (!subtreeTabs.length)
|
|
|
|
continue;
|
2009-12-27 06:22:44 -05:00
|
|
|
this.stopRendering();
|
2012-02-04 13:15:38 -05:00
|
|
|
this.markAsClosedSet(subtreeTabs);
|
|
|
|
for (let i = subtreeTabs.length-1; i > -1; i--)
|
2009-12-25 23:49:58 -05:00
|
|
|
{
|
2012-02-04 13:15:38 -05:00
|
|
|
b.removeTab(subtreeTabs[i], { animate : true });
|
2009-12-25 23:49:58 -05:00
|
|
|
}
|
2009-12-27 06:22:44 -05:00
|
|
|
this.startRendering();
|
2012-02-04 13:15:38 -05:00
|
|
|
this.fireTabSubtreeClosedEvent(b, subtreeTabs[0], subtreeTabs)
|
|
|
|
}
|
2007-10-19 22:44:14 -04:00
|
|
|
},
|
2013-11-06 10:27:24 -05:00
|
|
|
removeTabSubTree : function(...aArgs) {
|
|
|
|
return this.removeTabSubtree.apply(this, aArgs);
|
|
|
|
}, // obsolete, for backward compatibility
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
fireTabSubtreeClosingEvent : function TSTWindow_fireTabSubtreeClosingEvent(aParentTab, aClosedTabs)
|
2009-12-25 23:49:58 -05:00
|
|
|
{
|
2011-01-11 05:29:14 -05:00
|
|
|
var b = this.getTabBrowserFromChild(aParentTab);
|
|
|
|
var data = {
|
|
|
|
parent : aParentTab,
|
|
|
|
tabs : aClosedTabs
|
|
|
|
};
|
|
|
|
var canClose = (
|
|
|
|
/* PUBLIC API */
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_SUBTREE_CLOSING, b, true, true, data) &&
|
2011-01-11 05:29:14 -05:00
|
|
|
// for backward compatibility
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_SUBTREE_CLOSING.replace(/^nsDOM/, ''), b, true, true, data)
|
2011-01-11 05:29:14 -05:00
|
|
|
);
|
2010-12-20 06:54:42 -05:00
|
|
|
return canClose;
|
2009-12-25 23:49:58 -05:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
fireTabSubtreeClosedEvent : function TSTWindow_fireTabSubtreeClosedEvent(aTabBrowser, aParentTab, aClosedTabs)
|
2009-12-25 23:49:58 -05:00
|
|
|
{
|
2009-12-26 00:24:55 -05:00
|
|
|
aClosedTabs = aClosedTabs.filter(function(aTab) { return !aTab.parentNode; });
|
2011-01-11 05:29:14 -05:00
|
|
|
var data = {
|
|
|
|
parent : aParentTab,
|
|
|
|
tabs : aClosedTabs
|
|
|
|
};
|
2010-12-20 06:54:42 -05:00
|
|
|
|
2009-12-25 23:49:58 -05:00
|
|
|
/* PUBLIC API */
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_SUBTREE_CLOSED, aTabBrowser, true, false, data);
|
2010-12-20 06:54:42 -05:00
|
|
|
// for backward compatibility
|
2014-03-11 12:50:40 -04:00
|
|
|
this.fireCustomEvent(this.kEVENT_TYPE_SUBTREE_CLOSED.replace(/^nsDOM/, ''), aTabBrowser, true, false, data);
|
2009-12-25 23:49:58 -05:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
warnAboutClosingTabSubtreeOf : function TSTWindow_warnAboutClosingTabSubtreeOf(aTab)
|
2009-12-18 00:52:47 -05:00
|
|
|
{
|
2009-12-25 06:19:50 -05:00
|
|
|
if (!this.shouldCloseTabSubtreeOf(aTab))
|
2009-12-18 01:08:42 -05:00
|
|
|
return true;
|
2009-12-18 00:52:47 -05:00
|
|
|
|
|
|
|
var tabs = [aTab].concat(this.getDescendantTabs(aTab));
|
|
|
|
return this.warnAboutClosingTabs(tabs.length);
|
|
|
|
},
|
2013-11-06 10:27:24 -05:00
|
|
|
warnAboutClosingTabSubTreeOf : function(...aArgs) {
|
|
|
|
return this.warnAboutClosingTabSubtreeOf.apply(this, aArgs);
|
|
|
|
}, // obsolete, for backward compatibility
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
warnAboutClosingTabs : function TSTWindow_warnAboutClosingTabs(aTabsCount)
|
2009-06-17 04:59:18 -04:00
|
|
|
{
|
|
|
|
if (
|
|
|
|
aTabsCount <= 1 ||
|
2013-01-05 21:47:50 -05:00
|
|
|
!prefs.getPref('browser.tabs.warnOnClose')
|
2009-06-17 04:59:18 -04:00
|
|
|
)
|
|
|
|
return true;
|
|
|
|
var checked = { value:true };
|
2011-05-25 17:23:02 -04:00
|
|
|
var w = this.window;
|
|
|
|
w.focus();
|
2014-07-26 13:44:23 -04:00
|
|
|
var message = w.PluralForm.get(aTabsCount, utils.tabbrowserBundle.getString('tabs.closeWarningMultiple')).replace('#1', aTabsCount);
|
2012-09-17 23:10:11 -04:00
|
|
|
var shouldClose = Services.prompt.confirmEx(w,
|
2013-01-02 21:08:25 -05:00
|
|
|
utils.tabbrowserBundle.getString('tabs.closeWarningTitle'),
|
2014-04-14 01:29:11 -04:00
|
|
|
message,
|
2012-09-17 23:10:11 -04:00
|
|
|
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
|
|
|
|
(Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1),
|
2013-01-02 21:08:25 -05:00
|
|
|
utils.tabbrowserBundle.getString('tabs.closeButtonMultiple'),
|
2009-06-17 04:59:18 -04:00
|
|
|
null, null,
|
2013-01-02 21:08:25 -05:00
|
|
|
utils.tabbrowserBundle.getString('tabs.closeWarningPromptMe'),
|
2009-06-17 04:59:18 -04:00
|
|
|
checked
|
|
|
|
) == 0;
|
|
|
|
if (shouldClose && !checked.value)
|
2013-01-05 21:47:50 -05:00
|
|
|
prefs.setPref('browser.tabs.warnOnClose', false);
|
2009-06-17 04:59:18 -04:00
|
|
|
return shouldClose;
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
reloadTabSubtree : function TSTWindow_reloadTabSubtree(aTabOrTabs, aOnlyChildren)
|
2009-07-06 05:21:06 -04:00
|
|
|
{
|
2009-12-25 15:06:49 -05:00
|
|
|
var tabs = this.gatherSubtreeMemberTabs(aTabOrTabs, aOnlyChildren);
|
2009-07-06 05:21:06 -04:00
|
|
|
var b = this.getTabBrowserFromChild(tabs[0]);
|
|
|
|
for (var i = tabs.length-1; i > -1; i--)
|
|
|
|
{
|
|
|
|
b.reloadTab(tabs[i]);
|
|
|
|
}
|
|
|
|
},
|
2013-11-06 10:27:24 -05:00
|
|
|
reloadTabSubTree : function(...aArgs) {
|
|
|
|
return this.reloadTabSubtree.apply(this, aArgs);
|
|
|
|
}, // obsolete, for backward compatibility
|
2009-07-06 05:21:06 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
createSubtree : function TSTWindow_createSubtree(aTabs)
|
2009-07-23 11:34:28 -04:00
|
|
|
{
|
2013-09-17 23:10:15 -04:00
|
|
|
var rootTabs = this.getRootTabs(aTabs);
|
2009-07-23 12:14:45 -04:00
|
|
|
|
2009-07-23 12:33:06 -04:00
|
|
|
var parent = this.getParentTab(aTabs[0]);
|
2009-07-23 12:51:48 -04:00
|
|
|
var next = aTabs[0];
|
2009-07-23 12:49:54 -04:00
|
|
|
while (
|
2009-07-23 12:51:48 -04:00
|
|
|
(next = this.getNextSiblingTab(next)) &&
|
|
|
|
aTabs.indexOf(next) > -1
|
2009-07-23 12:49:54 -04:00
|
|
|
);
|
|
|
|
|
2013-09-17 23:10:15 -04:00
|
|
|
var b = this.getTabBrowserFromChild(aTabs[0]);
|
|
|
|
|
|
|
|
rootTabs.forEach(function(aRootTab) {
|
|
|
|
var parentTab = this.getParentTab(aRootTab);
|
|
|
|
var descendantTabs = this.getDescendantTabs(aRootTab);
|
|
|
|
descendantTabs.reverse().forEach(function(aDescendantTab) {
|
|
|
|
var inTargets = aTabs.indexOf(aDescendantTab) > -1;
|
|
|
|
var parentInTargets = aTabs.indexOf(this.getParentTab(aDescendantTab)) > -1;
|
|
|
|
if (inTargets || (inTargets == parentInTargets))
|
|
|
|
return;
|
|
|
|
if (parentTab)
|
|
|
|
b.treeStyleTab.attachTabTo(aDescendantTab, parentTab, {
|
|
|
|
dontExpand : true,
|
|
|
|
dontMove : true,
|
|
|
|
insertBefore : this.getNextSiblingTab(aRootTab)
|
|
|
|
});
|
|
|
|
else
|
|
|
|
b.treeStyleTab.detachTab(aDescendantTab);
|
|
|
|
}, this);
|
|
|
|
}, this);
|
|
|
|
|
|
|
|
aTabs = rootTabs;
|
|
|
|
|
|
|
|
var shouldCreateGroup = aTabs.length > 1 && utils.getTreePref('createSubtree.underParent');
|
|
|
|
var root = shouldCreateGroup ?
|
2013-08-21 04:34:07 -04:00
|
|
|
b.addTab(this.getGroupTabURI({
|
|
|
|
temporary: utils.getTreePref('createSubtree.underParent.temporaryGroup')
|
|
|
|
})) :
|
2009-07-24 03:09:29 -04:00
|
|
|
aTabs.shift() ;
|
2011-05-25 16:54:46 -04:00
|
|
|
var self = this;
|
|
|
|
this.Deferred.next(function(self) {
|
2013-09-17 23:10:15 -04:00
|
|
|
if (shouldCreateGroup) {
|
|
|
|
for (let i = 0, maxi = aTabs.length; i < maxi; i++)
|
|
|
|
{
|
|
|
|
let tab = aTabs[i];
|
|
|
|
b.treeStyleTab.attachTabTo(tab, root);
|
|
|
|
b.treeStyleTab.collapseExpandTab(tab, false);
|
|
|
|
}
|
2012-02-04 13:15:38 -05:00
|
|
|
}
|
2009-07-23 12:49:54 -04:00
|
|
|
if (parent) {
|
|
|
|
b.treeStyleTab.attachTabTo(root, parent, {
|
2009-07-23 12:51:48 -04:00
|
|
|
insertBefore : next
|
2009-07-23 12:49:54 -04:00
|
|
|
});
|
|
|
|
}
|
2009-07-23 12:51:48 -04:00
|
|
|
else if (next) {
|
2009-12-25 06:19:50 -05:00
|
|
|
b.treeStyleTab.moveTabSubtreeTo(root, next._tPos);
|
2009-07-23 12:51:48 -04:00
|
|
|
}
|
2012-02-06 12:13:46 -05:00
|
|
|
}).error(this.defaultDeferredErrorHandler);
|
2009-07-23 12:14:45 -04:00
|
|
|
},
|
2013-11-06 10:27:24 -05:00
|
|
|
createSubTree : function(...aArgs) {
|
|
|
|
return this.createSubtree.apply(this, aArgs);
|
|
|
|
}, // obsolete, for backward compatibility
|
2009-11-23 11:11:30 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
canCreateSubtree : function TSTWindow_canCreateSubtree(aTabs)
|
2009-07-23 12:14:45 -04:00
|
|
|
{
|
2013-09-17 23:10:15 -04:00
|
|
|
var rootTabs = this.getRootTabs(aTabs);
|
|
|
|
if (rootTabs.length == 1) {
|
|
|
|
let descendants = this.getDescendantTabs(rootTabs[0]);
|
|
|
|
// are they already grouped?
|
|
|
|
// if it is a partial selection, I can create new group.
|
|
|
|
return (descendants.some(function(aDescendantTab) {
|
|
|
|
return aTabs.indexOf(aDescendantTab) < 0;
|
|
|
|
}, this));
|
2009-07-23 12:14:45 -04:00
|
|
|
}
|
2013-09-17 23:10:15 -04:00
|
|
|
return true;
|
2009-07-23 12:14:45 -04:00
|
|
|
},
|
2013-11-06 10:27:24 -05:00
|
|
|
canCreateSubTree : function(...aArgs) {
|
|
|
|
return this.canCreateSubtree.apply(this, aArgs);
|
|
|
|
}, // obsolete, for backward compatibility
|
2009-11-23 11:11:30 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
getRootTabs : function TSTWindow_getRootTabs(aTabs)
|
2009-07-23 12:14:45 -04:00
|
|
|
{
|
|
|
|
var roots = [];
|
2013-09-17 05:17:20 -04:00
|
|
|
if (!aTabs || !aTabs.length)
|
|
|
|
return roots;
|
2009-07-23 12:14:45 -04:00
|
|
|
aTabs = this.cleanUpTabsArray(aTabs);
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = aTabs.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let tab = aTabs[i];
|
2012-02-04 13:15:38 -05:00
|
|
|
let parent = this.getParentTab(tab);
|
2013-09-17 05:17:20 -04:00
|
|
|
if (parent && aTabs.indexOf(parent) > -1)
|
|
|
|
continue;
|
2012-02-04 13:15:38 -05:00
|
|
|
roots.push(tab);
|
|
|
|
}
|
2009-07-23 12:14:45 -04:00
|
|
|
return roots;
|
2009-07-23 11:34:28 -04:00
|
|
|
},
|
2009-11-23 11:11:30 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
collapseExpandAllSubtree : function TSTWindow_collapseExpandAllSubtree(aCollapse)
|
2007-11-17 00:20:26 -05:00
|
|
|
{
|
2012-09-17 11:31:48 -04:00
|
|
|
Services.obs.notifyObservers(
|
2011-05-25 16:54:46 -04:00
|
|
|
this.window,
|
2010-11-30 19:33:07 -05:00
|
|
|
this.kTOPIC_COLLAPSE_EXPAND_ALL,
|
2007-11-17 00:20:26 -05:00
|
|
|
(aCollapse ? 'collapse' : 'open' )
|
|
|
|
);
|
|
|
|
},
|
2008-02-28 02:45:39 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
promoteTab : function TSTWindow_promoteTab(aTab) /* PUBLIC API */
|
2009-12-18 04:05:41 -05:00
|
|
|
{
|
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
|
|
|
var sv = b.treeStyleTab;
|
|
|
|
|
|
|
|
var parent = sv.getParentTab(aTab);
|
2013-09-17 05:17:20 -04:00
|
|
|
if (!parent)
|
|
|
|
return;
|
2009-12-18 04:05:41 -05:00
|
|
|
|
|
|
|
var nextSibling = sv.getNextSiblingTab(parent);
|
|
|
|
|
|
|
|
var grandParent = sv.getParentTab(parent);
|
|
|
|
if (grandParent) {
|
|
|
|
sv.attachTabTo(aTab, grandParent, {
|
|
|
|
insertBefore : nextSibling
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
2011-12-06 20:18:05 -05:00
|
|
|
sv.detachTab(aTab);
|
2009-12-18 04:05:41 -05:00
|
|
|
let index = nextSibling ? nextSibling._tPos : b.mTabContainer.childNodes.length ;
|
2013-09-17 05:17:20 -04:00
|
|
|
if (index > aTab._tPos)
|
|
|
|
index--;
|
2009-12-18 04:05:41 -05:00
|
|
|
b.moveTabTo(aTab, index);
|
|
|
|
}
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
promoteCurrentTab : function TSTWindow_promoteCurrentTab() /* PUBLIC API */
|
2009-12-18 04:05:41 -05:00
|
|
|
{
|
|
|
|
this.promoteTab(this.browser.selectedTab);
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
demoteTab : function TSTWindow_demoteTab(aTab) /* PUBLIC API */
|
2009-12-18 04:05:41 -05:00
|
|
|
{
|
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
|
|
|
var sv = b.treeStyleTab;
|
|
|
|
|
|
|
|
var previous = this.getPreviousSiblingTab(aTab);
|
|
|
|
if (previous)
|
|
|
|
sv.attachTabTo(aTab, previous);
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
demoteCurrentTab : function TSTWindow_demoteCurrentTab() /* PUBLIC API */
|
2009-12-18 04:05:41 -05:00
|
|
|
{
|
|
|
|
this.demoteTab(this.browser.selectedTab);
|
|
|
|
},
|
2009-12-25 12:55:55 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
expandTreeAfterKeyReleased : function TSTWindow_expandTreeAfterKeyReleased(aTab)
|
2009-08-14 02:12:08 -04:00
|
|
|
{
|
2013-09-17 05:17:20 -04:00
|
|
|
if (utils.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut'))
|
|
|
|
return;
|
2009-08-14 02:12:08 -04:00
|
|
|
this._tabShouldBeExpandedAfterKeyReleased = aTab || null;
|
|
|
|
},
|
|
|
|
_tabShouldBeExpandedAfterKeyReleased : null,
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
removeAllTabsBut : function TSTWindow_removeAllTabsBut(aTab)
|
2010-12-08 06:34:42 -05:00
|
|
|
{
|
|
|
|
var keepTabs = [aTab].concat(this.getDescendantTabs(aTab));
|
|
|
|
var b = this.getTabBrowserFromChild(aTab);
|
2012-09-23 02:43:49 -04:00
|
|
|
var closeTabs = this.getTabs(b).filter(function(aTab) {
|
2011-04-26 12:06:58 -04:00
|
|
|
return keepTabs.indexOf(aTab) < 0 && !aTab.hasAttribute('pinned');
|
2010-12-08 06:34:42 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!this.warnAboutClosingTabs(closeTabs.length))
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.stopRendering();
|
|
|
|
this.markAsClosedSet(closeTabs);
|
2012-02-04 16:31:03 -05:00
|
|
|
var tabs = closeTabs.reverse();
|
|
|
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
b.removeTab(tabs[i]);
|
2012-02-04 13:15:38 -05:00
|
|
|
}
|
2010-12-08 06:34:42 -05:00
|
|
|
this.startRendering();
|
|
|
|
},
|
|
|
|
|
2010-11-30 19:26:12 -05:00
|
|
|
// For backward compatibility. You should use DOM event to block TST's focus handling.
|
2011-05-25 16:54:46 -04:00
|
|
|
registerTabFocusAllowance : function TSTWindow_registerTabFocusAllowance(aProcess) /* PUBLIC API */
|
2008-03-02 13:16:57 -05:00
|
|
|
{
|
2010-11-30 05:05:00 -05:00
|
|
|
var listener = {
|
|
|
|
process : aProcess,
|
|
|
|
handleEvent : function(aEvent) {
|
2011-03-29 23:34:37 -04:00
|
|
|
var tab = aEvent.originalTarget;
|
|
|
|
var b = tab.__treestyletab__linkedTabBrowser;
|
|
|
|
if (!this.process.call(b.treeStyleTab, b))
|
2010-11-30 05:05:00 -05:00
|
|
|
aEvent.preventDefault();
|
|
|
|
}
|
|
|
|
};
|
2011-05-25 16:54:46 -04:00
|
|
|
this.window.addEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, listener, false);
|
2010-11-30 05:05:00 -05:00
|
|
|
this._tabFocusAllowance.push(listener);
|
2008-03-02 13:16:57 -05:00
|
|
|
},
|
|
|
|
_tabFocusAllowance : [],
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
tearOffSubtreeFromRemote : function TSTWindow_tearOffSubtreeFromRemote()
|
2008-12-01 03:30:36 -05:00
|
|
|
{
|
2011-05-25 17:23:02 -04:00
|
|
|
var w = this.window;
|
|
|
|
var remoteTab = w.arguments[0];
|
2008-12-01 03:30:36 -05:00
|
|
|
var remoteWindow = remoteTab.ownerDocument.defaultView;
|
|
|
|
var remoteService = remoteWindow.TreeStyleTabService;
|
|
|
|
var remoteMultipleTabService = remoteWindow.MultipleTabService;
|
|
|
|
if (remoteService.hasChildTabs(remoteTab) ||
|
2008-12-01 20:54:16 -05:00
|
|
|
(remoteMultipleTabService && remoteMultipleTabService.isSelected(remoteTab))) {
|
2011-05-25 16:54:46 -04:00
|
|
|
let remoteBrowser = remoteService.getTabBrowserFromChild(remoteTab);
|
2010-12-01 19:00:39 -05:00
|
|
|
if (remoteBrowser.treeStyleTab.tabbarDNDObserver.isDraggingAllTabs(remoteTab)) {
|
2011-05-25 17:23:02 -04:00
|
|
|
w.close();
|
2008-12-01 03:30:36 -05:00
|
|
|
}
|
|
|
|
else {
|
2011-05-25 16:54:46 -04:00
|
|
|
let actionInfo = {
|
2012-02-04 17:50:26 -05:00
|
|
|
action : remoteTab.__treestyletab__toBeDuplicated ? this.kACTION_DUPLICATE : this.kACTION_IMPORT
|
2008-12-01 04:14:05 -05:00
|
|
|
};
|
2012-02-04 17:50:26 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
let b = this.browser;
|
|
|
|
let blankTab;
|
|
|
|
this.Deferred
|
|
|
|
.next(function() {
|
|
|
|
var blankTab = b.selectedTab;
|
|
|
|
b.treeStyleTab.tabbarDNDObserver.performDrop(actionInfo, remoteTab);
|
|
|
|
return blankTab;
|
|
|
|
})
|
|
|
|
.next(function(aBlankTab) {
|
|
|
|
b.removeTab(aBlankTab);
|
2009-05-13 02:09:17 -04:00
|
|
|
remoteTab = null;
|
|
|
|
remoteBrowser = null;
|
|
|
|
remoteWindow = null
|
|
|
|
remoteService = null;
|
|
|
|
remoteMultipleTabService = null;
|
2012-02-04 17:50:26 -05:00
|
|
|
})
|
2012-02-06 12:13:46 -05:00
|
|
|
.error(this.defaultDeferredErrorHandler);
|
2008-12-01 03:30:36 -05:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2013-11-06 10:27:24 -05:00
|
|
|
tearOffSubTreeFromRemote : function(...aArgs) {
|
|
|
|
return this.tearOffSubtreeFromRemote.apply(this, aArgs);
|
|
|
|
}, // obsolete, for backward compatibility
|
2010-03-28 14:22:15 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onPrintPreviewEnter : function TSTWindow_onPrintPreviewEnter()
|
2010-03-28 14:22:15 -04:00
|
|
|
{
|
2011-05-25 17:23:02 -04:00
|
|
|
var d = this.document;
|
|
|
|
var event = d.createEvent('Events');
|
2010-11-30 05:05:00 -05:00
|
|
|
event.initEvent(this.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, true, false);
|
2011-05-25 17:23:02 -04:00
|
|
|
d.documentElement.dispatchEvent(event);
|
2010-12-20 06:54:42 -05:00
|
|
|
|
|
|
|
// for backward compatibility
|
2011-05-25 17:23:02 -04:00
|
|
|
event = d.createEvent('Events');
|
2010-12-20 06:54:42 -05:00
|
|
|
event.initEvent(this.kEVENT_TYPE_PRINT_PREVIEW_ENTERED.replace(/^nsDOM/, ''), true, false);
|
2011-05-25 17:23:02 -04:00
|
|
|
d.documentElement.dispatchEvent(event);
|
2010-03-28 14:22:15 -04:00
|
|
|
},
|
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onPrintPreviewExit : function TSTWindow_onPrintPreviewExit()
|
2010-03-28 14:22:15 -04:00
|
|
|
{
|
2011-05-25 17:23:02 -04:00
|
|
|
var d = this.document;
|
|
|
|
var event = d.createEvent('Events');
|
2010-11-30 05:05:00 -05:00
|
|
|
event.initEvent(this.kEVENT_TYPE_PRINT_PREVIEW_EXITED, true, false);
|
2011-05-25 17:23:02 -04:00
|
|
|
d.documentElement.dispatchEvent(event);
|
2010-12-20 06:54:42 -05:00
|
|
|
|
|
|
|
// for backward compatibility
|
2011-05-25 17:23:02 -04:00
|
|
|
event = d.createEvent('Events');
|
2010-12-20 06:54:42 -05:00
|
|
|
event.initEvent(this.kEVENT_TYPE_PRINT_PREVIEW_EXITED.replace(/^nsDOM/, ''), true, false);
|
2011-05-25 17:23:02 -04:00
|
|
|
d.documentElement.dispatchEvent(event);
|
2010-03-28 14:22:15 -04:00
|
|
|
},
|
2008-03-08 03:57:17 -05:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
observe : function TSTWindow_observe(aSubject, aTopic, aData)
|
2009-07-03 05:58:34 -04:00
|
|
|
{
|
|
|
|
switch (aTopic)
|
|
|
|
{
|
|
|
|
case 'nsPref:changed':
|
|
|
|
this.onPrefChange(aData);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
2011-04-06 00:13:40 -04:00
|
|
|
get restoringTree() {
|
2012-01-27 13:57:48 -05:00
|
|
|
if (this._restoringTree || !!this.restoringCount)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
var count = 0;
|
|
|
|
this.browser.visibleTabs.some(function(aTab) {
|
|
|
|
if (aTab.linkedBrowser.__treestyletab__toBeRestored)
|
|
|
|
count++;
|
|
|
|
return count > 1;
|
|
|
|
});
|
|
|
|
return count > 1;
|
2009-10-25 13:31:47 -04:00
|
|
|
},
|
2011-12-08 11:39:55 -05:00
|
|
|
set restoringTree(aValue) {
|
|
|
|
return this._restoringTree = !!aValue;
|
|
|
|
},
|
|
|
|
_restoringTree : false,
|
2009-07-03 05:58:34 -04:00
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
/* Pref Listener */
|
2008-03-08 05:07:28 -05:00
|
|
|
|
2008-03-03 03:26:51 -05:00
|
|
|
domains : [
|
|
|
|
'extensions.treestyletab',
|
2009-08-14 02:30:03 -04:00
|
|
|
'browser.ctrlTab.previews'
|
2008-03-03 03:26:51 -05:00
|
|
|
],
|
2007-10-16 13:22:28 -04:00
|
|
|
|
2011-05-25 16:54:46 -04:00
|
|
|
onPrefChange : function TSTWindow_onPrefChange(aPrefName)
|
2007-10-16 13:22:28 -04:00
|
|
|
{
|
2013-01-05 21:47:50 -05:00
|
|
|
var value = prefs.getPref(aPrefName);
|
2007-10-16 13:22:28 -04:00
|
|
|
switch (aPrefName)
|
|
|
|
{
|
2008-06-17 02:22:49 -04:00
|
|
|
case 'extensions.treestyletab.tabbar.autoHide.mode':
|
2008-06-17 08:55:05 -04:00
|
|
|
// don't set on this time, because appearance of all tabbrowsers are not updated yet.
|
2012-10-23 12:43:56 -04:00
|
|
|
// this.autoHide.mode = utils.getTreePref('tabbar.autoHide.mode');
|
2008-03-09 08:34:10 -04:00
|
|
|
case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown':
|
2008-03-08 03:57:17 -05:00
|
|
|
case 'extensions.treestyletab.tabbar.autoShow.tabSwitch':
|
2008-03-09 08:34:10 -04:00
|
|
|
case 'extensions.treestyletab.tabbar.autoShow.feedback':
|
2011-05-25 16:54:46 -04:00
|
|
|
this.autoHideWindow.updateKeyListeners(this.window);
|
2008-03-08 03:57:17 -05:00
|
|
|
break;
|
|
|
|
|
2009-03-25 10:09:34 -04:00
|
|
|
case 'extensions.treestyletab.tabbar.style':
|
|
|
|
case 'extensions.treestyletab.tabbar.position':
|
2013-01-05 21:47:50 -05:00
|
|
|
this.themeManager.set(prefs.getPref('extensions.treestyletab.tabbar.style'), this.position);
|
2009-03-25 10:09:34 -04:00
|
|
|
break;
|
|
|
|
|
2009-08-14 02:36:59 -04:00
|
|
|
case 'browser.ctrlTab.previews':
|
2011-05-25 16:54:46 -04:00
|
|
|
this.autoHideWindow.updateKeyListeners(this.window);
|
2009-12-25 06:27:23 -05:00
|
|
|
case 'extensions.treestyletab.autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut':
|
|
|
|
case 'extensions.treestyletab.autoCollapseExpandSubtreeOnSelect':
|
2009-08-14 02:36:59 -04:00
|
|
|
if (this.shouldListenKeyEventsForAutoExpandByFocusChange)
|
2009-08-14 02:12:08 -04:00
|
|
|
this.startListenKeyEventsFor(this.LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE);
|
2009-08-14 02:36:59 -04:00
|
|
|
else
|
2009-08-14 02:12:08 -04:00
|
|
|
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE);
|
|
|
|
break;
|
|
|
|
|
2007-10-16 13:22:28 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-05-25 16:54:46 -04:00
|
|
|
}
|
2010-03-27 10:52:25 -04:00
|
|
|
|
2014-04-02 06:25:51 -04:00
|
|
|
});
|
2010-03-27 10:52:25 -04:00
|
|
|
|