2011-05-25 16:54:46 -04:00
/ * * * * * * B E G I N L I C E N S E B L O C K * * * * *
* 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 .
*
* The Initial Developer of the Original Code is SHIMODA Hiroshi .
* Portions created by the Initial Developer are Copyright ( C ) 2011
* the Initial Developer . All Rights Reserved .
*
2011-11-01 13:43:39 -04:00
* Contributor ( s ) : SHIMODA Hiroshi < piro . outsider . reflex @ gmail . com >
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 ;
2011-05-25 23:11:08 -04:00
Components . utils . import ( 'resource://gre/modules/XPCOMUtils.jsm' ) ;
2011-05-25 16:54:46 -04:00
2011-05-26 11:35:43 -04:00
// Components.utils.import('resource://treestyletab-modules/rap.js');
// rap();
2011-05-25 23:11:08 -04:00
Components . utils . import ( 'resource://treestyletab-modules/utils.js' ) ;
XPCOMUtils . defineLazyGetter ( this , 'TreeStyleTabBrowser' , function ( ) {
var ns = { } ;
Components . utils . import ( 'resource://treestyletab-modules/browser.js' , ns ) ;
return ns . TreeStyleTabBrowser ;
} ) ;
2011-05-25 16:54:46 -04:00
function TreeStyleTabWindow ( aWindow )
{
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
XPCOMUtils . defineLazyGetter ( aWindow , 'TreeStyleTabBrowser' , function ( ) {
var ns = { } ;
Components . utils . import ( 'resource://treestyletab-modules/browser.js' , ns ) ;
return ns . TreeStyleTabBrowser ;
} ) ;
2011-05-25 16:54:46 -04:00
}
TreeStyleTabWindow . prototype = {
2008-11-09 23:48:11 -05:00
2011-05-25 16:54:46 -04:00
utils : TreeStyleTabUtils ,
_ _proto _ _ : TreeStyleTabUtils ,
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 :
this . utils . 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 ( ) ) {
2011-01-22 10:46:29 -05:00
var current = this . utils . 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 ( ) {
2011-01-22 10:46:29 -05:00
self . utils . position = aValue ;
2010-03-24 13:20:30 -04:00
} ,
{
label : self . treeBundle . getString ( 'undo_changeTabbarPosition_label' ) ,
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 {
this . utils . position = aValue ;
}
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
{
2009-12-25 14:27:34 -05:00
return this . utils . undoChangeTabbarPosition ( ) ;
} ,
2011-05-25 16:54:46 -04:00
redoChangeTabbarPosition : function TSTWindow _redoChangeTabbarPosition ( ) /* PUBLIC API */
2009-12-25 14:27:34 -05:00
{
return this . utils . redoChangeTabbarPosition ( ) ;
2009-12-18 04:14:02 -05:00
} ,
2009-12-25 12:55:55 -05:00
get treeViewEnabled ( ) /* PUBLIC API */
{
return this . utils . treeViewEnabled ;
} ,
set treeViewEnabled ( aValue )
{
return this . utils . treeViewEnabled = aValue ;
} ,
2009-12-25 13:13:33 -05:00
get useTMPSessionAPI ( ) /* PUBLIC API */
{
return this . utils . useTMPSessionAPI ;
} ,
set useTMPSessionAPI ( aValue )
{
return this . utils . useTMPSessionAPI = aValue ;
} ,
2010-05-08 01:37:41 -04:00
get browser ( )
{
2011-05-25 17:23:02 -04:00
var w = this . window ;
return 'SplitBrowser' in w ? w . SplitBrowser . activeBrowser :
w . gBrowser ;
2010-05-08 01:37:41 -04: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
{
2011-05-25 16:54:46 -04:00
var namespace = { } ;
Components . utils . import (
'resource://treestyletab-modules/browser.js' ,
namespace
) ;
return aTabBrowser . treeStyleTab || new namespace . 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 ( )
{
2011-05-25 17:23:02 -04:00
var w = this . window ;
var toolbox = w . gToolbox || w . gNavToolbox ;
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
2011-12-14 01:28:47 -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
{
2011-08-29 11:39:17 -04:00
aTerm = aTerm . replace ( /^\s+|\s+$/g , '' ) ;
2011-01-25 10:06:32 -05:00
var mode = this . 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
2011-05-25 16:54:46 -04:00
var w = this . document . commandDispatcher . focusedWindow ;
2010-12-09 01:18:37 -05:00
if ( ! w || w . top != this . browser . contentWindow )
w = this . browser . contentWindow ;
return ( function ( aWindow ) {
2011-05-25 16:54:46 -04:00
if ( ! aWindow || ! ( aWindow instanceof Ci . nsIDOMWindow ) )
2010-12-09 09:33:04 -05:00
return false ;
var selection = aWindow . getSelection ( ) ;
2011-08-29 11:39:17 -04:00
if ( selection && selection . toString ( ) . replace ( /^\s+|\s+$/g , '' ) == aTerm )
2010-12-09 01:18:37 -05:00
return true ;
2010-12-09 09:33:04 -05:00
return aWindow . frames ? Array . slice ( aWindow . frames ) . some ( arguments . callee ) : false ;
2010-12-09 01:18:37 -05:00
} ) ( w ) ;
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
(
this . getPref ( 'browser.fullscreen.autohide' ) &&
this . getTreePref ( 'tabbar.autoHide.mode.fullscreen' )
) :
this . getTreePref ( 'tabbar.autoHide.mode' ) ;
} ,
2011-05-26 10:22:42 -04:00
get autoHideWindow ( )
{
if ( ! this . _autoHideWindow ) {
let ns = { } ;
Components . utils . import ( 'resource://treestyletab-modules/autoHide.js' , ns ) ;
this . _autoHideWindow = new ns . AutoHideWindow ( this . window ) ;
}
return this . _autoHideWindow ;
} ,
get themeManager ( )
{
if ( ! this . _themeManager ) {
let ns = { } ;
Components . utils . import ( 'resource://treestyletab-modules/themeManager.js' , ns ) ;
this . _themeManager = new ns . TreeStyleTabThemeManager ( this . window ) ;
}
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
{
2011-05-26 11:35:43 -04:00
// rap('window/preInit start');
2008-10-14 00:57:35 -04:00
if ( this . preInitialized ) return ;
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
2009-07-27 03:22:56 -04:00
this . migratePrefs ( ) ;
2011-05-26 10:22:42 -04:00
// initialize theme
this . onPrefChange ( 'extensions.treestyletab.tabbar.style' ) ;
2011-05-26 11:35:43 -04:00
// rap('window/preInit end');
2009-07-27 03:22:56 -04:00
} ,
preInitialized : false ,
2011-01-25 10:06:32 -05:00
kPREF _VERSION : 7 ,
2011-05-25 16:54:46 -04:00
migratePrefs : function TSTWindow _migratePrefs ( )
2009-07-27 03:22:56 -04:00
{
2009-07-07 20:09:13 -04:00
// migrate old prefs
2009-07-21 22:22:00 -04:00
var orientalPrefs = [ ] ;
2009-07-27 03:22:56 -04:00
switch ( this . getTreePref ( 'prefsVersion' ) )
2009-07-07 20:09:13 -04:00
{
case 0 :
2009-07-21 22:22:00 -04:00
orientalPrefs = orientalPrefs . concat ( [
2009-07-07 20:09:13 -04:00
'extensions.treestyletab.tabbar.fixed' ,
'extensions.treestyletab.enableSubtreeIndent' ,
'extensions.treestyletab.allowSubtreeCollapseExpand'
2009-07-21 22:22:00 -04:00
] ) ;
2009-07-24 07:00:53 -04:00
case 2 :
if ( this . getTreePref ( 'urlbar.loadSameDomainToNewChildTab' ) !== null ) {
let value = this . getTreePref ( 'urlbar.loadSameDomainToNewChildTab' ) ;
this . setTreePref ( 'urlbar.loadSameDomainToNewTab' , value ) ;
this . setTreePref ( 'urlbar.loadSameDomainToNewTab.asChild' , value ) ;
if ( value ) this . setTreePref ( 'urlbar.loadDifferentDomainToNewTab' , value ) ;
2009-07-27 03:22:56 -04:00
this . clearTreePref ( 'urlbar.loadSameDomainToNewChildTab' ) ;
}
case 3 :
if ( this . getTreePref ( 'loadDroppedLinkToNewChildTab' ) !== null ) {
this . setTreePref ( 'dropLinksOnTab.behavior' ,
this . getTreePref ( 'loadDroppedLinkToNewChildTab.confirm' ) ?
this . kDROPLINK _ASK :
this . getTreePref ( 'loadDroppedLinkToNewChildTab' ) ?
this . kDROPLINK _NEWTAB :
this . kDROPLINK _LOAD
) ;
this . clearTreePref ( 'loadDroppedLinkToNewChildTab.confirm' ) ;
this . clearTreePref ( 'loadDroppedLinkToNewChildTab' ) ;
}
if ( this . getTreePref ( 'openGroupBookmarkAsTabSubTree' ) !== null ) {
let behavior = 0 ;
if ( this . getTreePref ( 'openGroupBookmarkAsTabSubTree.underParent' ) )
behavior += this . kGROUP _BOOKMARK _USE _DUMMY ;
if ( ! this . getTreePref ( 'openGroupBookmarkBehavior.confirm' ) ) {
2009-07-27 04:37:06 -04:00
behavior += (
this . getTreePref ( 'openGroupBookmarkAsTabSubTree' ) ?
this . kGROUP _BOOKMARK _SUBTREE :
this . getTreePref ( 'browser.tabs.loadFolderAndReplace' ) ?
this . kGROUP _BOOKMARK _REPLACE :
this . kGROUP _BOOKMARK _SEPARATE
) ;
2009-07-27 03:22:56 -04:00
}
this . setTreePref ( 'openGroupBookmark.behavior' , behavior ) ;
this . clearTreePref ( 'openGroupBookmarkBehavior.confirm' ) ;
this . clearTreePref ( 'openGroupBookmarkAsTabSubTree' ) ;
this . clearTreePref ( 'openGroupBookmarkAsTabSubTree.underParent' ) ;
2011-01-22 13:32:04 -05:00
this . setPref ( 'browser.tabs.loadFolderAndReplace' , ! ! ( behavior & this . kGROUP _BOOKMARK _REPLACE ) ) ;
2009-07-24 07:00:53 -04:00
}
2009-12-25 06:19:50 -05:00
case 4 :
[
2009-12-25 06:27:23 -05:00
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect' ,
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove' ,
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut' ,
'extensions.treestyletab.autoExpandSubTreeOnAppendChild' ,
'extensions.treestyletab.autoExpandSubTreeOnCollapsedChildFocused' ,
'extensions.treestyletab.collapseExpandSubTree.dblclick' ,
'extensions.treestyletab.createSubTree.underParent' ,
2009-12-25 06:19:50 -05:00
'extensions.treestyletab.show.context-item-reloadTabSubTree' ,
'extensions.treestyletab.show.context-item-removeTabSubTree' ,
'extensions.treestyletab.show.context-item-bookmarkTabSubTree' ,
'extensions.multipletab.show.multipletab-selection-item-removeTabSubTree' ,
'extensions.multipletab.show.multipletab-selection-item-createSubTree'
] . forEach ( function ( aPref ) {
var value = this . getPref ( aPref ) ;
if ( value === null ) return ;
this . setPref ( aPref . replace ( 'SubTree' , 'Subtree' ) , value ) ;
this . clearPref ( aPref ) ;
} , this ) ;
2010-07-29 22:39:51 -04:00
case 5 :
let ( behavior = this . getTreePref ( 'openGroupBookmark.behavior' ) ) {
behavior = behavior | 2048 ;
this . setTreePref ( 'openGroupBookmark.behavior' , behavior ) ;
}
2011-01-25 10:06:32 -05:00
case 6 :
let (
general = this . getTreePref ( 'autoAttachNewTabsAsChildren' ) ,
search = this . getTreePref ( 'autoAttachSearchResultAsChildren' )
) {
if ( general !== null )
this . setTreePref ( 'autoAttach' , general ) ;
if ( search !== null )
this . setTreePref ( 'autoAttach.searchResult' , search ) ;
}
2009-07-21 22:22:00 -04:00
default :
orientalPrefs . forEach ( function ( aPref ) {
2009-07-07 20:09:13 -04:00
let value = this . getPref ( aPref ) ;
if ( value === null ) return ;
this . setPref ( aPref + '.horizontal' , value ) ;
this . setPref ( aPref + '.vertical' , value ) ;
2009-07-21 22:22:00 -04:00
this . clearPref ( aPref ) ;
2009-07-07 20:09:13 -04:00
} , this ) ;
break ;
}
2009-07-27 03:22:56 -04:00
this . setTreePref ( 'prefsVersion' , this . kPREF _VERSION ) ;
2009-07-06 11:36:43 -04:00
} ,
2011-05-25 16:54:46 -04:00
init : function TSTWindow _init ( )
2007-10-16 13:22:28 -04:00
{
2011-05-26 11:35:43 -04:00
// rap('window/init start');
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
2008-10-14 00:57:35 -04:00
if ( this . initialized ) return ;
this . initialized = true ;
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 ) ;
2011-05-25 16:54:46 -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
2007-10-16 13:22:28 -04:00
this . addPrefListener ( this ) ;
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' ) ;
2011-05-26 11:35:43 -04:00
// rap('window/init end');
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
{
2010-11-17 11:08:40 -05:00
var namespace = { } ;
Components . utils . import (
2010-12-06 07:04:52 -05:00
'resource://treestyletab-modules/lib/prefs.js' ,
2010-11-17 11:08:40 -05:00
namespace
) ;
var prefs = namespace . prefs ;
namespace = void ( 0 ) ;
2011-05-25 16:54:46 -04:00
var self = this ;
2009-09-09 00:45:54 -04:00
var restorePrefs = function ( ) {
2011-05-04 17:25:40 -04:00
if ( prefs . getPref ( 'extensions.treestyletab.tabsOnTopShouldBeRestored' ) ) {
prefs . clearPref ( 'extensions.treestyletab.tabsOnTopShouldBeRestored' ) ;
try {
2011-05-25 16:54:46 -04:00
self . browser . treeStyleTab . position = 'top' ;
2011-05-04 17:25:40 -04:00
}
catch ( e ) {
}
2011-05-25 16:54:46 -04:00
self . window . TabsOnTop . enabled = true ;
2011-05-04 17:25:40 -04:00
}
2009-09-09 00:45:54 -04:00
if ( ! prefs ) return ;
[
'browser.tabs.loadFolderAndReplace' ,
2010-03-31 06:34:30 -04:00
'browser.tabs.insertRelatedAfterCurrent' ,
'extensions.stm.tabBarMultiRows' // Super Tab Mode
2009-09-09 00:45:54 -04:00
] . forEach ( function ( aPref ) {
var backup = prefs . getPref ( aPref + '.backup' ) ;
if ( backup === null ) return ;
2010-03-25 14:10:18 -04:00
prefs . setPref ( aPref + '.override' , backup ) ; // we have to set to ".override" pref, to avoid unexpectedly reset by the preference listener.
2009-09-09 00:45:54 -04:00
prefs . clearPref ( aPref + '.backup' ) ;
} ) ;
} ;
2011-05-25 16:54:46 -04:00
new this . window [ 'piro.sakura.ne.jp' ] . 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
{
2007-11-14 14:34:36 -05:00
if ( aTabBrowser . localName != 'tabbrowser' ) return ;
2011-05-25 16:54:46 -04:00
var namespace = { } ;
Components . utils . import (
'resource://treestyletab-modules/browser.js' ,
namespace
2009-07-30 20:02:01 -04:00
) ;
2011-05-25 16:54:46 -04:00
( new namespace . 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
this . 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
{
if ( ! this . getTreePref ( 'enableSubtreeIndent.allTabsPopup' ) ) return ;
var items = Array . slice ( aEvent . originalTarget . childNodes ) ;
2010-04-30 00:49:51 -04:00
var firstItemIndex = 0 ;
2010-09-14 02:56:55 -04:00
// ignore menu items inserted by Weave (Firefox Sync), Tab Utilities, and others.
items . forEach ( function ( aItem , aIndex ) {
if (
aItem . getAttribute ( 'anonid' ) ||
aItem . id ||
aItem . hidden ||
aItem . localName != 'menuitem'
)
firstItemIndex = aIndex + 1 ;
} ) ;
items = items . slice ( firstItemIndex ) ;
2010-04-30 00:49:51 -04:00
2011-05-25 16:54:46 -04:00
var b = this . getTabBrowserFromChild ( aEvent . originalTarget ) || this . browser ;
2010-04-30 00:49:00 -04:00
this . getTabsArray ( b ) . forEach ( function ( aTab , aIndex ) {
2011-12-12 04:27:11 -05:00
items [ aIndex ] . style . marginLeft = aTab . getAttribute ( this . kNEST ) + 'em' ;
2010-04-30 00:49:00 -04:00
} , this ) ;
2008-09-26 10:13:29 -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 ) {
this . utils . inWindowDestoructionProcess = true ;
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 ) ;
2010-11-30 05:05:00 -05:00
2011-05-25 16:54:46 -04:00
this . _tabFocusAllowance . forEach ( function ( aListener ) {
2011-05-25 17:23:02 -04:00
w . removeEventListener ( this . kEVENT _TYPE _FOCUS _NEXT _TAB , aListener , false ) ;
2011-05-25 16:54:46 -04:00
} , this ) ;
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
2011-05-25 16:54:46 -04:00
this . removePrefListener ( this ) ;
}
catch ( e ) {
throw e ;
}
finally {
this . utils . inWindowDestoructionProcess = false ;
}
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
{
2007-11-14 14:34:36 -05:00
if ( aTabBrowser . localName != 'tabbrowser' ) return ;
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
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
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
{
if ( this . keyEventListeningFlags & aReason ) return ;
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 ) ;
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
{
if ( ! ( this . keyEventListeningFlags & aReason ) ) return ;
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 ) ;
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 (
this . FocusManager &&
this . FocusManager . focusedElement == this . browser . selectedTab &&
( 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 */
this . fireDataContainerEvent ( this . kEVENT _TYPE _TAB _FOCUS _SWITCHING _KEY _DOWN , b , true , false , data ) ;
2010-12-20 06:54:42 -05:00
// for backward compatibility
2011-01-11 05:29:14 -05:00
this . fireDataContainerEvent ( 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 ;
if ( ! b || ! b . treeStyleTab ) return ;
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 */
2011-01-11 05:29:14 -05:00
this . fireDataContainerEvent ( this . kEVENT _TYPE _TAB _FOCUS _SWITCHING _START , b , true , false , data ) ;
2011-01-10 23:20:01 -05:00
// for backward compatibility
2011-01-11 05:29:14 -05:00
this . fireDataContainerEvent ( this . kEVENT _TYPE _TAB _FOCUS _SWITCHING _START . replace ( /^nsDOM/ , '' ) , b , true , false , data ) ;
2008-03-08 03:57:17 -05:00
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 ) {
2011-01-11 05:29:14 -05:00
this . fireDataContainerEvent ( this . kEVENT _TYPE _TAB _FOCUS _SWITCHING _END , b , true , false , data ) ;
2011-01-10 23:20:01 -05:00
// for backward compatibility
2011-01-11 05:29:14 -05:00
this . fireDataContainerEvent ( 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
} ,
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
(
this . getTreePref ( 'autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut' ) ||
this . getTreePref ( 'autoCollapseExpandSubtreeOnSelect' )
) ;
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 &&
2009-08-14 10:51:01 -04:00
this . getPref ( 'browser.ctrlTab.previews' ) ;
} ,
2009-09-03 02:24:06 -04:00
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 ( ) ;
} ) ;
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 ( ) {
this . setTreePref ( 'tabbar.width' , width ) ;
} ) ;
2010-09-12 23:54:04 -04:00
if ( b . treeStyleTab . autoHide . mode == b . treeStyleTab . autoHide . kMODE _SHRINK &&
b . treeStyleTab . tabStripPlaceHolder )
b . treeStyleTab . tabStripPlaceHolder . setAttribute ( 'width' , this . getTreePref ( 'tabbar.shrunkenWidth' ) ) ;
}
else {
2011-04-06 08:05:59 -04:00
this . setPrefForActiveWindow ( function ( ) {
this . setTreePref ( 'tabbar.shrunkenWidth' , width ) ;
} ) ;
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 ( ) {
this . setTreePref ( 'tabbar.height' , this . maxTabbarHeight ( height , b ) ) ;
} ) ;
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
{
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 (
this . getPref ( 'browser.tabs.selectOwnerOnClose' ) &&
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
{
2008-04-29 14:17:44 -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
} ,
2009-12-25 06:36:22 -05:00
showHideSubTreeMenuItem : function ( ) { return this . showHideSubtreeMenuItem . apply ( this , arguments ) ; } , // 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 ||
2010-05-06 05:56:39 -04:00
! this . getPref ( 'browser.taskbar.previews.enable' ) ||
! this . 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 (
! this . getPref ( 'browser.taskbar.previews.enable' ) ||
! this . getTreePref ( 'taskbarPreviews.hideCollapsedTabs' )
)
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 ) {
2010-04-06 09:38:05 -04:00
aTabWindow . previews . forEach ( function ( aPreview ) {
if ( ! aPreview ) return ;
var tab = aPreview . controller . wrappedJSObject . tab ;
2010-05-13 08:06:31 -04:00
aPreview . visible = ! this . isCollapsed ( tab ) ;
2010-04-06 09:38:05 -04:00
} , this ) ;
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
{
2011-05-25 17:23:02 -04:00
var w = this . window ;
if ( ! ( 'TabsOnTop' in w ) || ! ( 'enabled' in w . TabsOnTop ) )
2010-05-15 10:05:02 -04:00
return ;
2011-05-25 17:23:02 -04:00
var TabsOnTop = w . TabsOnTop ;
2010-05-15 10:05:02 -04:00
if ( ! ( '_tabsOnTopDefaultState' in this ) )
this . _tabsOnTopDefaultState = TabsOnTop . enabled ;
2011-05-25 16:54:46 -04:00
if ( this . browser . treeStyleTab . position != 'top' ||
! this . browser . treeStyleTab . fixed ) {
2011-05-04 17:25:40 -04:00
if ( TabsOnTop . enabled ) {
2010-06-27 00:01:15 -04:00
TabsOnTop . enabled = false ;
2011-05-04 17:25:40 -04:00
this . setTreePref ( 'tabsOnTopShouldBeRestored' , true ) ;
}
2010-05-15 10:05:02 -04:00
}
else if ( '_tabsOnTopDefaultState' in this ) {
2010-06-27 00:01:15 -04:00
if ( TabsOnTop . enabled != this . _tabsOnTopDefaultState )
TabsOnTop . enabled = this . _tabsOnTopDefaultState ;
2010-05-15 10:05:02 -04:00
delete this . _tabsOnTopDefaultState ;
2011-05-04 17:25:40 -04:00
this . setTreePref ( 'tabsOnTopShouldBeRestored' , 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 (
'local-name() = "tooltip" or local-name() ="panel" or ' +
'parent::*/ancestor-or-self::*[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 ) ;
2010-12-02 23:16:30 -05:00
return aItem && 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-24 22:27:33 -04:00
kNEWTAB _DO _NOTHING : - 1 ,
kNEWTAB _OPEN _AS _ORPHAN : 0 ,
kNEWTAB _OPEN _AS _CHILD : 1 ,
kNEWTAB _OPEN _AS _SIBLING : 2 ,
kNEWTAB _OPEN _AS _NEXT _SIBLING : 3 ,
2011-05-25 16:54:46 -04:00
_handleNewTabCommand : function TSTWindow _handleNewTabCommand ( aBaseTab , aBehavior )
2011-01-25 10:01:37 -05:00
{
2011-05-24 22:27:33 -04:00
switch ( aBehavior )
2011-01-25 10:01:37 -05:00
{
2011-05-24 22:27:33 -04:00
case this . kNEWTAB _OPEN _AS _ORPHAN :
case this . kNEWTAB _DO _NOTHING :
2011-01-25 10:01:37 -05:00
default :
2011-05-24 22:27:33 -04:00
return ;
case this . kNEWTAB _OPEN _AS _CHILD :
2011-05-25 00:58:25 -04:00
this . readyToOpenChildTabNow ( aBaseTab ) ;
2011-01-25 10:01:37 -05:00
break ;
2011-05-24 22:27:33 -04:00
case this . kNEWTAB _OPEN _AS _SIBLING :
let ( parentTab = this . getParentTab ( aBaseTab ) ) {
2011-05-05 12:50:58 -04:00
if ( parentTab )
2011-05-25 00:58:25 -04:00
this . readyToOpenChildTabNow ( parentTab ) ;
2011-05-24 22:27:33 -04:00
else
return ;
2011-05-05 12:50:58 -04:00
}
2011-05-24 22:27:33 -04:00
break ;
case this . kNEWTAB _OPEN _AS _NEXT _SIBLING :
2011-05-25 00:58:25 -04:00
this . readyToOpenNextSiblingTabNow ( aBaseTab ) ;
2011-05-24 22:27:33 -04:00
break ;
2011-01-25 10:01:37 -05:00
}
2011-05-24 22:27:33 -04:00
} ,
2011-05-25 16:54:46 -04:00
onBeforeNewTabCommand : function TSTWindow _onBeforeNewTabCommand ( aTabBrowser )
2011-05-24 22:27:33 -04:00
{
var b = aTabBrowser || this . browser ;
this . _handleNewTabCommand ( b . selectedTab , this . 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 ;
if ( this . evaluateXPath (
2011-05-24 22:59:09 -04:00
'ancestor-or-self::*['
2011-05-24 22:53:22 -04:00
+ '@id="new-tab-button" or '
+ 'contains(concat(" ", normalize-space(@class), " "), " tabs-newtab-button ")'
+ ']' ,
aEvent . originalTarget ,
Ci . nsIDOMXPathResult . BOOLEAN _TYPE
) . booleanValue )
this . _handleNewTabCommand ( this . browser . selectedTab , this . getTreePref ( 'autoAttach.newTabButton' ) ) ;
2011-05-24 23:29:01 -04:00
else if ( aEvent . target . id == 'urlbar-go-button' || aEvent . target . id == 'go-button' )
2011-05-24 22:53:22 -04:00
this . _handleNewTabCommand ( this . browser . selectedTab , this . getTreePref ( 'autoAttach.goButton' ) ) ;
2011-05-04 14:55:40 -04:00
} ,
2011-05-24 14:27:53 -04:00
2011-05-25 16:54:46 -04:00
onBeforeTabDuplicate : function TSTWindow _onBeforeTabDuplicate ( aTab )
2011-05-24 14:27:53 -04:00
{
2011-05-24 22:53:22 -04:00
var b = this . getTabBrowserFromChild ( aTab ) || this . browser ;
this . _handleNewTabCommand ( aTab || b . selectedTab , this . getTreePref ( 'autoAttach.duplicateTabCommand' ) ) ;
2011-05-24 14:27:53 -04:00
} ,
2007-10-20 12:47:08 -04:00
2008-11-09 23:48:11 -05:00
/* Tree Style Tab<61> ̏<EFBFBD> <CC8F> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> s<EFBFBD> <73> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> O<EFBFBD> ɕ<EFBFBD> <C995> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ꂽ<EFBFBD> Z<EFBFBD> b<EFBFBD> V<EFBFBD> <56> <EFBFBD> <EFBFBD> <EFBFBD> ɂ <C982> <C282> ăc<C483> <63> <EFBFBD> [<5B> \<5C> <> <EFBFBD> <EFBFBD> */
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
{
this . _restoringTabs . forEach ( function ( aTab ) {
try {
var b = this . getTabBrowserFromChild ( aTab ) ;
2011-12-12 13:54:43 -05:00
if ( b ) b . treeStyleTab . handleRestoredTab ( aTab ) ;
2008-11-09 23:48:11 -05:00
}
catch ( e ) {
}
} , this ) ;
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 ;
this . setTreePref ( 'tabbar.fixed.' + orient , newFixed ) ;
} ) ;
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 ) ;
2009-12-25 23:49:58 -05:00
this . splitTabsToSubtrees ( tabs ) . forEach ( function ( aTabs ) {
if ( ! this . fireTabSubtreeClosingEvent ( aTabs [ 0 ] , aTabs ) )
return ;
var b = this . getTabBrowserFromChild ( aTabs [ 0 ] ) ;
2009-12-27 06:22:44 -05:00
if ( aOnlyChildren )
aTabs = aTabs . slice ( 1 ) ;
if ( ! aTabs . length )
return ;
this . stopRendering ( ) ;
this . markAsClosedSet ( aTabs ) ;
2011-05-25 16:54:46 -04:00
for ( let i = aTabs . length - 1 ; i > - 1 ; i -- )
2009-12-25 23:49:58 -05:00
{
2010-08-08 05:42:47 -04:00
b . removeTab ( aTabs [ i ] , { animate : true } ) ;
2009-12-25 23:49:58 -05:00
}
2009-12-27 06:22:44 -05:00
this . startRendering ( ) ;
2009-12-25 23:49:58 -05:00
this . fireTabSubtreeClosedEvent ( b , aTabs [ 0 ] , aTabs )
} , this ) ;
2007-10-19 22:44:14 -04:00
} ,
2009-12-25 12:55:55 -05:00
removeTabSubTree : function ( ) { return this . removeTabSubtree . apply ( this , arguments ) ; } , // obsolete, for backward compatibility
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 */
this . fireDataContainerEvent ( this . kEVENT _TYPE _SUBTREE _CLOSING , b , true , true , data ) &&
// for backward compatibility
this . fireDataContainerEvent ( this . kEVENT _TYPE _SUBTREE _CLOSING . replace ( /^nsDOM/ , '' ) , b , true , true , data )
) ;
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 */
2011-01-11 05:29:14 -05:00
this . fireDataContainerEvent ( this . kEVENT _TYPE _SUBTREE _CLOSED , aTabBrowser , true , false , data ) ;
2010-12-20 06:54:42 -05:00
// for backward compatibility
2011-01-11 05:29:14 -05:00
this . fireDataContainerEvent ( 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 ) ;
} ,
2009-12-25 12:55:55 -05:00
warnAboutClosingTabSubTreeOf : function ( ) { return this . warnAboutClosingTabSubtreeOf . apply ( this , arguments ) ; } , // obsolete, for backward compatibility
2011-05-25 16:54:46 -04:00
warnAboutClosingTabs : function TSTWindow _warnAboutClosingTabs ( aTabsCount )
2009-06-17 04:59:18 -04:00
{
if (
aTabsCount <= 1 ||
2009-06-17 06:09:52 -04:00
! this . 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 ( ) ;
var shouldClose = this . PromptService . confirmEx ( w ,
2009-06-17 04:59:18 -04:00
this . tabbrowserBundle . getString ( 'tabs.closeWarningTitle' ) ,
this . tabbrowserBundle . getFormattedString ( 'tabs.closeWarningMultipleTabs' , [ aTabsCount ] ) ,
2009-07-22 00:25:39 -04:00
( this . PromptService . BUTTON _TITLE _IS _STRING * this . PromptService . BUTTON _POS _0 ) +
( this . PromptService . BUTTON _TITLE _CANCEL * this . PromptService . BUTTON _POS _1 ) ,
2009-06-17 04:59:18 -04:00
this . tabbrowserBundle . getString ( 'tabs.closeButtonMultiple' ) ,
null , null ,
this . tabbrowserBundle . getString ( 'tabs.closeWarningPromptMe' ) ,
checked
) == 0 ;
if ( shouldClose && ! checked . value )
this . setPref ( 'browser.tabs.warnOnClose' , false ) ;
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 ] ) ;
}
} ,
2009-12-25 06:36:22 -05:00
reloadTabSubTree : function ( ) { return this . reloadTabSubtree . apply ( this , arguments ) ; } , // 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
{
2009-07-23 12:14:45 -04:00
aTabs = this . getRootTabs ( aTabs ) ;
if ( ! aTabs . length ) return ;
2009-07-23 11:34:28 -04:00
var b = this . getTabBrowserFromChild ( aTabs [ 0 ] ) ;
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
) ;
2009-12-25 06:27:23 -05:00
var root = this . getTreePref ( 'createSubtree.underParent' ) ?
2009-07-24 03:09:29 -04:00
b . addTab ( this . getGroupTabURI ( ) ) :
aTabs . shift ( ) ;
2011-05-25 16:54:46 -04:00
var self = this ;
this . Deferred . next ( function ( self ) {
2009-07-23 12:14:45 -04:00
aTabs . forEach ( function ( aTab ) {
b . treeStyleTab . attachTabTo ( aTab , root ) ;
2009-07-23 12:26:56 -04:00
b . treeStyleTab . collapseExpandTab ( aTab , false ) ;
2011-05-25 16:54:46 -04:00
} , self ) ;
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
}
2011-05-25 16:54:46 -04:00
} ) ;
2009-07-23 12:14:45 -04:00
} ,
2009-12-25 06:36:22 -05:00
createSubTree : function ( ) { return this . createSubtree . apply ( this , arguments ) ; } , // 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
{
aTabs = this . getRootTabs ( aTabs ) ;
if ( aTabs . length < 2 ) return false ;
var lastParent = this . getParentTab ( aTabs [ 0 ] ) ;
for ( let i = 1 , maxi = aTabs . length - 1 ; i < maxi ; i ++ )
{
let parent = this . getParentTab ( aTabs [ i ] ) ;
if ( ! lastParent || parent != lastParent ) return true ;
lastParent = parent ;
}
2009-07-23 12:26:56 -04:00
return this . getChildTabs ( lastParent ) . length != aTabs . length ;
2009-07-23 12:14:45 -04:00
} ,
2009-12-25 06:36:22 -05:00
canCreateSubTree : function ( ) { return this . canCreateSubtree . apply ( this , arguments ) ; } , // 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 = [ ] ;
if ( ! aTabs || ! aTabs . length ) return roots ;
aTabs = this . cleanUpTabsArray ( aTabs ) ;
2009-07-23 11:34:28 -04:00
aTabs . forEach ( function ( aTab ) {
2009-07-23 12:14:45 -04:00
var parent = this . getParentTab ( aTab ) ;
if ( parent && aTabs . indexOf ( parent ) > - 1 ) return ;
roots . push ( aTab ) ;
2009-07-23 11:34:28 -04:00
} , this ) ;
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
{
this . ObserverService . 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 ) ;
if ( ! parent ) return ;
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 ;
if ( index > aTab . _tPos ) index -- ;
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
{
2009-12-25 06:27:23 -05:00
if ( this . 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 ) ;
var closeTabs = this . getTabsArray ( 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 ) ;
closeTabs . reverse ( ) . forEach ( function ( aTab ) {
b . removeTab ( aTab ) ;
} ) ;
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 = {
2008-12-01 04:14:05 -05:00
action : this . kACTIONS _FOR _DESTINATION | this . kACTION _IMPORT
} ;
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 ;
2011-05-25 16:54:46 -04:00
} ) ;
2008-12-01 03:30:36 -05:00
}
return true ;
}
return false ;
} ,
2009-12-25 06:36:22 -05:00
tearOffSubTreeFromRemote : function ( ) { return this . tearOffSubtreeFromRemote . apply ( this , arguments ) ; } , // 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 ( ) {
2011-12-08 11:39:55 -05:00
return this . _restoringTree || this . restoringCount || this . window . _ _SS _tabsToRestore ;
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
{
var value = this . getPref ( aPrefName ) ;
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.
2009-09-03 02:24:06 -04:00
// this.autoHide.mode = this.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' :
2011-05-26 10:22:42 -04:00
this . themeManager . set ( this . 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
2007-10-16 13:22:28 -04:00
} ;
2011-05-26 11:35:43 -04:00
// rap('end of definition of window');
2010-03-27 10:52:25 -04:00