Merge pull request #393 from saneyuki/util

Split some pref methods from TSTBase
This commit is contained in:
YUKI "Piro" Hiroshi 2012-10-23 09:34:45 -07:00
commit edda4cd48b
12 changed files with 411 additions and 310 deletions

View File

@ -1,3 +1,7 @@
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this,
'TreeStyleTabUtils', 'resource://treestyletab-modules/utils.js');
var TreeStyleTabBookmarksService = { var TreeStyleTabBookmarksService = {
__proto__ : TreeStyleTabService, __proto__ : TreeStyleTabService,
@ -228,7 +232,7 @@ var TreeStyleTabBookmarksService = {
var sv = this; var sv = this;
with (ns) { with (ns) {
let (method = (sv.getTreePref('compatibility.TabUtilities') && PlacesUIUtils.TU__openTabset) ? let (method = (TreeStyleTabUtils.getTreePref('compatibility.TabUtilities') && PlacesUIUtils.TU__openTabset) ?
'TU__openTabset' : 'TU__openTabset' :
'_openTabset') { '_openTabset') {
eval('PlacesUIUtils.'+method+' = '+ eval('PlacesUIUtils.'+method+' = '+
@ -265,11 +269,11 @@ var TreeStyleTabBookmarksService = {
'$1' '$1'
) )
); );
if (sv.getTreePref('compatibility.TabUtilities') && method.indexOf('TU_') > -1) if (TreeStyleTabUtils.getTreePref('compatibility.TabUtilities') && method.indexOf('TU_') > -1)
window[method] = PlacesUIUtils[method]; window[method] = PlacesUIUtils[method];
} }
let (method = (sv.getTreePref('compatibility.TabUtilities') && PlacesUIUtils.TU_openContainerNodeInTabs) ? let (method = (TreeStyleTabUtils.getTreePref('compatibility.TabUtilities') && PlacesUIUtils.TU_openContainerNodeInTabs) ?
'TU_openContainerNodeInTabs' : 'TU_openContainerNodeInTabs' :
'openContainerNodeInTabs') { 'openContainerNodeInTabs') {
eval('PlacesUIUtils.'+method+' = '+ eval('PlacesUIUtils.'+method+' = '+
@ -288,11 +292,11 @@ var TreeStyleTabBookmarksService = {
'$1, aNode.title$2' '$1, aNode.title$2'
) )
); );
if (sv.getTreePref('compatibility.TabUtilities') && method.indexOf('TU_') > -1) if (TreeStyleTabUtils.getTreePref('compatibility.TabUtilities') && method.indexOf('TU_') > -1)
window[method] = PlacesUIUtils[method]; window[method] = PlacesUIUtils[method];
} }
let (method = (sv.getTreePref('compatibility.TabUtilities') && PlacesUIUtils.TU_openURINodesInTabs) ? let (method = (TreeStyleTabUtils.getTreePref('compatibility.TabUtilities') && PlacesUIUtils.TU_openURINodesInTabs) ?
'TU_openURINodesInTabs' : 'TU_openURINodesInTabs' :
'openURINodesInTabs') { 'openURINodesInTabs') {
eval('PlacesUIUtils.'+method+' = '+ eval('PlacesUIUtils.'+method+' = '+
@ -324,7 +328,7 @@ var TreeStyleTabBookmarksService = {
'$2' '$2'
) )
); );
if (sv.getTreePref('compatibility.TabUtilities') && method.indexOf('TU_') > -1) if (TreeStyleTabUtils.getTreePref('compatibility.TabUtilities') && method.indexOf('TU_') > -1)
window[method] = PlacesUIUtils[method]; window[method] = PlacesUIUtils[method];
} }
@ -415,7 +419,7 @@ var TreeStyleTabBookmarksService = {
} }
} }
if (sv.getTreePref('compatibility.TMP') && if (TreeStyleTabUtils.getTreePref('compatibility.TMP') &&
'TMP_Places' in aBrowserWindow && 'TMP_Places' in aBrowserWindow &&
'openGroup' in aBrowserWindow.TMP_Places) { 'openGroup' in aBrowserWindow.TMP_Places) {
result.treeStructure = treeStructure; result.treeStructure = treeStructure;

View File

@ -1,3 +1,7 @@
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this,
'TreeStyleTabUtils', 'resource://treestyletab-modules/utils.js');
var TreeStyleTabBookmarksServiceEditable = { var TreeStyleTabBookmarksServiceEditable = {
__proto__ : TreeStyleTabBookmarksService, __proto__ : TreeStyleTabBookmarksService,
@ -235,7 +239,7 @@ var TreeStyleTabBookmarksServiceEditable = {
var parentIndex = items.indexOf(newParentId); var parentIndex = items.indexOf(newParentId);
var newIndex; var newIndex;
if (this.getTreePref('insertNewChildAt') == this.kINSERT_FISRT) { if (TreeStyleTabUtils.getTreePref('insertNewChildAt') == this.kINSERT_FISRT) {
newIndex = treeStructure.indexOf(parentIndex); newIndex = treeStructure.indexOf(parentIndex);
} }
else { else {

View File

@ -1,4 +1,8 @@
Components.utils.import('resource://gre/modules/Services.jsm'); Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this,
'Services', 'resource://gre/modules/Services.jsm');
XPCOMUtils.defineLazyModuleGetter(this,
'TreeStyleTabUtils', 'resource://treestyletab-modules/utils.js');
TreeStyleTabWindowHelper.extraProperties = [ TreeStyleTabWindowHelper.extraProperties = [
TreeStyleTabService.kID, TreeStyleTabService.kID,
@ -17,7 +21,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
// Highlander // Highlander
// https://addons.mozilla.org/firefox/addon/4086 // https://addons.mozilla.org/firefox/addon/4086
if ('Highlander' in window && if ('Highlander' in window &&
sv.getTreePref('compatibility.Highlander')) { TreeStyleTabUtils.getTreePref('compatibility.Highlander')) {
eval('Highlander.overrideHandleLinkClick = '+ eval('Highlander.overrideHandleLinkClick = '+
Highlander.overrideHandleLinkClick.toSource().replace( Highlander.overrideHandleLinkClick.toSource().replace(
/(var )?origHandleLinkClick/g, /(var )?origHandleLinkClick/g,
@ -31,7 +35,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
// PermaTabs Mod // PermaTabs Mod
// https://addons.mozilla.org/firefox/addon/7816 // https://addons.mozilla.org/firefox/addon/7816
if ('permaTabs' in window && if ('permaTabs' in window &&
sv.getTreePref('compatibility.PermaTabs')) { TreeStyleTabUtils.getTreePref('compatibility.PermaTabs')) {
if ('__init' in permaTabs) { if ('__init' in permaTabs) {
// without delay, Firefox crashes on startup. // without delay, Firefox crashes on startup.
eval('permaTabs.__init = '+ eval('permaTabs.__init = '+
@ -50,7 +54,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
' var TST = TreeStyleTabService;\n' + ' var TST = TreeStyleTabService;\n' +
' if (this.TSTRestoredPermaTabsInfo === void(0)) {\n' + ' if (this.TSTRestoredPermaTabsInfo === void(0)) {\n' +
' try {\n' + ' try {\n' +
' eval("this.TSTRestoredPermaTabsInfo = "+(TST.getTreePref("permaTabsInfo") || "null"));\n' + ' eval("this.TSTRestoredPermaTabsInfo = "+(TreeStyleTabUtils.getTreePref("permaTabsInfo") || "null"));\n' +
' }\n' + ' }\n' +
' catch(e) {\n' + ' catch(e) {\n' +
' }\n' + ' }\n' +
@ -101,7 +105,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
' }\n' + ' }\n' +
' tabsInfo[this.permaTabs[index].id] = info;\n' + ' tabsInfo[this.permaTabs[index].id] = info;\n' +
' }\n' + ' }\n' +
' TST.setTreePref("permaTabsInfo", tabsInfo.toSource());\n' + ' TreeStyleTabUtils.setTreePref("permaTabsInfo", tabsInfo.toSource());\n' +
'}).call(this);' '}).call(this);'
) )
); );
@ -109,12 +113,12 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
} }
// Tab Mix Plus // Tab Mix Plus
if (sv.getTreePref('compatibility.TMP')) { if (TreeStyleTabUtils.getTreePref('compatibility.TMP')) {
document.documentElement.setAttribute('treestyletab-enable-compatibility-tmp', true); document.documentElement.setAttribute('treestyletab-enable-compatibility-tmp', true);
} }
// Tab Mix Plus, SessionStore API // Tab Mix Plus, SessionStore API
if ( if (
sv.getTreePref('compatibility.TMP') && TreeStyleTabUtils.getTreePref('compatibility.TMP') &&
('TabmixSessionData' in window || 'SessionData' in window) ('TabmixSessionData' in window || 'SessionData' in window)
) { ) {
let sessionData = window.TabmixSessionData || window.SessionData; let sessionData = window.TabmixSessionData || window.SessionData;
@ -187,7 +191,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
// https://addons.mozilla.org/firefox/addon/2324 // https://addons.mozilla.org/firefox/addon/2324
// We need to initialize TST before Session Manager restores the last session anyway! // We need to initialize TST before Session Manager restores the last session anyway!
if ('gSessionManager' in window && if ('gSessionManager' in window &&
sv.getTreePref('compatibility.SessionManager')) { TreeStyleTabUtils.getTreePref('compatibility.SessionManager')) {
if ('onLoad_proxy' in gSessionManager && if ('onLoad_proxy' in gSessionManager &&
'onLoad' in gSessionManager) { 'onLoad' in gSessionManager) {
eval('gSessionManager.onLoad = '+gSessionManager.onLoad.toSource().replace( eval('gSessionManager.onLoad = '+gSessionManager.onLoad.toSource().replace(
@ -215,7 +219,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
// FullerScreen // FullerScreen
// https://addons.mozilla.org/firefox/addon/4650 // https://addons.mozilla.org/firefox/addon/4650
if ('FS_onFullerScreen' in window && if ('FS_onFullerScreen' in window &&
sv.getTreePref('compatibility.FullerScreen')) { TreeStyleTabUtils.getTreePref('compatibility.FullerScreen')) {
let (functions = 'CheckIfFullScreen,FS_onFullerScreen,FS_onMouseMove'.split(',')) { let (functions = 'CheckIfFullScreen,FS_onFullerScreen,FS_onMouseMove'.split(',')) {
for (let i = 0, maxi = functions.length; i < maxi; i++) for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
@ -232,7 +236,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
// TooManyTabs // TooManyTabs
// https://addons.mozilla.org/firefox/addon/9429 // https://addons.mozilla.org/firefox/addon/9429
if ('tooManyTabs' in window && if ('tooManyTabs' in window &&
sv.getTreePref('compatibility.TooManyTabs')) { TreeStyleTabUtils.getTreePref('compatibility.TooManyTabs')) {
sv.registerExpandTwistyAreaBlocker('tooManyTabs'); sv.registerExpandTwistyAreaBlocker('tooManyTabs');
} }
@ -240,7 +244,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
// https://addons.mozilla.org/firefox/addon/dragndrop-toolbars/ // https://addons.mozilla.org/firefox/addon/dragndrop-toolbars/
if ('globDndtb' in window && if ('globDndtb' in window &&
globDndtb.setTheStuff && globDndtb.setTheStuff &&
sv.getTreePref('compatibility.DragNDropToolbars')) { TreeStyleTabUtils.getTreePref('compatibility.DragNDropToolbars')) {
let reinitTabbar = function() { let reinitTabbar = function() {
TreeStyleTabService.stopRendering(); TreeStyleTabService.stopRendering();
gBrowser.treeStyleTab.syncDestroyTabbar(); gBrowser.treeStyleTab.syncDestroyTabbar();
@ -278,7 +282,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
if ('mtSidebarStartup' in window && if ('mtSidebarStartup' in window &&
'mtSidebarShutdown' in window && 'mtSidebarShutdown' in window &&
'mtPreventHiding' in window && 'mtPreventHiding' in window &&
sv.getTreePref('compatibility.OptimozTweaks')) { TreeStyleTabUtils.getTreePref('compatibility.OptimozTweaks')) {
eval('window.mtSidebarStartup = '+window.mtSidebarStartup.toSource().replace( eval('window.mtSidebarStartup = '+window.mtSidebarStartup.toSource().replace(
'{', '{',
'{\n' + '{\n' +
@ -317,11 +321,11 @@ TreeStyleTabWindowHelper.overrideExtensionsBeforeBrowserInit = function TSTWH_ov
var sv = this.service; var sv = this.service;
// Tab Mix Plus // Tab Mix Plus
if (sv.getTreePref('compatibility.TMP') && if (TreeStyleTabUtils.getTreePref('compatibility.TMP') &&
'TMP_LastTab' in window) { 'TMP_LastTab' in window) {
TMP_LastTab.TabBar = gBrowser.mTabContainer; TMP_LastTab.TabBar = gBrowser.mTabContainer;
} }
if (sv.getTreePref('compatibility.TMP') && if (TreeStyleTabUtils.getTreePref('compatibility.TMP') &&
'isTabVisible' in gBrowser.mTabContainer && 'isTabVisible' in gBrowser.mTabContainer &&
'ensureTabIsVisible' in gBrowser.mTabContainer) { 'ensureTabIsVisible' in gBrowser.mTabContainer) {
function replaceHorizontalProps(aString) function replaceHorizontalProps(aString)
@ -357,7 +361,7 @@ TreeStyleTabWindowHelper.overrideExtensionsBeforeBrowserInit = function TSTWH_ov
// Tabberwocky // Tabberwocky
// https://addons.mozilla.org/firefox/addon/14439 // https://addons.mozilla.org/firefox/addon/14439
if ('tabberwocky' in window && if ('tabberwocky' in window &&
sv.getTreePref('compatibility.Tabberwocky')) { TreeStyleTabUtils.getTreePref('compatibility.Tabberwocky')) {
let listener = { let listener = {
handleEvent : function(aEvent) handleEvent : function(aEvent)
{ {
@ -402,7 +406,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// https://addons.mozilla.org/firefox/addon/8644 // https://addons.mozilla.org/firefox/addon/8644
if ('selectionlinks' in window && if ('selectionlinks' in window &&
'parseSelection' in selectionlinks && 'parseSelection' in selectionlinks &&
sv.getTreePref('compatibility.SelectionLinks')) { TreeStyleTabUtils.getTreePref('compatibility.SelectionLinks')) {
eval('selectionlinks.parseSelection = '+ eval('selectionlinks.parseSelection = '+
selectionlinks.parseSelection.toSource().replace( selectionlinks.parseSelection.toSource().replace(
/((?:[^\s:;]+.selectedTab\s*=\s*)?([^\s:;]+).addTab\()/g, /((?:[^\s:;]+.selectedTab\s*=\s*)?([^\s:;]+).addTab\()/g,
@ -416,7 +420,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Tab Mix Plus // Tab Mix Plus
if ( if (
sv.getTreePref('compatibility.TMP') && TreeStyleTabUtils.getTreePref('compatibility.TMP') &&
'TabmixTabbar' in window 'TabmixTabbar' in window
) { ) {
let DNDObserver = 'TMP_tabDNDObserver' in window ? TMP_tabDNDObserver : TabDNDObserver ; let DNDObserver = 'TMP_tabDNDObserver' in window ? TMP_tabDNDObserver : TabDNDObserver ;
@ -487,7 +491,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Super DragAndGo // Super DragAndGo
// https://addons.mozilla.org/firefox/addon/137 // https://addons.mozilla.org/firefox/addon/137
if ('superDrag' in window && if ('superDrag' in window &&
sv.getTreePref('compatibility.SuperDragAndGo')) { TreeStyleTabUtils.getTreePref('compatibility.SuperDragAndGo')) {
eval('superDrag.onDrop = '+ eval('superDrag.onDrop = '+
superDrag.onDrop.toSource().replace( superDrag.onDrop.toSource().replace(
/(var newTab = getBrowser\(\).addTab\([^\)]+\);)/g, /(var newTab = getBrowser\(\).addTab\([^\)]+\);)/g,
@ -502,7 +506,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Drag de Go // Drag de Go
// https://addons.mozilla.org/firefox/addon/2918 // https://addons.mozilla.org/firefox/addon/2918
if ('ddg_ges' in window && if ('ddg_ges' in window &&
sv.getTreePref('compatibility.DragDeGo')) { TreeStyleTabUtils.getTreePref('compatibility.DragDeGo')) {
eval('ddg_ges.Open = '+ eval('ddg_ges.Open = '+
ddg_ges.Open.toSource().replace( ddg_ges.Open.toSource().replace(
'if (mode[1] == "h" || mode[1] == "f") {', 'if (mode[1] == "h" || mode[1] == "f") {',
@ -523,7 +527,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Colorful Tabs // Colorful Tabs
// https://addons.mozilla.org/firefox/addon/1368 // https://addons.mozilla.org/firefox/addon/1368
if ('colorfulTabs' in window && if ('colorfulTabs' in window &&
sv.getTreePref('compatibility.ColorfulTabs')) { TreeStyleTabUtils.getTreePref('compatibility.ColorfulTabs')) {
let listener = { let listener = {
handleEvent : function(aEvent) handleEvent : function(aEvent)
{ {
@ -575,7 +579,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// FLST (Focus Last Selected Tab) // FLST (Focus Last Selected Tab)
// https://addons.mozilla.org/firefox/addon/32 // https://addons.mozilla.org/firefox/addon/32
if ('flst' in window && if ('flst' in window &&
sv.getTreePref('compatibility.FLST')) { TreeStyleTabUtils.getTreePref('compatibility.FLST')) {
TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) {
return !aTabBrowser.treeStyleTab.getPref('extensions.flst.enabled'); return !aTabBrowser.treeStyleTab.getPref('extensions.flst.enabled');
}); });
@ -583,7 +587,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Focus Last Selected Tab 0.9.5.x // Focus Last Selected Tab 0.9.5.x
// http://www.gozer.org/mozilla/extensions/ // http://www.gozer.org/mozilla/extensions/
if (sv.getTreePref('compatibility.FocusLastSelectedTab')) { if (TreeStyleTabUtils.getTreePref('compatibility.FocusLastSelectedTab')) {
sv.extensions.isAvailable('focuslastselectedtab@gozer.org', { ok : function() { sv.extensions.isAvailable('focuslastselectedtab@gozer.org', { ok : function() {
TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) {
return !aTabBrowser.selectedTab.hasAttribute('lastselected'); return !aTabBrowser.selectedTab.hasAttribute('lastselected');
@ -594,7 +598,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// LastTab // LastTab
// https://addons.mozilla.org/firefox/addon/112 // https://addons.mozilla.org/firefox/addon/112
if ('LastTab' in window && if ('LastTab' in window &&
sv.getTreePref('compatibility.LastTab')) { TreeStyleTabUtils.getTreePref('compatibility.LastTab')) {
TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) {
return !aTabBrowser.treeStyleTab.getPref('extensions.lasttab.focusLastTabOnClose'); return !aTabBrowser.treeStyleTab.getPref('extensions.lasttab.focusLastTabOnClose');
}); });
@ -603,7 +607,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// FireGestures // FireGestures
// https://addons.mozilla.org/firefox/addon/6366 // https://addons.mozilla.org/firefox/addon/6366
if ('FireGestures' in window && if ('FireGestures' in window &&
sv.getTreePref('compatibility.FireGestures')) { TreeStyleTabUtils.getTreePref('compatibility.FireGestures')) {
eval('FireGestures.onExtraGesture = '+ eval('FireGestures.onExtraGesture = '+
FireGestures.onExtraGesture.toSource().replace( FireGestures.onExtraGesture.toSource().replace(
'case "keypress-stop":', 'case "keypress-stop":',
@ -648,7 +652,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// http://www.mousegestures.org/ // http://www.mousegestures.org/
if ('mgBuiltInFunctions' in window && if ('mgBuiltInFunctions' in window &&
'mgLinkInTab' in mgBuiltInFunctions && 'mgLinkInTab' in mgBuiltInFunctions &&
sv.getTreePref('compatibility.MouseGesturesRedox')) { TreeStyleTabUtils.getTreePref('compatibility.MouseGesturesRedox')) {
eval('mgBuiltInFunctions.mgLinkInTab = '+ eval('mgBuiltInFunctions.mgLinkInTab = '+
mgBuiltInFunctions.mgLinkInTab.toSource().replace( mgBuiltInFunctions.mgLinkInTab.toSource().replace(
'var tab', 'var tab',
@ -659,7 +663,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Greasemonkey // Greasemonkey
// https://addons.mozilla.org/firefox/addon/748 // https://addons.mozilla.org/firefox/addon/748
if (sv.getTreePref('compatibility.Greasemonkey')) { if (TreeStyleTabUtils.getTreePref('compatibility.Greasemonkey')) {
try { try {
let hitchModule = Components.utils.import('resource://greasemonkey/util/hitch.js', {}); let hitchModule = Components.utils.import('resource://greasemonkey/util/hitch.js', {});
let hitch = hitchModule.hitch; let hitch = hitchModule.hitch;
@ -715,7 +719,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// SBM Counter // SBM Counter
// http://miniturbo.org/products/sbmcounter/ // http://miniturbo.org/products/sbmcounter/
if ('SBMCounter' in window && if ('SBMCounter' in window &&
sv.getTreePref('compatibility.SBMCounter')) { TreeStyleTabUtils.getTreePref('compatibility.SBMCounter')) {
eval('SBMCounter.action = '+ eval('SBMCounter.action = '+
SBMCounter.action.toSource().replace( SBMCounter.action.toSource().replace(
'gBrowser.selectedTab = gBrowser.addTab', 'gBrowser.selectedTab = gBrowser.addTab',
@ -727,7 +731,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Aging Tabs // Aging Tabs
// https://addons.mozilla.org/firefox/addon/3542 // https://addons.mozilla.org/firefox/addon/3542
if ('agingTabs' in window && if ('agingTabs' in window &&
sv.getTreePref('compatibility.AgingTabs')) { TreeStyleTabUtils.getTreePref('compatibility.AgingTabs')) {
eval('agingTabs.setColor = '+ eval('agingTabs.setColor = '+
agingTabs.setColor.toSource().replace( agingTabs.setColor.toSource().replace(
'{', '{',
@ -740,7 +744,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// https://addons.mozilla.org/firefox/addon/4336 // https://addons.mozilla.org/firefox/addon/4336
// Snap Links Plus // Snap Links Plus
// http://snaplinks.mozdev.org/ // http://snaplinks.mozdev.org/
if (sv.getTreePref('compatibility.SnapLinks')) { if (TreeStyleTabUtils.getTreePref('compatibility.SnapLinks')) {
if ('executeAction' in window && if ('executeAction' in window &&
'openTabs' in window) { 'openTabs' in window) {
eval('window.openTabs = '+ eval('window.openTabs = '+
@ -765,7 +769,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// https://addons.mozilla.org/firefox/addon/879 // https://addons.mozilla.org/firefox/addon/879
if ('mouselessbrowsing' in window && if ('mouselessbrowsing' in window &&
'EventHandler' in mouselessbrowsing && 'EventHandler' in mouselessbrowsing &&
sv.getTreePref('compatibility.MouselessBrowsing')) { TreeStyleTabUtils.getTreePref('compatibility.MouselessBrowsing')) {
if ('execute' in mouselessbrowsing.EventHandler) { if ('execute' in mouselessbrowsing.EventHandler) {
eval('mouselessbrowsing.EventHandler.execute = '+ eval('mouselessbrowsing.EventHandler.execute = '+
mouselessbrowsing.EventHandler.execute.toSource().replace( mouselessbrowsing.EventHandler.execute.toSource().replace(
@ -800,7 +804,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// https://addons.mozilla.org/firefox/addon/425 // https://addons.mozilla.org/firefox/addon/425
if ('LinkyContext' in window && if ('LinkyContext' in window &&
'prototype' in LinkyContext && 'prototype' in LinkyContext &&
sv.getTreePref('compatibility.Linky')) { TreeStyleTabUtils.getTreePref('compatibility.Linky')) {
let (methods = 'doSelected,doSelectedText,doImages,doAll,doAllPics,doValidateAll,doValidateSelected'.split(',')) { let (methods = 'doSelected,doSelectedText,doImages,doAll,doAllPics,doValidateAll,doValidateSelected'.split(',')) {
for (let i = 0, maxi = methods.length; i < maxi; i++) for (let i = 0, maxi = methods.length; i < maxi; i++)
{ {
@ -823,7 +827,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// https://addons.mozilla.org/firefox/addon/6912 // https://addons.mozilla.org/firefox/addon/6912
if ('QuickDrag' in window && if ('QuickDrag' in window &&
'_loadTab' in QuickDrag && '_loadTab' in QuickDrag &&
sv.getTreePref('compatibility.QuickDrag')) { TreeStyleTabUtils.getTreePref('compatibility.QuickDrag')) {
eval('QuickDrag._loadTab = '+ eval('QuickDrag._loadTab = '+
QuickDrag._loadTab.toSource().replace( QuickDrag._loadTab.toSource().replace(
/(gBrowser.loadOneTab\()/g, /(gBrowser.loadOneTab\()/g,
@ -835,7 +839,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Autohide // Autohide
// http://www.krickelkrackel.de/autohide/ // http://www.krickelkrackel.de/autohide/
if ('autoHIDE' in window && if ('autoHIDE' in window &&
sv.getTreePref('compatibility.Autohide')) { TreeStyleTabUtils.getTreePref('compatibility.Autohide')) {
let autoHideEventListener = { let autoHideEventListener = {
handleEvent : function(aEvent) handleEvent : function(aEvent)
{ {
@ -924,7 +928,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
sidewikiWindowHandler.barsContainer_ && sidewikiWindowHandler.barsContainer_ &&
sidewikiWindowHandler.barsContainer_.geometry_ && sidewikiWindowHandler.barsContainer_.geometry_ &&
sidewikiWindowHandler.barsContainer_.geometry_.__proto__.getWindowSizeForDrawers && sidewikiWindowHandler.barsContainer_.geometry_.__proto__.getWindowSizeForDrawers &&
sv.getTreePref('compatibility.GoogleToolbar.Sidewiki')) { TreeStyleTabUtils.getTreePref('compatibility.GoogleToolbar.Sidewiki')) {
let func = sidewikiWindowHandler.barsContainer_.geometry_.__proto__.getWindowSizeForDrawers.toSource(); let func = sidewikiWindowHandler.barsContainer_.geometry_.__proto__.getWindowSizeForDrawers.toSource();
if (func.indexOf('treeStyleTab') < 0) { if (func.indexOf('treeStyleTab') < 0) {
eval('sidewikiWindowHandler.barsContainer_.geometry_.__proto__.getWindowSizeForDrawers = '+func.replace( eval('sidewikiWindowHandler.barsContainer_.geometry_.__proto__.getWindowSizeForDrawers = '+func.replace(
@ -950,7 +954,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Smoothly Close Tabs // Smoothly Close Tabs
// https://addons.mozilla.org/firefox/addon/71410 // https://addons.mozilla.org/firefox/addon/71410
if ('SMOOTHLYCLOSETABS' in window && if ('SMOOTHLYCLOSETABS' in window &&
sv.getTreePref('compatibility.SmoothlyCloseTabs')) { TreeStyleTabUtils.getTreePref('compatibility.SmoothlyCloseTabs')) {
let replaceScrollProps = function(aString) { let replaceScrollProps = function(aString) {
return aString.replace( return aString.replace(
/\.scrollWidth/g, /\.scrollWidth/g,
@ -980,7 +984,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Super Tab Mode // Super Tab Mode
// https://addons.mozilla.org/firefox/addon/13288 // https://addons.mozilla.org/firefox/addon/13288
if ('stmM' in window && if ('stmM' in window &&
sv.getTreePref('compatibility.STM')) { TreeStyleTabUtils.getTreePref('compatibility.STM')) {
var observer = { var observer = {
domain : 'extensions.stm.', domain : 'extensions.stm.',
observe : function(aSubject, aTopic, aData) observe : function(aSubject, aTopic, aData)
@ -1046,7 +1050,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Tab Utilities // Tab Utilities
// https://addons.mozilla.org/firefox/addon/59961 // https://addons.mozilla.org/firefox/addon/59961
if ('tabutils' in window && if ('tabutils' in window &&
sv.getTreePref('compatibility.TabUtilities')) { TreeStyleTabUtils.getTreePref('compatibility.TabUtilities')) {
TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) {
return aTabBrowser.treeStyleTab.getPref('extensions.tabutils.selectOnClose') == 0; return aTabBrowser.treeStyleTab.getPref('extensions.tabutils.selectOnClose') == 0;
}); });
@ -1054,7 +1058,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Remove New Tab Button // Remove New Tab Button
// https://addons.mozilla.org/firefox/addon/10535 // https://addons.mozilla.org/firefox/addon/10535
if (sv.getTreePref('compatibility.RemoveNewTabButton')) { if (TreeStyleTabUtils.getTreePref('compatibility.RemoveNewTabButton')) {
sv.extensions.isAvailable('remove-new-tab-button@forerunnerdesigns.com', { ok : function() { sv.extensions.isAvailable('remove-new-tab-button@forerunnerdesigns.com', { ok : function() {
document.documentElement.setAttribute(TreeStyleTabService.kHIDE_NEWTAB, true); document.documentElement.setAttribute(TreeStyleTabService.kHIDE_NEWTAB, true);
}}); }});
@ -1064,7 +1068,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// https://addons.mozilla.org/firefox/addon/10909/ // https://addons.mozilla.org/firefox/addon/10909/
if ('IeTab' in window && if ('IeTab' in window &&
IeTab.prototype && IeTab.prototype &&
sv.getTreePref('compatibility.IETabPlus')) { TreeStyleTabUtils.getTreePref('compatibility.IETabPlus')) {
if (IeTab.prototype.switchTabEngine) if (IeTab.prototype.switchTabEngine)
eval('IeTab.prototype.switchTabEngine = '+ eval('IeTab.prototype.switchTabEngine = '+
IeTab.prototype.switchTabEngine.toSource().replace( IeTab.prototype.switchTabEngine.toSource().replace(
@ -1085,7 +1089,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// Locationbar2 // Locationbar2
// https://addons.mozilla.org/firefox/addon/locationbar²/ // https://addons.mozilla.org/firefox/addon/locationbar²/
if ('lb2_alternateStyles' in window && if ('lb2_alternateStyles' in window &&
sv.getTreePref('compatibility.Locationbar2')) { TreeStyleTabUtils.getTreePref('compatibility.Locationbar2')) {
let listening = false; let listening = false;
let listener = function(aEvent) { let listener = function(aEvent) {
switch (aEvent.type) switch (aEvent.type)
@ -1132,7 +1136,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// https://addons.mozilla.org/firefox/addon/instaclick/ // https://addons.mozilla.org/firefox/addon/instaclick/
if ('instaclick' in window && if ('instaclick' in window &&
'contentAreaClick2' in window.instaclick && 'contentAreaClick2' in window.instaclick &&
sv.getTreePref('compatibility.InstaClick')) { TreeStyleTabUtils.getTreePref('compatibility.InstaClick')) {
eval('instaclick.contentAreaClick2 = '+ eval('instaclick.contentAreaClick2 = '+
instaclick.contentAreaClick2.toSource().replace( instaclick.contentAreaClick2.toSource().replace(
'gBrowser.loadOneTab(', 'gBrowser.loadOneTab(',
@ -1145,7 +1149,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
// https://addons.mozilla.org/firefox/addon/duplicate-this-tab/ // https://addons.mozilla.org/firefox/addon/duplicate-this-tab/
if ('duplicatethistab' in window && if ('duplicatethistab' in window &&
'openLinkWithHistory' in window.duplicatethistab && 'openLinkWithHistory' in window.duplicatethistab &&
sv.getTreePref('compatibility.DuplicateThisTab')) { TreeStyleTabUtils.getTreePref('compatibility.DuplicateThisTab')) {
eval('duplicatethistab.openLinkWithHistory = '+ eval('duplicatethistab.openLinkWithHistory = '+
duplicatethistab.openLinkWithHistory.toSource().replace( duplicatethistab.openLinkWithHistory.toSource().replace(
'var newTab = ', 'var newTab = ',
@ -1164,7 +1168,7 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
var sv = this.service; var sv = this.service;
// Tab Mix Plus // Tab Mix Plus
if (sv.getTreePref('compatibility.TMP') && if (TreeStyleTabUtils.getTreePref('compatibility.TMP') &&
'TabmixTabbar' in window) { 'TabmixTabbar' in window) {
// correct broken appearance of the first tab // correct broken appearance of the first tab
var t = gBrowser.treeStyleTab.getFirstTab(gBrowser); var t = gBrowser.treeStyleTab.getFirstTab(gBrowser);
@ -1205,7 +1209,7 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
if ('MultiLinks_Wrapper' in window && if ('MultiLinks_Wrapper' in window &&
'LinksManager' in MultiLinks_Wrapper && 'LinksManager' in MultiLinks_Wrapper &&
'OpenInNewTabs' in MultiLinks_Wrapper.LinksManager && 'OpenInNewTabs' in MultiLinks_Wrapper.LinksManager &&
sv.getTreePref('compatibility.MultiLinks')) { TreeStyleTabUtils.getTreePref('compatibility.MultiLinks')) {
eval('MultiLinks_Wrapper.LinksManager.OpenInNewTabs = '+ eval('MultiLinks_Wrapper.LinksManager.OpenInNewTabs = '+
MultiLinks_Wrapper.LinksManager.OpenInNewTabs.toSource().replace( MultiLinks_Wrapper.LinksManager.OpenInNewTabs.toSource().replace(
'{', '{',
@ -1225,7 +1229,7 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
// https://addons.mozilla.org/firefox/addon/13906/ // https://addons.mozilla.org/firefox/addon/13906/
if ('domaintab' in window && if ('domaintab' in window &&
'TMP_howToOpen' in domaintab && 'TMP_howToOpen' in domaintab &&
sv.getTreePref('compatibility.DomainTab')) { TreeStyleTabUtils.getTreePref('compatibility.DomainTab')) {
eval('domaintab.TMP_howToOpen = '+ eval('domaintab.TMP_howToOpen = '+
domaintab.TMP_howToOpen.toSource().replace( domaintab.TMP_howToOpen.toSource().replace(
/(domaintab.DT_openNewTabWith\()/g, /(domaintab.DT_openNewTabWith\()/g,
@ -1237,7 +1241,7 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
// Personal Titlebar // Personal Titlebar
// https://addons.mozilla.org/irefox/addon/personal-titlebar/ // https://addons.mozilla.org/irefox/addon/personal-titlebar/
if (document.getElementById('personal-titlebar') && if (document.getElementById('personal-titlebar') &&
sv.getTreePref('compatibility.PersonalTitlebar')) { TreeStyleTabUtils.getTreePref('compatibility.PersonalTitlebar')) {
let titlebar = document.getElementById('titlebar'); let titlebar = document.getElementById('titlebar');
let personalTitlebar = document.getElementById('personal-titlebar'); let personalTitlebar = document.getElementById('personal-titlebar');
let listener = { let listener = {
@ -1287,7 +1291,7 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
// TotalToolbar // TotalToolbar
// http://totaltoolbar.mozdev.org/ // http://totaltoolbar.mozdev.org/
let (menu = document.getElementById('tt-toolbar-properties') && let (menu = document.getElementById('tt-toolbar-properties') &&
sv.getTreePref('compatibility.TotalToolbar')) { TreeStyleTabUtils.getTreePref('compatibility.TotalToolbar')) {
if (menu) { if (menu) {
let tabbarToolboxes = ['tt-toolbox-tabright', 'tt-toolbox-tableft'] let tabbarToolboxes = ['tt-toolbox-tabright', 'tt-toolbox-tableft']
.map(document.getElementById, document) .map(document.getElementById, document)
@ -1348,7 +1352,7 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
'gFxWeaveGlue' in window || // addon 'gFxWeaveGlue' in window || // addon
'gSyncUI' in window // Firefox 4 built-in 'gSyncUI' in window // Firefox 4 built-in
) && ) &&
sv.getTreePref('compatibility.FirefoxSync') TreeStyleTabUtils.getTreePref('compatibility.FirefoxSync')
) { ) {
let ns = {}; let ns = {};
try { // 1.4 try { // 1.4

View File

@ -38,6 +38,15 @@ const EXPORTED_SYMBOLS = ['AutoHideBrowser', 'AutoHideWindow'];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyGetter(this, 'TSTUtils', function() {
var ns = {};
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
return ns.TreeStyleTabUtils;
});
function AutoHideBrowser(aTabBrowser) function AutoHideBrowser(aTabBrowser)
{ {
this.init(aTabBrowser); this.init(aTabBrowser);
@ -82,12 +91,12 @@ AutoHideBrowser.prototype = {
getModeForNormal : function AHB_getModeForNormal(aTabBrowser) getModeForNormal : function AHB_getModeForNormal(aTabBrowser)
{ {
var b = aTabBrowser || this.browser; var b = aTabBrowser || this.browser;
return parseInt(b.getAttribute(this.kMODE+'-normal') || this.treeStyleTab.getTreePref('tabbar.autoHide.mode')); return parseInt(b.getAttribute(this.kMODE+'-normal') || TSTUtils.getTreePref('tabbar.autoHide.mode'));
}, },
getModeForFullScreen : function AHB_getModeForFullScreen(aTabBrowser) getModeForFullScreen : function AHB_getModeForFullScreen(aTabBrowser)
{ {
var b = aTabBrowser || this.browser; var b = aTabBrowser || this.browser;
return parseInt(b.getAttribute(this.kMODE+'-fullscreen') || this.treeStyleTab.getTreePref('tabbar.autoHide.mode.fullscreen')); return parseInt(b.getAttribute(this.kMODE+'-fullscreen') || TSTUtils.getTreePref('tabbar.autoHide.mode.fullscreen'));
}, },
get state() get state()
@ -156,8 +165,8 @@ AutoHideBrowser.prototype = {
default: default:
case this.kMODE_SHRINK: case this.kMODE_SHRINK:
return sv.getTreePref('tabbar.width') return TSTUtils.getTreePref('tabbar.width')
- sv.getTreePref('tabbar.shrunkenWidth'); - TSTUtils.getTreePref('tabbar.shrunkenWidth');
} }
}, },
get YOffset() get YOffset()
@ -281,7 +290,7 @@ AutoHideBrowser.prototype = {
{ {
this.mode = this.getModeForFullScreen(); this.mode = this.getModeForFullScreen();
this.end(); this.end();
this.mode = this.treeStyleTab.getTreePref('tabbar.autoHide.mode'); this.mode = TSTUtils.getTreePref('tabbar.autoHide.mode');
this.treeStyleTab.checkTabsIndentOverflow(); this.treeStyleTab.checkTabsIndentOverflow();
if (this.mode != this.kMODE_DISABLED) if (this.mode != this.kMODE_DISABLED)
this.start(); this.start();
@ -313,13 +322,13 @@ AutoHideBrowser.prototype = {
get shouldListenMouseMove() get shouldListenMouseMove()
{ {
return this.treeStyleTab.getTreePref('tabbar.autoShow.mousemove'); return TSTUtils.getTreePref('tabbar.autoShow.mousemove');
}, },
get shouldListenKeyEventsForAutoHide() get shouldListenKeyEventsForAutoHide()
{ {
return this.treeStyleTab.getTreePref('tabbar.autoShow.accelKeyDown') || return TSTUtils.getTreePref('tabbar.autoShow.accelKeyDown') ||
this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch'); TSTUtils.getTreePref('tabbar.autoShow.tabSwitch');
}, },
showHideOnMouseMove : function AHB_showHideOnMouseMove(aEvent) showHideOnMouseMove : function AHB_showHideOnMouseMove(aEvent)
@ -340,7 +349,7 @@ AutoHideBrowser.prototype = {
if ( if (
shouldShow && shouldShow &&
this.showHideReason & this.kKEEP_SHOWN_ON_MOUSEOVER && this.showHideReason & this.kKEEP_SHOWN_ON_MOUSEOVER &&
sv.getTreePref('tabbar.autoShow.keepShownOnMouseover') TSTUtils.getTreePref('tabbar.autoShow.keepShownOnMouseover')
) { ) {
this.showHideReason = this.kSHOWN_BY_MOUSEMOVE; this.showHideReason = this.kSHOWN_BY_MOUSEMOVE;
this.cancelDelayedShowForShortcut(); this.cancelDelayedShowForShortcut();
@ -348,7 +357,7 @@ AutoHideBrowser.prototype = {
} }
else if ( else if (
!shouldShow && !shouldShow &&
sv.getTreePref('tabbar.autoShow.mousemove') TSTUtils.getTreePref('tabbar.autoShow.mousemove')
) { ) {
this.showHideOnMouseMoveTimer = w.setTimeout( this.showHideOnMouseMoveTimer = w.setTimeout(
function(aSelf) { function(aSelf) {
@ -356,7 +365,7 @@ AutoHideBrowser.prototype = {
if (aSelf.showHideReason == aSelf.kSHOWN_BY_MOUSEMOVE) if (aSelf.showHideReason == aSelf.kSHOWN_BY_MOUSEMOVE)
aSelf.hide(aSelf.kSHOWN_BY_MOUSEMOVE); aSelf.hide(aSelf.kSHOWN_BY_MOUSEMOVE);
}, },
sv.getTreePref('tabbar.autoHide.delay'), TSTUtils.getTreePref('tabbar.autoHide.delay'),
this this
); );
} }
@ -368,7 +377,7 @@ AutoHideBrowser.prototype = {
aSelf.cancelHideForFeedback(); aSelf.cancelHideForFeedback();
aSelf.show(aSelf.kSHOWN_BY_MOUSEMOVE); aSelf.show(aSelf.kSHOWN_BY_MOUSEMOVE);
}, },
sv.getTreePref('tabbar.autoHide.delay'), TSTUtils.getTreePref('tabbar.autoHide.delay'),
this this
); );
} }
@ -516,7 +525,7 @@ AutoHideBrowser.prototype = {
showForFeedback : function AHB_showForFeedback() showForFeedback : function AHB_showForFeedback()
{ {
if (!this.enabled || if (!this.enabled ||
!this.treeStyleTab.getTreePref('tabbar.autoShow.feedback')) !TSTUtils.getTreePref('tabbar.autoShow.feedback'))
return; return;
var w = this.window; var w = this.window;
@ -545,7 +554,7 @@ AutoHideBrowser.prototype = {
if (aSelf.showHideReason == aSelf.kSHOWN_BY_FEEDBACK) if (aSelf.showHideReason == aSelf.kSHOWN_BY_FEEDBACK)
aSelf.hide(); aSelf.hide();
}, },
this.treeStyleTab.getTreePref('tabbar.autoShow.feedback.delay'), TSTUtils.getTreePref('tabbar.autoShow.feedback.delay'),
this this
); );
}, },
@ -563,9 +572,9 @@ AutoHideBrowser.prototype = {
if (aForceExpanded || if (aForceExpanded ||
this.expanded || this.expanded ||
this.mode != this.kMODE_SHRINK) this.mode != this.kMODE_SHRINK)
this.treeStyleTab.setTreePref('tabbar.width', this.treeStyleTab.maxTabbarWidth(aWidth)); TSTUtils.setTreePref('tabbar.width', this.treeStyleTab.maxTabbarWidth(aWidth));
else else
this.treeStyleTab.setTreePref('tabbar.shrunkenWidth', this.treeStyleTab.maxTabbarWidth(aWidth)); TSTUtils.setTreePref('tabbar.shrunkenWidth', this.treeStyleTab.maxTabbarWidth(aWidth));
}, },
updateMenuItem : function AHB_updateMenuItem(aNode) updateMenuItem : function AHB_updateMenuItem(aNode)
@ -597,14 +606,14 @@ AutoHideBrowser.prototype = {
get widthFromMode() get widthFromMode()
{ {
return (this.shrunken) ? return (this.shrunken) ?
this.treeStyleTab.getTreePref('tabbar.shrunkenWidth') : TSTUtils.getTreePref('tabbar.shrunkenWidth') :
this.treeStyleTab.getTreePref('tabbar.width') ; TSTUtils.getTreePref('tabbar.width') ;
}, },
get placeHolderWidthFromMode() get placeHolderWidthFromMode()
{ {
return (this.mode == this.kMODE_SHRINK) ? return (this.mode == this.kMODE_SHRINK) ?
this.treeStyleTab.getTreePref('tabbar.shrunkenWidth') : TSTUtils.getTreePref('tabbar.shrunkenWidth') :
this.treeStyleTab.getTreePref('tabbar.width') ; TSTUtils.getTreePref('tabbar.width') ;
}, },
get height() get height()
@ -728,7 +737,7 @@ AutoHideBrowser.prototype = {
default: default:
case this.kMODE_SHRINK: case this.kMODE_SHRINK:
if (pos == 'left' || pos == 'right') { if (pos == 'left' || pos == 'right') {
let width = sv.maxTabbarWidth(sv.getTreePref('tabbar.width')); let width = sv.maxTabbarWidth(TSTUtils.getTreePref('tabbar.width'));
sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE); sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE);
} }
break; break;
@ -766,7 +775,7 @@ AutoHideBrowser.prototype = {
sv.setTabbrowserAttribute(this.kAUTOHIDE, 'show'); sv.setTabbrowserAttribute(this.kAUTOHIDE, 'show');
sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_SHRUNKEN); sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_SHRUNKEN);
if (pos == 'left' || pos == 'right') if (pos == 'left' || pos == 'right')
sv.setTabStripAttribute('width', sv.getTreePref('tabbar.shrunkenWidth')); sv.setTabStripAttribute('width', TSTUtils.getTreePref('tabbar.shrunkenWidth'));
sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE); sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE);
break; break;
} }
@ -947,7 +956,7 @@ AutoHideBrowser.prototype = {
case this.treeStyleTab.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START: case this.treeStyleTab.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START:
this.cancelDelayedShowForShortcut(); this.cancelDelayedShowForShortcut();
if (this.enabled && if (this.enabled &&
this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch') && TSTUtils.getTreePref('tabbar.autoShow.tabSwitch') &&
( (
aEvent.getData('scrollDown') || aEvent.getData('scrollDown') ||
aEvent.getData('scrollUp') || aEvent.getData('scrollUp') ||
@ -1099,7 +1108,7 @@ AutoHideBrowser.prototype = {
w.TreeStyleTabService.accelKeyPressed w.TreeStyleTabService.accelKeyPressed
) { ) {
if (this.enabled && if (this.enabled &&
sv.getTreePref('tabbar.autoShow.accelKeyDown') && TSTUtils.getTreePref('tabbar.autoShow.accelKeyDown') &&
!this.expanded && !this.expanded &&
!this.delayedAutoShowTimer && !this.delayedAutoShowTimer &&
!this.delayedShowForShortcutTimer) { !this.delayedShowForShortcutTimer) {
@ -1110,7 +1119,7 @@ AutoHideBrowser.prototype = {
sv = null; sv = null;
b = null; b = null;
}, },
sv.getTreePref('tabbar.autoShow.accelKeyDown.delay'), TSTUtils.getTreePref('tabbar.autoShow.accelKeyDown.delay'),
this this
); );
this.delayedShowForShortcutDone = false; this.delayedShowForShortcutDone = false;
@ -1153,8 +1162,8 @@ AutoHideBrowser.prototype = {
this.showHideOnMouseMoveTimer = null; this.showHideOnMouseMoveTimer = null;
this.delayedShowForFeedbackTimer = null; this.delayedShowForFeedbackTimer = null;
b.setAttribute(this.kMODE+'-normal', sv.getTreePref('tabbar.autoHide.mode')); b.setAttribute(this.kMODE+'-normal', TSTUtils.getTreePref('tabbar.autoHide.mode'));
b.setAttribute(this.kMODE+'-fullscreen', sv.getTreePref('tabbar.autoHide.mode.fullscreen')); b.setAttribute(this.kMODE+'-fullscreen', TSTUtils.getTreePref('tabbar.autoHide.mode.fullscreen'));
sv.addPrefListener(this); sv.addPrefListener(this);
this.onPrefChange('browser.tabs.closeButtons'); this.onPrefChange('browser.tabs.closeButtons');
this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area'); this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area');
@ -1207,8 +1216,8 @@ AutoHideBrowser.prototype = {
}; };
for (var i in prefs) for (var i in prefs)
{ {
if (this.treeStyleTab.getTreePref(i) != prefs[i]) if (TSTUtils.getTreePref(i) != prefs[i])
this.treeStyleTab.setTreePref(i, prefs[i]); TSTUtils.setTreePref(i, prefs[i]);
} }
} }
@ -1263,10 +1272,10 @@ AutoHideWindow.prototype = {
} }
var mode = this.getMode(b) == AutoHideBrowser.prototype.kMODE_DISABLED ? var mode = this.getMode(b) == AutoHideBrowser.prototype.kMODE_DISABLED ?
this.treeStyleTab.getTreePref(toggleKey) : TSTUtils.getTreePref(toggleKey) :
AutoHideBrowser.prototype.kMODE_DISABLED ; AutoHideBrowser.prototype.kMODE_DISABLED ;
this.treeStyleTab.setTreePref(key, mode); TSTUtils.setTreePref(key, mode);
b.setAttribute(AutoHideBrowser.prototype.kMODE+'-'+(w.fullScreen ? 'fullscreen' : 'normal' ), mode); b.setAttribute(AutoHideBrowser.prototype.kMODE+'-'+(w.fullScreen ? 'fullscreen' : 'normal' ), mode);
b.treeStyleTab.autoHide.updateMode(); b.treeStyleTab.autoHide.updateMode();
}, },
@ -1310,9 +1319,9 @@ AutoHideWindow.prototype = {
{ {
return !this.treeStyleTab.ctrlTabPreviewsEnabled && return !this.treeStyleTab.ctrlTabPreviewsEnabled &&
( (
this.treeStyleTab.getTreePref('tabbar.autoShow.accelKeyDown') || TSTUtils.getTreePref('tabbar.autoShow.accelKeyDown') ||
this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch') || TSTUtils.getTreePref('tabbar.autoShow.tabSwitch') ||
this.treeStyleTab.getTreePref('tabbar.autoShow.feedback') TSTUtils.getTreePref('tabbar.autoShow.feedback')
); );
}, },

View File

@ -80,6 +80,12 @@ XPCOMUtils.defineLazyGetter(this, 'confirmWithPopup', function() {
Components.utils.import('resource://treestyletab-modules/lib/confirmWithPopup.js', ns); Components.utils.import('resource://treestyletab-modules/lib/confirmWithPopup.js', ns);
return ns.confirmWithPopup; return ns.confirmWithPopup;
}); });
XPCOMUtils.defineLazyGetter(this, 'TSTUtils', function() {
var ns = {};
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
return ns.TreeStyleTabUtils;
});
var TreeStyleTabBase = { var TreeStyleTabBase = {
__proto__ : window['piro.sakura.ne.jp'].prefs, __proto__ : window['piro.sakura.ne.jp'].prefs,
@ -373,7 +379,7 @@ var TreeStyleTabBase = {
{ {
// migrate old prefs // migrate old prefs
var orientalPrefs = []; var orientalPrefs = [];
switch (this.getTreePref('prefsVersion')) switch (TSTUtils.getTreePref('prefsVersion'))
{ {
case 0: case 0:
orientalPrefs = orientalPrefs.concat([ orientalPrefs = orientalPrefs.concat([
@ -383,42 +389,42 @@ var TreeStyleTabBase = {
]); ]);
case 1: case 1:
case 2: case 2:
if (this.getTreePref('urlbar.loadSameDomainToNewChildTab') !== null) { if (TSTUtils.getTreePref('urlbar.loadSameDomainToNewChildTab') !== null) {
let value = this.getTreePref('urlbar.loadSameDomainToNewChildTab'); let value = TSTUtils.getTreePref('urlbar.loadSameDomainToNewChildTab');
this.setTreePref('urlbar.loadSameDomainToNewTab', value); TSTUtils.setTreePref('urlbar.loadSameDomainToNewTab', value);
this.setTreePref('urlbar.loadSameDomainToNewTab.asChild', value); TSTUtils.setTreePref('urlbar.loadSameDomainToNewTab.asChild', value);
if (value) this.setTreePref('urlbar.loadDifferentDomainToNewTab', value); if (value) TSTUtils.setTreePref('urlbar.loadDifferentDomainToNewTab', value);
this.clearTreePref('urlbar.loadSameDomainToNewChildTab'); TSTUtils.clearTreePref('urlbar.loadSameDomainToNewChildTab');
} }
case 3: case 3:
if (this.getTreePref('loadDroppedLinkToNewChildTab') !== null) { if (TSTUtils.getTreePref('loadDroppedLinkToNewChildTab') !== null) {
this.setTreePref('dropLinksOnTab.behavior', TSTUtils.setTreePref('dropLinksOnTab.behavior',
this.getTreePref('loadDroppedLinkToNewChildTab.confirm') ? TSTUtils.getTreePref('loadDroppedLinkToNewChildTab.confirm') ?
this.kDROPLINK_ASK : this.kDROPLINK_ASK :
this.getTreePref('loadDroppedLinkToNewChildTab') ? TSTUtils.getTreePref('loadDroppedLinkToNewChildTab') ?
this.kDROPLINK_NEWTAB : this.kDROPLINK_NEWTAB :
this.kDROPLINK_LOAD this.kDROPLINK_LOAD
); );
this.clearTreePref('loadDroppedLinkToNewChildTab.confirm'); TSTUtils.clearTreePref('loadDroppedLinkToNewChildTab.confirm');
this.clearTreePref('loadDroppedLinkToNewChildTab'); TSTUtils.clearTreePref('loadDroppedLinkToNewChildTab');
} }
if (this.getTreePref('openGroupBookmarkAsTabSubTree') !== null) { if (TSTUtils.getTreePref('openGroupBookmarkAsTabSubTree') !== null) {
let behavior = 0; let behavior = 0;
if (this.getTreePref('openGroupBookmarkAsTabSubTree.underParent')) if (TSTUtils.getTreePref('openGroupBookmarkAsTabSubTree.underParent'))
behavior += this.kGROUP_BOOKMARK_USE_DUMMY; behavior += this.kGROUP_BOOKMARK_USE_DUMMY;
if (!this.getTreePref('openGroupBookmarkBehavior.confirm')) { if (!TSTUtils.getTreePref('openGroupBookmarkBehavior.confirm')) {
behavior += ( behavior += (
this.getTreePref('openGroupBookmarkAsTabSubTree') ? TSTUtils.getTreePref('openGroupBookmarkAsTabSubTree') ?
this.kGROUP_BOOKMARK_SUBTREE : this.kGROUP_BOOKMARK_SUBTREE :
this.getTreePref('browser.tabs.loadFolderAndReplace') ? TSTUtils.getTreePref('browser.tabs.loadFolderAndReplace') ?
this.kGROUP_BOOKMARK_REPLACE : this.kGROUP_BOOKMARK_REPLACE :
this.kGROUP_BOOKMARK_SEPARATE this.kGROUP_BOOKMARK_SEPARATE
); );
} }
this.setTreePref('openGroupBookmark.behavior', behavior); TSTUtils.setTreePref('openGroupBookmark.behavior', behavior);
this.clearTreePref('openGroupBookmarkBehavior.confirm'); TSTUtils.clearTreePref('openGroupBookmarkBehavior.confirm');
this.clearTreePref('openGroupBookmarkAsTabSubTree'); TSTUtils.clearTreePref('openGroupBookmarkAsTabSubTree');
this.clearTreePref('openGroupBookmarkAsTabSubTree.underParent'); TSTUtils.clearTreePref('openGroupBookmarkAsTabSubTree.underParent');
this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE)); this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
} }
case 4: case 4:
@ -446,31 +452,31 @@ var TreeStyleTabBase = {
} }
} }
case 5: case 5:
let (behavior = this.getTreePref('openGroupBookmark.behavior')) { let (behavior = TSTUtils.getTreePref('openGroupBookmark.behavior')) {
behavior = behavior | 2048; behavior = behavior | 2048;
this.setTreePref('openGroupBookmark.behavior', behavior); TSTUtils.setTreePref('openGroupBookmark.behavior', behavior);
} }
case 6: case 6:
let ( let (
general = this.getTreePref('autoAttachNewTabsAsChildren'), general = TSTUtils.getTreePref('autoAttachNewTabsAsChildren'),
search = this.getTreePref('autoAttachSearchResultAsChildren') search = TSTUtils.getTreePref('autoAttachSearchResultAsChildren')
) { ) {
if (general !== null) if (general !== null)
this.setTreePref('autoAttach', general); TSTUtils.setTreePref('autoAttach', general);
if (search !== null) if (search !== null)
this.setTreePref('autoAttach.searchResult', search); TSTUtils.setTreePref('autoAttach.searchResult', search);
} }
case 7: case 7:
let ( let (
enabled = this.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut'), enabled = TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut'),
delay = this.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay') delay = TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay')
) { ) {
if (enabled !== null) { if (enabled !== null) {
this.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut', enabled); TSTUtils.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut', enabled);
this.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.collapseOthers', enabled); TSTUtils.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.collapseOthers', enabled);
} }
if (delay !== null) if (delay !== null)
this.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay', delay); TSTUtils.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay', delay);
} }
case 8: case 8:
orientalPrefs = orientalPrefs.concat([ orientalPrefs = orientalPrefs.concat([
@ -489,7 +495,7 @@ var TreeStyleTabBase = {
} }
break; break;
} }
this.setTreePref('prefsVersion', this.kPREF_VERSION); TSTUtils.setTreePref('prefsVersion', this.kPREF_VERSION);
}, },
updateAeroPeek : function TSTUtils_updateAeroPeek() updateAeroPeek : function TSTUtils_updateAeroPeek()
@ -503,7 +509,7 @@ var TreeStyleTabBase = {
{ {
// Scriptish // Scriptish
// https://addons.mozilla.org/firefox/addon/scriptish/ // https://addons.mozilla.org/firefox/addon/scriptish/
if (this.getTreePref('compatibility.Scriptish')) { if (TSTUtils.getTreePref('compatibility.Scriptish')) {
try { try {
let tabModule = Components.utils.import('resource://scriptish/utils/Scriptish_openInTab.js', {}); let tabModule = Components.utils.import('resource://scriptish/utils/Scriptish_openInTab.js', {});
let Scriptish_openInTab = tabModule.Scriptish_openInTab; let Scriptish_openInTab = tabModule.Scriptish_openInTab;
@ -560,11 +566,11 @@ var TreeStyleTabBase = {
'%FORCE_NARROW_SCROLLBAR%') '%FORCE_NARROW_SCROLLBAR%')
.replace(/%FORCE_NARROW_SCROLLBAR%/g, .replace(/%FORCE_NARROW_SCROLLBAR%/g,
this.getTreePref('tabbar.narrowScrollbar.overrideSystemAppearance') ? TSTUtils.getTreePref('tabbar.narrowScrollbar.overrideSystemAppearance') ?
this.kOVERRIDE_SYSTEM_SCROLLBAR_APPEARANCE : '' ) this.kOVERRIDE_SYSTEM_SCROLLBAR_APPEARANCE : '' )
.replace(/%MODE%/g, this.kMODE) .replace(/%MODE%/g, this.kMODE)
.replace(/%NARROW%/g, this.kNARROW_SCROLLBAR) .replace(/%NARROW%/g, this.kNARROW_SCROLLBAR)
.replace(/%SIZE%/g, this.getTreePref('tabbar.narrowScrollbar.size')) .replace(/%SIZE%/g, TSTUtils.getTreePref('tabbar.narrowScrollbar.size'))
); );
this.lastAgentSheet = this.makeURIFromSpec(style); this.lastAgentSheet = this.makeURIFromSpec(style);
SSS.loadAndRegisterSheet(this.lastAgentSheet, SSS.AGENT_SHEET); SSS.loadAndRegisterSheet(this.lastAgentSheet, SSS.AGENT_SHEET);
@ -662,7 +668,7 @@ var TreeStyleTabBase = {
dropLinksOnTabBehavior : function TSTUtils_dropLinksOnTabBehavior() dropLinksOnTabBehavior : function TSTUtils_dropLinksOnTabBehavior()
{ {
var behavior = this.getTreePref('dropLinksOnTab.behavior'); var behavior = TSTUtils.getTreePref('dropLinksOnTab.behavior');
if (behavior & this.kDROPLINK_FIXED) return behavior; if (behavior & this.kDROPLINK_FIXED) return behavior;
var checked = { value : false }; var checked = { value : false };
@ -680,7 +686,7 @@ var TreeStyleTabBase = {
behavior = newChildTab ? this.kDROPLINK_NEWTAB : this.kDROPLINK_LOAD ; behavior = newChildTab ? this.kDROPLINK_NEWTAB : this.kDROPLINK_LOAD ;
if (checked.value) if (checked.value)
this.setTreePref('dropLinksOnTab.behavior', behavior); TSTUtils.setTreePref('dropLinksOnTab.behavior', behavior);
return behavior return behavior
}, },
@ -691,7 +697,7 @@ var TreeStyleTabBase = {
openGroupBookmarkBehavior : function TSTUtils_openGroupBookmarkBehavior() openGroupBookmarkBehavior : function TSTUtils_openGroupBookmarkBehavior()
{ {
var behavior = this.getTreePref('openGroupBookmark.behavior'); var behavior = TSTUtils.getTreePref('openGroupBookmark.behavior');
if (behavior & this.kGROUP_BOOKMARK_FIXED) return behavior; if (behavior & this.kGROUP_BOOKMARK_FIXED) return behavior;
var dummyTabFlag = behavior & this.kGROUP_BOOKMARK_USE_DUMMY; var dummyTabFlag = behavior & this.kGROUP_BOOKMARK_USE_DUMMY;
@ -719,7 +725,7 @@ var TreeStyleTabBase = {
behavior = behaviors[button]; behavior = behaviors[button];
if (checked.value) { if (checked.value) {
this.setTreePref('openGroupBookmark.behavior', behavior); TSTUtils.setTreePref('openGroupBookmark.behavior', behavior);
this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE)); this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
} }
return behavior; return behavior;
@ -736,7 +742,7 @@ var TreeStyleTabBase = {
bookmarkDroppedTabsBehavior : function TSTUtils_bookmarkDroppedTabsBehavior() bookmarkDroppedTabsBehavior : function TSTUtils_bookmarkDroppedTabsBehavior()
{ {
var behavior = this.getTreePref('bookmarkDroppedTabs.behavior'); var behavior = TSTUtils.getTreePref('bookmarkDroppedTabs.behavior');
if (behavior & this.kBOOKMARK_DROPPED_TABS_FIXED) return behavior; if (behavior & this.kBOOKMARK_DROPPED_TABS_FIXED) return behavior;
var checked = { value : false }; var checked = { value : false };
@ -760,7 +766,7 @@ var TreeStyleTabBase = {
behavior = behaviors[button]; behavior = behaviors[button];
if (checked.value) if (checked.value)
this.setTreePref('bookmarkDroppedTabs.behavior', behavior); TSTUtils.setTreePref('bookmarkDroppedTabs.behavior', behavior);
return behavior; return behavior;
}, },
@ -793,14 +799,14 @@ var TreeStyleTabBase = {
} }
if (aButtonIndex > 0) { if (aButtonIndex > 0) {
behavior ^= self.kUNDO_ASK; behavior ^= self.kUNDO_ASK;
self.setTreePref('undoCloseTabSet.behavior', behavior); TSTUtils.setTreePref('undoCloseTabSet.behavior', behavior);
} }
return behavior; return behavior;
}); });
}, },
get undoCloseTabSetBehavior() get undoCloseTabSetBehavior()
{ {
return this.getTreePref('undoCloseTabSet.behavior'); return TSTUtils.getTreePref('undoCloseTabSet.behavior');
}, },
kUNDO_ASK : 1, kUNDO_ASK : 1,
kUNDO_CLOSE_SET : 2, kUNDO_CLOSE_SET : 2,
@ -1812,7 +1818,7 @@ var TreeStyleTabBase = {
readyToOpenChildTab : function TSTUtils_readyToOpenChildTab(aFrameOrTabBrowser, aMultiple, aInsertBefore) /* PUBLIC API */ readyToOpenChildTab : function TSTUtils_readyToOpenChildTab(aFrameOrTabBrowser, aMultiple, aInsertBefore) /* PUBLIC API */
{ {
if (!this.getTreePref('autoAttach')) return false; if (!TSTUtils.getTreePref('autoAttach')) return false;
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser); var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
if (!frame) if (!frame)
@ -1911,7 +1917,7 @@ var TreeStyleTabBase = {
readyToOpenNewTabGroup : function TSTUtils_readyToOpenNewTabGroup(aFrameOrTabBrowser, aTreeStructure, aExpandAllTree) /* PUBLIC API */ readyToOpenNewTabGroup : function TSTUtils_readyToOpenNewTabGroup(aFrameOrTabBrowser, aTreeStructure, aExpandAllTree) /* PUBLIC API */
{ {
if (!this.getTreePref('autoAttach')) return false; if (!TSTUtils.getTreePref('autoAttach')) return false;
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser); var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
if (!frame) return false; if (!frame) return false;
@ -2040,7 +2046,7 @@ var TreeStyleTabBase = {
return ( return (
this.hasChildTabs(aTab) && this.hasChildTabs(aTab) &&
( (
this.getTreePref('closeParentBehavior') == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN || TSTUtils.getTreePref('closeParentBehavior') == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN ||
this.isSubtreeCollapsed(aTab) this.isSubtreeCollapsed(aTab)
) )
); );
@ -2584,7 +2590,7 @@ var TreeStyleTabBase = {
get position() /* PUBLIC API */ get position() /* PUBLIC API */
{ {
return this.getTreePref('tabbar.position') || 'top'; return TSTUtils.getTreePref('tabbar.position') || 'top';
}, },
set position(aValue) set position(aValue)
{ {
@ -2592,8 +2598,8 @@ var TreeStyleTabBase = {
if (!position || !/^(top|bottom|left|right)$/.test(position)) if (!position || !/^(top|bottom|left|right)$/.test(position))
position = 'top'; position = 'top';
if (position != this.getTreePref('tabbar.position')) if (position != TSTUtils.getTreePref('tabbar.position'))
this.setTreePref('tabbar.position', position); TSTUtils.setTreePref('tabbar.position', position);
return aValue; return aValue;
}, },
@ -2705,8 +2711,8 @@ var TreeStyleTabBase = {
updateTabWidthPrefs : function TSTUtils_updateTabWidthPrefs(aPrefName) updateTabWidthPrefs : function TSTUtils_updateTabWidthPrefs(aPrefName)
{ {
var expanded = this.getTreePref('tabbar.width'); var expanded = TSTUtils.getTreePref('tabbar.width');
var shrunken = this.getTreePref('tabbar.shrunkenWidth'); var shrunken = TSTUtils.getTreePref('tabbar.shrunkenWidth');
var originalExpanded = expanded; var originalExpanded = expanded;
var originalShrunken = shrunken; var originalShrunken = shrunken;
if (aPrefName == 'extensions.treestyletab.tabbar.shrunkenWidth') { if (aPrefName == 'extensions.treestyletab.tabbar.shrunkenWidth') {
@ -2725,28 +2731,11 @@ var TreeStyleTabBase = {
} }
if (expanded != originalExpanded || if (expanded != originalExpanded ||
shrunken != originalShrunken) { shrunken != originalShrunken) {
this.setTreePref('tabbar.width', Math.max(0, expanded)); TSTUtils.setTreePref('tabbar.width', Math.max(0, expanded));
this.setTreePref('tabbar.shrunkenWidth', Math.max(0, shrunken)); TSTUtils.setTreePref('tabbar.shrunkenWidth', Math.max(0, shrunken));
} }
}, },
/* Save/Load Prefs */
getTreePref : function TSTUtils_getTreePref(aPrefstring)
{
return this.getPref('extensions.treestyletab.'+aPrefstring);
},
setTreePref : function TSTUtils_setTreePref(aPrefstring, aNewValue)
{
return this.setPref('extensions.treestyletab.'+aPrefstring, aNewValue);
},
clearTreePref : function TSTUtils_clearTreePref(aPrefstring)
{
return this.clearPref('extensions.treestyletab.'+aPrefstring);
},
get shouldApplyNewPref() get shouldApplyNewPref()
{ {
return ( return (

View File

@ -42,6 +42,12 @@ Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, 'TSTUtils', function() {
var ns = {};
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
return ns.TreeStyleTabUtils;
});
Components.utils.import('resource://treestyletab-modules/window.js'); Components.utils.import('resource://treestyletab-modules/window.js');
function TreeStyleTabBrowser(aWindowService, aTabBrowser) function TreeStyleTabBrowser(aWindowService, aTabBrowser)
@ -123,7 +129,7 @@ TreeStyleTabBrowser.prototype = {
get scrollBox() get scrollBox()
{ {
return ( // Tab Mix Plus return ( // Tab Mix Plus
this.getTreePref('compatibility.TMP') && TSTUtils.getTreePref('compatibility.TMP') &&
this.document.getAnonymousElementByAttribute(this.mTabBrowser.mTabContainer, 'class', 'tabs-frame') this.document.getAnonymousElementByAttribute(this.mTabBrowser.mTabContainer, 'class', 'tabs-frame')
) || ) ||
this.mTabBrowser.mTabContainer.mTabstrip; this.mTabBrowser.mTabContainer.mTabstrip;
@ -199,7 +205,7 @@ TreeStyleTabBrowser.prototype = {
{ {
var orient = this.isVertical ? 'vertical' : 'horizontal' ; var orient = this.isVertical ? 'vertical' : 'horizontal' ;
if (!this.windowService.preInitialized) if (!this.windowService.preInitialized)
return this.getTreePref('tabbar.fixed.'+orient); return TSTUtils.getTreePref('tabbar.fixed.'+orient);
var b = this.mTabBrowser; var b = this.mTabBrowser;
if (!b) return false; if (!b) return false;
@ -308,7 +314,7 @@ TreeStyleTabBrowser.prototype = {
return ( return (
!this.isVertical && !this.isVertical &&
this.canCollapseSubtree() && this.canCollapseSubtree() &&
this.getTreePref('stackCollapsedTabs') TSTUtils.getTreePref('stackCollapsedTabs')
); );
}, },
@ -331,7 +337,7 @@ TreeStyleTabBrowser.prototype = {
var d = this.document; var d = this.document;
var label = d.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-stack') || // Mac OS X var label = d.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-stack') || // Mac OS X
( // Tab Mix Plus ( // Tab Mix Plus
this.getTreePref('compatibility.TMP') && TSTUtils.getTreePref('compatibility.TMP') &&
d.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-container') d.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-container')
) || ) ||
d.getAnonymousElementByAttribute(aTab, 'class', 'tab-text tab-label'); d.getAnonymousElementByAttribute(aTab, 'class', 'tab-text tab-label');
@ -342,7 +348,7 @@ TreeStyleTabBrowser.prototype = {
{ {
var d = this.document; var d = this.document;
var close = ( // Tab Mix Plus var close = ( // Tab Mix Plus
this.getTreePref('compatibility.TMP') && TSTUtils.getTreePref('compatibility.TMP') &&
d.getAnonymousElementByAttribute(aTab, 'class', 'tab-close-button always-right') d.getAnonymousElementByAttribute(aTab, 'class', 'tab-close-button always-right')
) || ) ||
d.getAnonymousElementByAttribute(aTab, 'class', 'tab-close-button'); d.getAnonymousElementByAttribute(aTab, 'class', 'tab-close-button');
@ -411,9 +417,9 @@ TreeStyleTabBrowser.prototype = {
isMultiRow : function TSTBrowser_isMultiRow() isMultiRow : function TSTBrowser_isMultiRow()
{ {
var w = this.window; var w = this.window;
return ('tabberwocky' in w && this.getTreePref('compatibility.Tabberwocky')) ? return ('tabberwocky' in w && TSTUtils.getTreePref('compatibility.Tabberwocky')) ?
(this.getPref('tabberwocky.multirow') && !this.isVertical) : (this.getPref('tabberwocky.multirow') && !this.isVertical) :
('TabmixTabbar' in w && this.getTreePref('compatibility.TMP')) ? ('TabmixTabbar' in w && TSTUtils.getTreePref('compatibility.TMP')) ?
w.TabmixTabbar.isMultiRow : w.TabmixTabbar.isMultiRow :
false ; false ;
}, },
@ -441,7 +447,7 @@ TreeStyleTabBrowser.prototype = {
var maxWidth = tabbarPlaceHolderWidth || tabbarWidth; var maxWidth = tabbarPlaceHolderWidth || tabbarWidth;
var faviconized = this.getTreePref('pinnedTab.faviconized'); var faviconized = TSTUtils.getTreePref('pinnedTab.faviconized');
var faviconizedSize = tabbar.childNodes[0].boxObject.height; var faviconizedSize = tabbar.childNodes[0].boxObject.height;
var width = faviconized ? faviconizedSize : maxWidth ; var width = faviconized ? faviconizedSize : maxWidth ;
@ -581,21 +587,21 @@ TreeStyleTabBrowser.prototype = {
if (this.isVertical) { if (this.isVertical) {
let key = this.autoHide.expanded ? let key = this.autoHide.expanded ?
'tabbar.width' : 'tabbar.shrunkenWidth' ; 'tabbar.width' : 'tabbar.shrunkenWidth' ;
let width = this.getTreePref(key); let width = TSTUtils.getTreePref(key);
let minWidth = this.scrollBox.boxObject.width let minWidth = this.scrollBox.boxObject.width
if (minWidth > width) { if (minWidth > width) {
this.setPrefForActiveWindow(function() { this.setPrefForActiveWindow(function() {
this.setTreePref(key, minWidth); TSTUtils.setTreePref(key, minWidth);
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PREF_CHANGE); this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PREF_CHANGE);
}); });
} }
} }
else { else {
let height = this.getTreePref('tabbar.height'); let height = TSTUtils.getTreePref('tabbar.height');
let minHeight = this.scrollBox.boxObject.height let minHeight = this.scrollBox.boxObject.height
if (minHeight > height) { if (minHeight > height) {
this.setPrefForActiveWindow(function() { this.setPrefForActiveWindow(function() {
this.setTreePref('tabbar.height', minHeight); TSTUtils.setTreePref('tabbar.height', minHeight);
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PREF_CHANGE); this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PREF_CHANGE);
}); });
} }
@ -630,8 +636,8 @@ TreeStyleTabBrowser.prototype = {
var position = this.position; var position = this.position;
this.fireTabbarPositionEvent(this.kEVENT_TYPE_TABBAR_POSITION_CHANGING, 'top', position); /* PUBLIC API */ this.fireTabbarPositionEvent(this.kEVENT_TYPE_TABBAR_POSITION_CHANGING, 'top', position); /* PUBLIC API */
this.setTabbrowserAttribute(this.kFIXED+'-horizontal', this.getTreePref('tabbar.fixed.horizontal') ? 'true' : null, b); this.setTabbrowserAttribute(this.kFIXED+'-horizontal', TSTUtils.getTreePref('tabbar.fixed.horizontal') ? 'true' : null, b);
this.setTabbrowserAttribute(this.kFIXED+'-vertical', this.getTreePref('tabbar.fixed.vertical') ? 'true' : null, b); this.setTabbrowserAttribute(this.kFIXED+'-vertical', TSTUtils.getTreePref('tabbar.fixed.vertical') ? 'true' : null, b);
/** /**
* <tabbrowser> has its custom background color for itself, but it * <tabbrowser> has its custom background color for itself, but it
@ -956,14 +962,14 @@ TreeStyleTabBrowser.prototype = {
aTab.removeAttribute('flex'); aTab.removeAttribute('flex');
aTab.maxWidth = 65000; aTab.maxWidth = 65000;
aTab.minWidth = 0; aTab.minWidth = 0;
if (this.getTreePref('compatibility.TMP')) if (TSTUtils.getTreePref('compatibility.TMP'))
aTab.setAttribute('dir', 'ltr'); // Tab Mix Plus aTab.setAttribute('dir', 'ltr'); // Tab Mix Plus
} }
else { else {
aTab.removeAttribute('align'); aTab.removeAttribute('align');
aTab.removeAttribute('maxwidth'); aTab.removeAttribute('maxwidth');
aTab.removeAttribute('minwidth'); aTab.removeAttribute('minwidth');
if (this.getTreePref('compatibility.TMP')) if (TSTUtils.getTreePref('compatibility.TMP'))
aTab.removeAttribute('dir'); // Tab Mix Plus aTab.removeAttribute('dir'); // Tab Mix Plus
} }
}, },
@ -1186,7 +1192,7 @@ TreeStyleTabBrowser.prototype = {
var pos = aNewPosition || this.getPositionFlag(this.position); var pos = aNewPosition || this.getPositionFlag(this.position);
if (b.getAttribute('id') != 'content' && if (b.getAttribute('id') != 'content' &&
!this.getTreePref('tabbar.position.subbrowser.enabled')) { !TSTUtils.getTreePref('tabbar.position.subbrowser.enabled')) {
pos = this.kTABBAR_TOP; pos = this.kTABBAR_TOP;
} }
@ -1213,7 +1219,7 @@ TreeStyleTabBrowser.prototype = {
// Tab Mix Plus // Tab Mix Plus
var scrollFrame, newTabBox, tabBarMode; var scrollFrame, newTabBox, tabBarMode;
if (this.getTreePref('compatibility.TMP')) { if (TSTUtils.getTreePref('compatibility.TMP')) {
scrollFrame = d.getAnonymousElementByAttribute(b.mTabContainer, 'class', 'tabs-frame') || scrollFrame = d.getAnonymousElementByAttribute(b.mTabContainer, 'class', 'tabs-frame') ||
d.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'scroll-tabs-frame'); d.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'scroll-tabs-frame');
newTabBox = d.getAnonymousElementByAttribute(b.mTabContainer, 'id', 'tabs-newbutton-box'); newTabBox = d.getAnonymousElementByAttribute(b.mTabContainer, 'id', 'tabs-newbutton-box');
@ -1260,7 +1266,7 @@ TreeStyleTabBrowser.prototype = {
if (scrollInnerBox) if (scrollInnerBox)
scrollInnerBox.removeAttribute('flex'); scrollInnerBox.removeAttribute('flex');
if (this.getTreePref('compatibility.TMP') && scrollFrame) { // Tab Mix Plus if (TSTUtils.getTreePref('compatibility.TMP') && scrollFrame) { // Tab Mix Plus
d.getAnonymousNodes(scrollFrame)[0].removeAttribute('flex'); d.getAnonymousNodes(scrollFrame)[0].removeAttribute('flex');
scrollFrame.parentNode.orient = scrollFrame.parentNode.orient =
scrollFrame.orient = 'vertical'; scrollFrame.orient = 'vertical';
@ -1275,7 +1281,7 @@ TreeStyleTabBrowser.prototype = {
this.setTabbrowserAttribute(this.kMODE, 'vertical'); this.setTabbrowserAttribute(this.kMODE, 'vertical');
let width = this.maxTabbarWidth(this.getTreePref('tabbar.width'), b); let width = this.maxTabbarWidth(TSTUtils.getTreePref('tabbar.width'), b);
this.setTabStripAttribute('width', width); this.setTabStripAttribute('width', width);
this.removeTabStripAttribute('height'); this.removeTabStripAttribute('height');
b.mPanelContainer.removeAttribute('height'); b.mPanelContainer.removeAttribute('height');
@ -1295,7 +1301,7 @@ TreeStyleTabBrowser.prototype = {
if (pos == this.kTABBAR_RIGHT) { if (pos == this.kTABBAR_RIGHT) {
this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'right'); this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'right');
if (this.getTreePref('tabbar.invertTab')) { if (TSTUtils.getTreePref('tabbar.invertTab')) {
this.setTabbrowserAttribute(this.kTAB_INVERTED, 'true'); this.setTabbrowserAttribute(this.kTAB_INVERTED, 'true');
this.indentTarget = 'right'; this.indentTarget = 'right';
} }
@ -1350,7 +1356,7 @@ TreeStyleTabBrowser.prototype = {
if (scrollInnerBox) if (scrollInnerBox)
scrollInnerBox.setAttribute('flex', 1); scrollInnerBox.setAttribute('flex', 1);
if (this.getTreePref('compatibility.TMP') && scrollFrame) { // Tab Mix Plus if (TSTUtils.getTreePref('compatibility.TMP') && scrollFrame) { // Tab Mix Plus
d.getAnonymousNodes(scrollFrame)[0].setAttribute('flex', 1); d.getAnonymousNodes(scrollFrame)[0].setAttribute('flex', 1);
scrollFrame.parentNode.orient = scrollFrame.parentNode.orient =
scrollFrame.orient = 'horizontal'; scrollFrame.orient = 'horizontal';
@ -1361,7 +1367,7 @@ TreeStyleTabBrowser.prototype = {
if (toolboxContainer) if (toolboxContainer)
toolboxContainer.orient = 'horizontal'; toolboxContainer.orient = 'horizontal';
this.setTabbrowserAttribute(this.kMODE, this.getTreePref('tabbar.multirow') ? 'multirow' : 'horizontal'); this.setTabbrowserAttribute(this.kMODE, TSTUtils.getTreePref('tabbar.multirow') ? 'multirow' : 'horizontal');
this.removeTabbrowserAttribute(this.kTAB_INVERTED); this.removeTabbrowserAttribute(this.kTAB_INVERTED);
if (strip.localName == 'toolbar') { if (strip.localName == 'toolbar') {
@ -1409,7 +1415,7 @@ TreeStyleTabBrowser.prototype = {
tab.style.removeProperty(this.collapseCSSProp); tab.style.removeProperty(this.collapseCSSProp);
} }
this.indentProp = this.getTreePref('indent.property'); this.indentProp = TSTUtils.getTreePref('indent.property');
this.indentCSSProp = this.indentProp+'-'+this.indentTarget; this.indentCSSProp = this.indentProp+'-'+this.indentTarget;
this.collapseCSSProp = 'margin-'+this.collapseTarget; this.collapseCSSProp = 'margin-'+this.collapseTarget;
@ -1582,12 +1588,12 @@ TreeStyleTabBrowser.prototype = {
if (TabsOnTop && !this.windowService.isPopupWindow && if (TabsOnTop && !this.windowService.isPopupWindow &&
this.windowService.initialized) { this.windowService.initialized) {
let currentState = TabsOnTop.enabled; let currentState = TabsOnTop.enabled;
let originalState = this.getTreePref('tabsOnTop.originalState'); let originalState = TSTUtils.getTreePref('tabsOnTop.originalState');
if (originalState !== null && if (originalState !== null &&
currentState != originalState && currentState != originalState &&
this.windowService.tabsOnTopChangingByUI && this.windowService.tabsOnTopChangingByUI &&
!this.windowService.changingTabsOnTop) !this.windowService.changingTabsOnTop)
this.setTreePref('tabsOnTop.originalState', currentState); TSTUtils.setTreePref('tabsOnTop.originalState', currentState);
// Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=555987 // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=555987
// This should be done when the value of the "ordinal" attribute // This should be done when the value of the "ordinal" attribute
// is modified dynamically. So, we don' have to do it before // is modified dynamically. So, we don' have to do it before
@ -1605,7 +1611,7 @@ TreeStyleTabBrowser.prototype = {
} }
else { else {
this.fixed = false; // ensure set to the current orient this.fixed = false; // ensure set to the current orient
this.setTabStripAttribute('height', this.maxTabbarHeight(this.getTreePref('tabbar.height'), b)); this.setTabStripAttribute('height', this.maxTabbarHeight(TSTUtils.getTreePref('tabbar.height'), b));
} }
if (toggleTabsOnTop) { if (toggleTabsOnTop) {
if (this.position == 'top') if (this.position == 'top')
@ -1638,12 +1644,12 @@ TreeStyleTabBrowser.prototype = {
delete self.deferredTasks['updateTabbarState']; delete self.deferredTasks['updateTabbarState'];
}); });
var allowToCollapse = this.getTreePref('allowSubtreeCollapseExpand.'+orient); var allowToCollapse = TSTUtils.getTreePref('allowSubtreeCollapseExpand.'+orient);
if (this.allowSubtreeCollapseExpand != allowToCollapse) if (this.allowSubtreeCollapseExpand != allowToCollapse)
this.collapseExpandAllSubtree(false, false); this.collapseExpandAllSubtree(false, false);
this.allowSubtreeCollapseExpand = allowToCollapse; this.allowSubtreeCollapseExpand = allowToCollapse;
this.maxTreeLevel = this.getTreePref('maxTreeLevel.'+orient); this.maxTreeLevel = TSTUtils.getTreePref('maxTreeLevel.'+orient);
this.setTabbrowserAttribute(this.kALLOW_STACK, this.canStackTabs ? 'true' : null); this.setTabbrowserAttribute(this.kALLOW_STACK, this.canStackTabs ? 'true' : null);
this.updateTabsZIndex(this.canStackTabs); this.updateTabsZIndex(this.canStackTabs);
@ -1665,10 +1671,10 @@ TreeStyleTabBrowser.prototype = {
canCollapse : b.getAttribute(this.kALLOW_COLLAPSE) == 'true' canCollapse : b.getAttribute(this.kALLOW_COLLAPSE) == 'true'
}; };
var newState = { var newState = {
fixed : this.getTreePref('tabbar.fixed.'+orient), fixed : TSTUtils.getTreePref('tabbar.fixed.'+orient),
maxTreeLevel : this.getTreePref('maxTreeLevel.'+orient), maxTreeLevel : TSTUtils.getTreePref('maxTreeLevel.'+orient),
indented : this.getTreePref('maxTreeLevel.'+orient) != 0, indented : TSTUtils.getTreePref('maxTreeLevel.'+orient) != 0,
canCollapse : this.getTreePref('allowSubtreeCollapseExpand.'+orient) canCollapse : TSTUtils.getTreePref('allowSubtreeCollapseExpand.'+orient)
}; };
if (oldState.fixed == newState.fixed && if (oldState.fixed == newState.fixed &&
@ -1775,11 +1781,11 @@ TreeStyleTabBrowser.prototype = {
let realWidth = parseInt(this._tabStripPlaceHolder.getAttribute('width') || box.width); let realWidth = parseInt(this._tabStripPlaceHolder.getAttribute('width') || box.width);
let realHeight = parseInt(this._tabStripPlaceHolder.getAttribute('height') || box.height); let realHeight = parseInt(this._tabStripPlaceHolder.getAttribute('height') || box.height);
let width = (this.autoHide.expanded && this.isVertical && (aReason & this.kTABBAR_UPDATE_SYNC_TO_TABBAR) ? let width = (this.autoHide.expanded && this.isVertical && (aReason & this.kTABBAR_UPDATE_SYNC_TO_TABBAR) ?
this.maxTabbarWidth(this.getTreePref('tabbar.width')) : this.maxTabbarWidth(TSTUtils.getTreePref('tabbar.width')) :
0 0
) || realWidth; ) || realWidth;
let height = (this.autoHide.expanded && !this.isVertical && (aReason & this.kTABBAR_UPDATE_SYNC_TO_TABBAR) ? let height = (this.autoHide.expanded && !this.isVertical && (aReason & this.kTABBAR_UPDATE_SYNC_TO_TABBAR) ?
this.maxTabbarHeight(this.getTreePref('tabbar.height')) : this.maxTabbarHeight(TSTUtils.getTreePref('tabbar.height')) :
0 0
) || realHeight; ) || realHeight;
let yOffset = pos == 'bottom' ? height - realHeight : 0 ; let yOffset = pos == 'bottom' ? height - realHeight : 0 ;
@ -1802,7 +1808,7 @@ TreeStyleTabBrowser.prototype = {
strip.collapsed = tabContainerBox.collapsed = collapsed; strip.collapsed = tabContainerBox.collapsed = collapsed;
if (statusPanel && this.getTreePref('repositionStatusPanel')) { if (statusPanel && TSTUtils.getTreePref('repositionStatusPanel')) {
let offsetParentBox = this.utils.findOffsetParent(statusPanel).boxObject; let offsetParentBox = this.utils.findOffsetParent(statusPanel).boxObject;
let contentBox = this.mTabBrowser.mPanelContainer.boxObject; let contentBox = this.mTabBrowser.mPanelContainer.boxObject;
let chromeMargins = (d.documentElement.getAttribute('chromemargin') || '0,0,0,0').split(','); let chromeMargins = (d.documentElement.getAttribute('chromemargin') || '0,0,0,0').split(',');
@ -1827,7 +1833,7 @@ TreeStyleTabBrowser.prototype = {
if ( if (
statusPanel && statusPanel &&
( (
this.getTreePref('repositionStatusPanel') || TSTUtils.getTreePref('repositionStatusPanel') ||
statusPanel.__treestyletab__repositioned statusPanel.__treestyletab__repositioned
) )
) { ) {
@ -2093,8 +2099,8 @@ TreeStyleTabBrowser.prototype = {
}; };
for (var i in prefs) for (var i in prefs)
{ {
if (prefs[i] !== void(0) && this.getTreePref(i) != prefs[i]) if (prefs[i] !== void(0) && TSTUtils.getTreePref(i) != prefs[i])
this.setTreePref(i, prefs[i]); TSTUtils.setTreePref(i, prefs[i]);
} }
this.position = this.position; this.position = this.position;
}, },
@ -2330,8 +2336,8 @@ TreeStyleTabBrowser.prototype = {
case 'extensions.treestyletab.tabbar.style': case 'extensions.treestyletab.tabbar.style':
case 'extensions.treestyletab.tabbar.style.aero': case 'extensions.treestyletab.tabbar.style.aero':
this.setTabbarStyle(this.getTreePref('tabbar.style')); this.setTabbarStyle(TSTUtils.getTreePref('tabbar.style'));
value = this.getTreePref('twisty.style'); value = TSTUtils.getTreePref('twisty.style');
if (value != 'auto') if (value != 'auto')
return; return;
case 'extensions.treestyletab.twisty.style': case 'extensions.treestyletab.twisty.style':
@ -2460,7 +2466,7 @@ TreeStyleTabBrowser.prototype = {
aStyle = aStyle.toLowerCase(); aStyle = aStyle.toLowerCase();
if (aStyle.indexOf('default') == 0) { // old name (for compatibility) if (aStyle.indexOf('default') == 0) { // old name (for compatibility)
this.setTreePref('tabbar.style', aStyle = aStyle.replace('default', 'plain')); TSTUtils.setTreePref('tabbar.style', aStyle = aStyle.replace('default', 'plain'));
} }
if (aStyle) { if (aStyle) {
@ -2473,7 +2479,7 @@ TreeStyleTabBrowser.prototype = {
additionalValues.push('color'); additionalValues.push('color');
if (/^(plain|mixed)$/.test(aStyle)) if (/^(plain|mixed)$/.test(aStyle))
additionalValues.push('shadow'); additionalValues.push('shadow');
if (this.getTreePref('tabbar.style.aero')) if (TSTUtils.getTreePref('tabbar.style.aero'))
additionalValues.push('aero'); additionalValues.push('aero');
if (additionalValues.length) if (additionalValues.length)
aStyle = additionalValues.join(' ')+' '+aStyle; aStyle = additionalValues.join(' ')+' '+aStyle;
@ -2493,7 +2499,7 @@ TreeStyleTabBrowser.prototype = {
aStyle = 'modern-black'; aStyle = 'modern-black';
if (this.getTreePref('tabbar.style') == 'sidebar') { if (TSTUtils.getTreePref('tabbar.style') == 'sidebar') {
aStyle = 'osx'; aStyle = 'osx';
} }
else if ( else if (
@ -2762,7 +2768,7 @@ TreeStyleTabBrowser.prototype = {
} }
else if ( else if (
parent && parent &&
this.getTreePref('insertNewChildAt') == this.kINSERT_FISRT && TSTUtils.getTreePref('insertNewChildAt') == this.kINSERT_FISRT &&
(this.multipleCount <= 0 || this._addedCountInThisLoop <= 0) (this.multipleCount <= 0 || this._addedCountInThisLoop <= 0)
) { ) {
/* /*
@ -3698,7 +3704,7 @@ TreeStyleTabBrowser.prototype = {
_restoreSubtreeCollapsedState : function TSTBrowser_restoreSubtreeCollapsedState(aTab, aCollapsed) _restoreSubtreeCollapsedState : function TSTBrowser_restoreSubtreeCollapsedState(aTab, aCollapsed)
{ {
var shouldCollapse = this.getTreePref('collapseExpandSubtree.sessionRestore'); var shouldCollapse = TSTUtils.getTreePref('collapseExpandSubtree.sessionRestore');
if (aCollapsed === void(0)) if (aCollapsed === void(0))
aCollapsed = this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true'; aCollapsed = this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true';
@ -4081,13 +4087,13 @@ TreeStyleTabBrowser.prototype = {
) )
return; return;
var shouldCollapseExpandNow = this.getTreePref('autoCollapseExpandSubtreeOnSelect'); var shouldCollapseExpandNow = TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect');
var newActiveTabOptions = { var newActiveTabOptions = {
canCollapseTree : shouldCollapseExpandNow, canCollapseTree : shouldCollapseExpandNow,
canExpandTree : shouldCollapseExpandNow canExpandTree : shouldCollapseExpandNow
}; };
if (this.isCollapsed(tab)) { if (this.isCollapsed(tab)) {
if (this.getTreePref('autoExpandSubtreeOnCollapsedChildFocused')) { if (TSTUtils.getTreePref('autoExpandSubtreeOnCollapsedChildFocused')) {
this.getAncestorTabs(tab).forEach(function(aAncestor) { this.getAncestorTabs(tab).forEach(function(aAncestor) {
this.collapseExpandSubtree(aAncestor, false); this.collapseExpandSubtree(aAncestor, false);
}, this); }, this);
@ -4112,7 +4118,7 @@ TreeStyleTabBrowser.prototype = {
* only when it is activated by user preference expressly. * only when it is activated by user preference expressly.
*/ */
this._focusChangedByCurrentTabRemove && this._focusChangedByCurrentTabRemove &&
!this.getTreePref('autoCollapseExpandSubtreeOnSelect.onCurrentTabRemove') !TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect.onCurrentTabRemove')
) )
) { ) {
// do nothing! // do nothing!
@ -4122,13 +4128,13 @@ TreeStyleTabBrowser.prototype = {
this._focusChangedByShortcut && this._focusChangedByShortcut &&
this.windowService.accelKeyPressed this.windowService.accelKeyPressed
) { ) {
if (this.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut')) { if (TSTUtils.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut')) {
newActiveTabOptions.canExpandTree = true; newActiveTabOptions.canExpandTree = true;
newActiveTabOptions.canCollapseTree = ( newActiveTabOptions.canCollapseTree = (
newActiveTabOptions.canCollapseTree && newActiveTabOptions.canCollapseTree &&
this.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.collapseOthers') TSTUtils.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.collapseOthers')
); );
let delay = this.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay'); let delay = TSTUtils.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay');
if (delay > 0) { if (delay > 0) {
this._autoExpandOnTabSelectTimer = this.window.setTimeout(function(aSelf) { this._autoExpandOnTabSelectTimer = this.window.setTimeout(function(aSelf) {
if (tab && tab.parentNode) if (tab && tab.parentNode)
@ -4197,7 +4203,7 @@ TreeStyleTabBrowser.prototype = {
this._focusChangedByShortcut = this.windowService.accelKeyPressed; this._focusChangedByShortcut = this.windowService.accelKeyPressed;
if (!this.canCollapseSubtree(this.mTabBrowser.selectedTab) || if (!this.canCollapseSubtree(this.mTabBrowser.selectedTab) ||
this.getTreePref('focusMode') != this.kFOCUS_VISIBLE) TSTUtils.getTreePref('focusMode') != this.kFOCUS_VISIBLE)
return false; return false;
if (this.processArrowKeyOnFocusAdvanced()) if (this.processArrowKeyOnFocusAdvanced())
@ -4242,7 +4248,7 @@ TreeStyleTabBrowser.prototype = {
break; break;
case 'right': case 'right':
if (this.getTreePref('tabbar.invertTab')) { if (TSTUtils.getTreePref('tabbar.invertTab')) {
collapse = event.right; collapse = event.right;
expand = event.left; expand = event.left;
} }
@ -4352,7 +4358,7 @@ TreeStyleTabBrowser.prototype = {
let tab = this.getTabFromEvent(aEvent); let tab = this.getTabFromEvent(aEvent);
if (tab && if (tab &&
this.hasChildTabs(tab) && this.hasChildTabs(tab) &&
this.getTreePref('collapseExpandSubtree.dblclick')) { TSTUtils.getTreePref('collapseExpandSubtree.dblclick')) {
this.manualCollapseExpandSubtree(tab, tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true'); this.manualCollapseExpandSubtree(tab, tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true');
aEvent.preventDefault(); aEvent.preventDefault();
aEvent.stopPropagation(); aEvent.stopPropagation();
@ -4476,7 +4482,7 @@ TreeStyleTabBrowser.prototype = {
let item = aEvent.currentTarget.querySelector('*[id^="'+id+'"]'); let item = aEvent.currentTarget.querySelector('*[id^="'+id+'"]');
if (!item) continue; if (!item) continue;
items[id] = item; items[id] = item;
if (this.getTreePref('show.'+id)) if (TSTUtils.getTreePref('show.'+id))
item.removeAttribute('hidden'); item.removeAttribute('hidden');
else else
item.setAttribute('hidden', true); item.setAttribute('hidden', true);
@ -4682,11 +4688,11 @@ TreeStyleTabBrowser.prototype = {
resetTabbarSize : function TSTBrowser_resetTabbarSize() resetTabbarSize : function TSTBrowser_resetTabbarSize()
{ {
if (this.isVertical) { if (this.isVertical) {
this.setTreePref('tabbar.shrunkenWidth', this.getTreePref('tabbar.shrunkenWidth.default')); TSTUtils.setTreePref('tabbar.shrunkenWidth', TSTUtils.getTreePref('tabbar.shrunkenWidth.default'));
this.setTreePref('tabbar.width', this.getTreePref('tabbar.width.default')); TSTUtils.setTreePref('tabbar.width', TSTUtils.getTreePref('tabbar.width.default'));
} }
else { else {
this.setTreePref('tabbar.height', this.getTreePref('tabbar.height.default')); TSTUtils.setTreePref('tabbar.height', TSTUtils.getTreePref('tabbar.height.default'));
let tabContainerBox = this.getTabContainerBox(this.mTabBrowser); let tabContainerBox = this.getTabContainerBox(this.mTabBrowser);
tabContainerBox.removeAttribute('height'); tabContainerBox.removeAttribute('height');
this._tabStripPlaceHolder.height = tabContainerBox.boxObject.height; this._tabStripPlaceHolder.height = tabContainerBox.boxObject.height;
@ -4858,7 +4864,7 @@ TreeStyleTabBrowser.prototype = {
this.collapseExpandSubtree(aParent, false, aInfo.dontAnimate); this.collapseExpandSubtree(aParent, false, aInfo.dontAnimate);
} }
else if (!aInfo.dontExpand) { else if (!aInfo.dontExpand) {
if (this.getTreePref('autoCollapseExpandSubtreeOnSelect')) { if (TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect')) {
if (this.shouldTabAutoExpanded(aParent)) if (this.shouldTabAutoExpanded(aParent))
this.collapseExpandTreesIntelligentlyFor(aParent); this.collapseExpandTreesIntelligentlyFor(aParent);
newAncestors.forEach(function(aAncestor) { newAncestors.forEach(function(aAncestor) {
@ -4867,7 +4873,7 @@ TreeStyleTabBrowser.prototype = {
}, this); }, this);
} }
else if (this.shouldTabAutoExpanded(aParent)) { else if (this.shouldTabAutoExpanded(aParent)) {
if (this.getTreePref('autoExpandSubtreeOnAppendChild')) { if (TSTUtils.getTreePref('autoExpandSubtreeOnAppendChild')) {
newAncestors.forEach(function(aAncestor) { newAncestors.forEach(function(aAncestor) {
if (this.shouldTabAutoExpanded(aAncestor)) if (this.shouldTabAutoExpanded(aAncestor))
this.collapseExpandSubtree(aAncestor, false, aInfo.dontAnimate); this.collapseExpandSubtree(aAncestor, false, aInfo.dontAnimate);
@ -4991,7 +4997,7 @@ TreeStyleTabBrowser.prototype = {
var insertBefore = null; var insertBefore = null;
if (aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN && if (aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN &&
!this.getTreePref('closeParentBehavior.moveDetachedTabsToBottom')) { !TSTUtils.getTreePref('closeParentBehavior.moveDetachedTabsToBottom')) {
insertBefore = this.getNextSiblingTab(this.getRootTab(aTab)); insertBefore = this.getNextSiblingTab(this.getRootTab(aTab));
} }
for (let i = 0, maxi = children.length; i < maxi; i++) for (let i = 0, maxi = children.length; i < maxi; i++)
@ -5061,8 +5067,8 @@ TreeStyleTabBrowser.prototype = {
getCloseParentBehaviorForTab : function TSTBrowser_getCloseParentBehaviorForTab(aTab, aDefaultBehavior) getCloseParentBehaviorForTab : function TSTBrowser_getCloseParentBehaviorForTab(aTab, aDefaultBehavior)
{ {
var closeParentBehavior = this.getTreePref('closeParentBehavior'); var closeParentBehavior = TSTUtils.getTreePref('closeParentBehavior');
var closeRootBehavior = this.getTreePref('closeRootBehavior'); var closeRootBehavior = TSTUtils.getTreePref('closeRootBehavior');
var parentTab = this.getParentTab(aTab); var parentTab = this.getParentTab(aTab);
var behavior = aDefaultBehavior ? var behavior = aDefaultBehavior ?
@ -5262,7 +5268,7 @@ TreeStyleTabBrowser.prototype = {
checkTabsIndentOverflowTimer : null, checkTabsIndentOverflowTimer : null,
checkTabsIndentOverflowCallback : function TSTBrowser_checkTabsIndentOverflowCallback() checkTabsIndentOverflowCallback : function TSTBrowser_checkTabsIndentOverflowCallback()
{ {
if (!this.getTreePref('indent.autoShrink')) { if (!TSTUtils.getTreePref('indent.autoShrink')) {
this.indent = -1; this.indent = -1;
return; return;
} }
@ -5299,7 +5305,7 @@ TreeStyleTabBrowser.prototype = {
} }
var maxIndent = maxIndentBase * (isVertical ? 0.33 : 0.5 ); var maxIndent = maxIndentBase * (isVertical ? 0.33 : 0.5 );
var indentMin = this.getTreePref(isVertical ? 'indent.min.vertical' : 'indent.min.horizontal'); var indentMin = TSTUtils.getTreePref(isVertical ? 'indent.min.vertical' : 'indent.min.horizontal');
var indentUnit = Math.max(Math.floor(maxIndent / nest), indentMin); var indentUnit = Math.max(Math.floor(maxIndent / nest), indentMin);
if (indent > maxIndent) { if (indent > maxIndent) {
this.indent = indentUnit; this.indent = indentUnit;
@ -5640,8 +5646,8 @@ TreeStyleTabBrowser.prototype = {
if (aCollapse) if (aCollapse)
this.deleteTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY); this.deleteTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY);
if (this.getTreePref('indent.autoShrink') && if (TSTUtils.getTreePref('indent.autoShrink') &&
this.getTreePref('indent.autoShrink.onlyForVisible')) TSTUtils.getTreePref('indent.autoShrink.onlyForVisible'))
this.checkTabsIndentOverflow(); this.checkTabsIndentOverflow();
this.doingCollapseExpand = false; this.doingCollapseExpand = false;
@ -5652,8 +5658,8 @@ TreeStyleTabBrowser.prototype = {
if (!aCollapse) if (!aCollapse)
this.setTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY, true); this.setTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY, true);
if (this.getTreePref('indent.autoShrink') && if (TSTUtils.getTreePref('indent.autoShrink') &&
this.getTreePref('indent.autoShrink.onlyForVisible')) { TSTUtils.getTreePref('indent.autoShrink.onlyForVisible')) {
this.cancelCheckTabsIndentOverflow(); this.cancelCheckTabsIndentOverflow();
if (!aTab.__treestyletab__checkTabsIndentOverflowOnMouseLeave) { if (!aTab.__treestyletab__checkTabsIndentOverflowOnMouseLeave) {
var self = this; var self = this;
@ -6198,7 +6204,7 @@ TreeStyleTabBrowser.prototype = {
if (this.useTMPSessionAPI && this.getPref('extensions.tabmix.sessions.manager')) if (this.useTMPSessionAPI && this.getPref('extensions.tabmix.sessions.manager'))
return; return;
var level = this.getTreePref('restoreTree.level'); var level = TSTUtils.getTreePref('restoreTree.level');
dump('TSTBrowser::restoreTree\n'); dump('TSTBrowser::restoreTree\n');
dump(' level = '+level+'\n'); dump(' level = '+level+'\n');
dump(' tabsToRestore = '+this.window.__SS_tabsToRestore+'\n'); dump(' tabsToRestore = '+this.window.__SS_tabsToRestore+'\n');

View File

@ -38,9 +38,17 @@ const EXPORTED_SYMBOLS = ['FullTooltipManager'];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import('resource://treestyletab-modules/base.js'); Components.utils.import('resource://treestyletab-modules/base.js');
Components.utils.import('resource://treestyletab-modules/pseudoTreeBuilder.js'); Components.utils.import('resource://treestyletab-modules/pseudoTreeBuilder.js');
XPCOMUtils.defineLazyGetter(this, 'TSTUtils', function() {
var ns = {};
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
return ns.TreeStyleTabUtils;
});
function FullTooltipManager(aOwner) function FullTooltipManager(aOwner)
{ {
this.init(aOwner); this.init(aOwner);
@ -277,7 +285,7 @@ FullTooltipManager.prototype = {
var label; var label;
var collapsed = this.isSubtreeCollapsed(tab); var collapsed = this.isSubtreeCollapsed(tab);
var mode = this.getTreePref('tooltip.mode'); var mode = TSTUtils.getTreePref('tooltip.mode');
var base = parseInt(tab.getAttribute(this.kNEST) || 0); var base = parseInt(tab.getAttribute(this.kNEST) || 0);
var descendant = this.getDescendantTabs(tab); var descendant = this.getDescendantTabs(tab);
@ -287,7 +295,7 @@ FullTooltipManager.prototype = {
if (mode > this.kTOOLTIP_MODE_DEFAULT && if (mode > this.kTOOLTIP_MODE_DEFAULT &&
descendant.length) { descendant.length) {
let tabs = [tab].concat(descendant); let tabs = [tab].concat(descendant);
let tabsToBeListed = tabs.slice(0, Math.max(1, this.getTreePref('tooltip.maxCount'))); let tabsToBeListed = tabs.slice(0, Math.max(1, TSTUtils.getTreePref('tooltip.maxCount')));
tree = tabsToBeListed tree = tabsToBeListed
.map(function(aTab) { .map(function(aTab) {
let label = aTab.getAttribute('label'); let label = aTab.getAttribute('label');
@ -308,7 +316,7 @@ FullTooltipManager.prototype = {
var shouldShowTree = mode != this.kTOOLTIP_MODE_DEFAULT && (collapsed || mode == this.kTOOLTIP_MODE_ALWAYS); var shouldShowTree = mode != this.kTOOLTIP_MODE_DEFAULT && (collapsed || mode == this.kTOOLTIP_MODE_ALWAYS);
if ('mOverCloseButton' in tab && tab.mOverCloseButton) { if ('mOverCloseButton' in tab && tab.mOverCloseButton) {
if (descendant.length && if (descendant.length &&
(collapsed || this.getTreePref('closeParentBehavior') == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN)) { (collapsed || TSTUtils.getTreePref('closeParentBehavior') == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN)) {
label = tree || tab.getAttribute('label'); label = tree || tab.getAttribute('label');
label = label && shouldShowTree ? label = label && shouldShowTree ?
this.treeBundle.getFormattedString('tooltip.closeTree.labeled', [label]) : this.treeBundle.getFormattedString('tooltip.closeTree.labeled', [label]) :
@ -345,7 +353,7 @@ FullTooltipManager.prototype = {
{ {
this.cancel(); this.cancel();
var delay = this.getTreePref('tooltip.fullTooltipDelay'); var delay = TSTUtils.getTreePref('tooltip.fullTooltipDelay');
if (delay < 0) if (delay < 0)
return; return;

View File

@ -40,8 +40,15 @@ const DEBUG = false;
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import('resource://gre/modules/Services.jsm'); Components.utils.import('resource://gre/modules/Services.jsm');
XPCOMUtils.defineLazyGetter(this, 'TSTUtils', function() {
var ns = {};
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
return ns.TreeStyleTabUtils;
});
const TAB_DROP_TYPE = 'application/x-moz-tabbrowser-tab'; const TAB_DROP_TYPE = 'application/x-moz-tabbrowser-tab';
const SSS = Cc['@mozilla.org/content/style-sheet-service;1'] const SSS = Cc['@mozilla.org/content/style-sheet-service;1']
@ -95,7 +102,7 @@ TabbarDNDObserver.prototype = {
); );
if (canDrag && !aEvent.shiftKey) { if (canDrag && !aEvent.shiftKey) {
let insensitiveArea = sv.getTreePref('tabbar.fixed.insensitiveArea'); let insensitiveArea = TSTUtils.getTreePref('tabbar.fixed.insensitiveArea');
let box = tabbar.boxObject; let box = tabbar.boxObject;
switch (sv.position) switch (sv.position)
{ {
@ -358,7 +365,7 @@ catch(e) {
var visible = sv.getNextVisibleTab(tab); var visible = sv.getNextVisibleTab(tab);
info.action = sv.kACTION_STAY | sv.kACTION_ATTACH; info.action = sv.kACTION_STAY | sv.kACTION_ATTACH;
info.parent = tab; info.parent = tab;
info.insertBefore = sv.getTreePref('insertNewChildAt') == sv.kINSERT_FISRT ? info.insertBefore = TSTUtils.getTreePref('insertNewChildAt') == sv.kINSERT_FISRT ?
(sv.getFirstChildTab(tab) || visible) : (sv.getFirstChildTab(tab) || visible) :
(sv.getNextSiblingTab(tab) || sv.getNextTab(sv.getLastDescendantTab(tab) || tab)); (sv.getNextSiblingTab(tab) || sv.getNextTab(sv.getLastDescendantTab(tab) || tab));
if (DEBUG && info.insertBefore) dump(' insertBefore = '+info.insertBefore._tPos+'\n'); if (DEBUG && info.insertBefore) dump(' insertBefore = '+info.insertBefore._tPos+'\n');
@ -726,7 +733,7 @@ catch(e) {
var tab = aEvent.target; var tab = aEvent.target;
if (tab.localName != 'tab' || if (tab.localName != 'tab' ||
!sv.getTreePref('autoExpand.enabled')) !TSTUtils.getTreePref('autoExpand.enabled'))
return; return;
w.clearTimeout(this.mAutoExpandTimer); w.clearTimeout(this.mAutoExpandTimer);
@ -746,7 +753,7 @@ catch(e) {
sv.shouldTabAutoExpanded(tab) && sv.shouldTabAutoExpanded(tab) &&
tab.getAttribute(sv.kDROP_POSITION) == 'self') { tab.getAttribute(sv.kDROP_POSITION) == 'self') {
let draggedTab = aDragged && sv.getTabById(aDragged); let draggedTab = aDragged && sv.getTabById(aDragged);
if (sv.getTreePref('autoExpand.intelligently')) { if (TSTUtils.getTreePref('autoExpand.intelligently')) {
sv.collapseExpandTreesIntelligentlyFor(tab); sv.collapseExpandTreesIntelligentlyFor(tab);
if (draggedTab) if (draggedTab)
aSelf.updateDragData(draggedTab); aSelf.updateDragData(draggedTab);
@ -760,7 +767,7 @@ catch(e) {
} }
} }
}, },
sv.getTreePref('autoExpand.delay') TSTUtils.getTreePref('autoExpand.delay')
); );
}, 0, this, tab.getAttribute(sv.kID), draggedTab && draggedTab.getAttribute(sv.kID)); }, 0, this, tab.getAttribute(sv.kID), draggedTab && draggedTab.getAttribute(sv.kID));
@ -978,7 +985,7 @@ catch(e) {
{ {
var sv = this.treeStyleTab; var sv = this.treeStyleTab;
if (this.mAutoExpandedTabs.length) { if (this.mAutoExpandedTabs.length) {
if (sv.getTreePref('autoExpand.collapseFinally')) { if (TSTUtils.getTreePref('autoExpand.collapseFinally')) {
for (let i = 0, maxi = this.mAutoExpandedTabs.length; i < maxi; i++) for (let i = 0, maxi = this.mAutoExpandedTabs.length; i < maxi; i++)
{ {
sv.collapseExpandSubtree(sv.getTabById(this.mAutoExpandedTabs[i]), true, true); sv.collapseExpandSubtree(sv.getTabById(this.mAutoExpandedTabs[i]), true, true);

View File

@ -38,6 +38,15 @@ const EXPORTED_SYMBOLS = ['TabpanelDNDObserver'];
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyGetter(this, 'TSTUtils', function() {
var ns = {};
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
return ns.TreeStyleTabUtils;
});
function TabpanelDNDObserver(aTabBrowser) function TabpanelDNDObserver(aTabBrowser)
{ {
this.init(aTabBrowser); this.init(aTabBrowser);
@ -118,10 +127,10 @@ TabpanelDNDObserver.prototype = {
var position = this.getDropPosition(aEvent); var position = this.getDropPosition(aEvent);
if (position != 'center' && if (position != 'center' &&
position != sv.position) { position != sv.position) {
if (sv.getTreePref('tabbar.fixed.autoCancelOnDrop') && if (TSTUtils.getTreePref('tabbar.fixed.autoCancelOnDrop') &&
dt.getData(sv.kDRAG_TYPE_TABBAR) != sv.kTABBAR_MOVE_FORCE) { dt.getData(sv.kDRAG_TYPE_TABBAR) != sv.kTABBAR_MOVE_FORCE) {
let orient = (position == 'left' || position == 'right') ? 'vertical' : 'horizontal' ; let orient = (position == 'left' || position == 'right') ? 'vertical' : 'horizontal' ;
sv.setTreePref('tabbar.fixed.'+orient, false); TSTUtils.setTreePref('tabbar.fixed.'+orient, false);
} }
sv.setPrefForActiveWindow(function() { sv.setPrefForActiveWindow(function() {
sv.utils.position = position; sv.utils.position = position;

81
modules/utils.js Normal file
View File

@ -0,0 +1,81 @@
/* ***** 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.
*
* The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
* Portions created by the Initial Developer are Copyright (C) 2010-2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com>
*
* 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 ******/
"use strict";
let EXPORTED_SYMBOLS = ['TreeStyleTabUtils'];
const Cc = Components.classes;
const Ci = Components.interfaces;
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyGetter(this, 'window', function() {
Components.utils.import('resource://treestyletab-modules/lib/namespace.jsm');
return getNamespaceFor('piro.sakura.ne.jp');
});
XPCOMUtils.defineLazyGetter(this, 'prefs', function() {
Components.utils.import('resource://treestyletab-modules/lib/prefs.js');
return window['piro.sakura.ne.jp'].prefs;
});
const TST_PREF_PREFIX = 'extensions.treestyletab.';
let TreeStyleTabUtils = {
get prefs () {
delete this.prefs;
return this.prefs = prefs;
},
/* Save/Load Prefs */
getTreePref : function TSTUtils_getTreePref(aPrefstring)
{
return prefs.getPref(TST_PREF_PREFIX + aPrefstring);
},
setTreePref : function TSTUtils_setTreePref(aPrefstring, aNewValue)
{
return prefs.setPref(TST_PREF_PREFIX + aPrefstring, aNewValue);
},
clearTreePref : function TSTUtils_clearTreePref(aPrefstring)
{
return prefs.clearPref(TST_PREF_PREFIX + aPrefstring);
},
};

View File

@ -48,6 +48,12 @@ XPCOMUtils.defineLazyGetter(this, 'TreeStyleTabBrowser', function() {
Components.utils.import('resource://treestyletab-modules/browser.js', ns); Components.utils.import('resource://treestyletab-modules/browser.js', ns);
return ns.TreeStyleTabBrowser; return ns.TreeStyleTabBrowser;
}); });
XPCOMUtils.defineLazyGetter(this, 'TSTUtils', function() {
var ns = {};
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
return ns.TreeStyleTabUtils;
});
function TreeStyleTabWindow(aWindow) function TreeStyleTabWindow(aWindow)
{ {
@ -255,7 +261,7 @@ TreeStyleTabWindow.prototype = {
{ {
aTerm = aTerm.replace(/^\s+|\s+$/g, ''); aTerm = aTerm.replace(/^\s+|\s+$/g, '');
var mode = this.getTreePref('autoAttach.searchResult'); var mode = TSTUtils.getTreePref('autoAttach.searchResult');
if (mode == this.kSEARCH_RESULT_ATTACH_ALWAYS) { if (mode == this.kSEARCH_RESULT_ATTACH_ALWAYS) {
return true; return true;
} }
@ -285,9 +291,9 @@ TreeStyleTabWindow.prototype = {
return this.window.fullScreen ? return this.window.fullScreen ?
( (
this.getPref('browser.fullscreen.autohide') && this.getPref('browser.fullscreen.autohide') &&
this.getTreePref('tabbar.autoHide.mode.fullscreen') TSTUtils.getTreePref('tabbar.autoHide.mode.fullscreen')
) : ) :
this.getTreePref('tabbar.autoHide.mode'); TSTUtils.getTreePref('tabbar.autoHide.mode');
}, },
get autoHideWindow() get autoHideWindow()
@ -454,7 +460,7 @@ TreeStyleTabWindow.prototype = {
aTabBrowser = aTabBrowser || this.browser; aTabBrowser = aTabBrowser || this.browser;
var allTabsButton = d.getElementById('alltabs-button') || var allTabsButton = d.getElementById('alltabs-button') ||
( // Tab Mix Plus ( // Tab Mix Plus
this.getTreePref('compatibility.TMP') && TSTUtils.getTreePref('compatibility.TMP') &&
d.getAnonymousElementByAttribute(aTabBrowser.mTabContainer, 'anonid', 'alltabs-button') d.getAnonymousElementByAttribute(aTabBrowser.mTabContainer, 'anonid', 'alltabs-button')
); );
@ -464,7 +470,7 @@ TreeStyleTabWindow.prototype = {
updateAllTabsPopup : function TSTWindow_updateAllTabsPopup(aEvent) updateAllTabsPopup : function TSTWindow_updateAllTabsPopup(aEvent)
{ {
if (!this.getTreePref('enableSubtreeIndent.allTabsPopup')) return; if (!TSTUtils.getTreePref('enableSubtreeIndent.allTabsPopup')) return;
var items = Array.slice(aEvent.originalTarget.childNodes); var items = Array.slice(aEvent.originalTarget.childNodes);
var firstItemIndex = 0; var firstItemIndex = 0;
@ -826,8 +832,8 @@ TreeStyleTabWindow.prototype = {
{ {
return !this.ctrlTabPreviewsEnabled && return !this.ctrlTabPreviewsEnabled &&
( (
this.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut') || TSTUtils.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut') ||
this.getTreePref('autoCollapseExpandSubtreeOnSelect') TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect')
); );
}, },
@ -900,15 +906,15 @@ TreeStyleTabWindow.prototype = {
width = this.maxTabbarWidth(width, b); width = this.maxTabbarWidth(width, b);
if (expanded || b.treeStyleTab.autoHide.expanded) { if (expanded || b.treeStyleTab.autoHide.expanded) {
this.setPrefForActiveWindow(function() { this.setPrefForActiveWindow(function() {
this.setTreePref('tabbar.width', width); TSTUtils.setTreePref('tabbar.width', width);
}); });
if (b.treeStyleTab.autoHide.mode == b.treeStyleTab.autoHide.kMODE_SHRINK && if (b.treeStyleTab.autoHide.mode == b.treeStyleTab.autoHide.kMODE_SHRINK &&
b.treeStyleTab.tabStripPlaceHolder) b.treeStyleTab.tabStripPlaceHolder)
b.treeStyleTab.tabStripPlaceHolder.setAttribute('width', this.getTreePref('tabbar.shrunkenWidth')); b.treeStyleTab.tabStripPlaceHolder.setAttribute('width', TSTUtils.getTreePref('tabbar.shrunkenWidth'));
} }
else { else {
this.setPrefForActiveWindow(function() { this.setPrefForActiveWindow(function() {
this.setTreePref('tabbar.shrunkenWidth', width); TSTUtils.setTreePref('tabbar.shrunkenWidth', width);
}); });
} }
} }
@ -916,7 +922,7 @@ TreeStyleTabWindow.prototype = {
let delta = aEvent.screenY - this.tabbarResizeStartY; let delta = aEvent.screenY - this.tabbarResizeStartY;
height += (pos == 'top' ? delta : -delta ); height += (pos == 'top' ? delta : -delta );
this.setPrefForActiveWindow(function() { this.setPrefForActiveWindow(function() {
this.setTreePref('tabbar.height', this.maxTabbarHeight(height, b)); TSTUtils.setTreePref('tabbar.height', this.maxTabbarHeight(height, b));
}); });
} }
b.treeStyleTab.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_TABBAR_RESIZE); b.treeStyleTab.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_TABBAR_RESIZE);
@ -980,7 +986,7 @@ TreeStyleTabWindow.prototype = {
if ( if (
this.updateAeroPeekPreviewsTimer || this.updateAeroPeekPreviewsTimer ||
!this.getPref('browser.taskbar.previews.enable') || !this.getPref('browser.taskbar.previews.enable') ||
!this.getTreePref('taskbarPreviews.hideCollapsedTabs') || !TSTUtils.getTreePref('taskbarPreviews.hideCollapsedTabs') ||
!('Win7Features' in w) || !('Win7Features' in w) ||
!w.Win7Features || !w.Win7Features ||
!this.AeroPeek || !this.AeroPeek ||
@ -1004,7 +1010,7 @@ TreeStyleTabWindow.prototype = {
{ {
if ( if (
!this.getPref('browser.taskbar.previews.enable') || !this.getPref('browser.taskbar.previews.enable') ||
!this.getTreePref('taskbarPreviews.hideCollapsedTabs') !TSTUtils.getTreePref('taskbarPreviews.hideCollapsedTabs')
) )
return; return;
@ -1041,12 +1047,12 @@ TreeStyleTabWindow.prototype = {
try { try {
var TabsOnTop = w.TabsOnTop; var TabsOnTop = w.TabsOnTop;
var originalState = this.getTreePref('tabsOnTop.originalState'); var originalState = TSTUtils.getTreePref('tabsOnTop.originalState');
if (originalState === null) { if (originalState === null) {
let current = this.getDefaultPref('browser.tabs.onTop') === null ? let current = this.getDefaultPref('browser.tabs.onTop') === null ?
TabsOnTop.enabled : TabsOnTop.enabled :
this.getPref('browser.tabs.onTop') ; this.getPref('browser.tabs.onTop') ;
this.setTreePref('tabsOnTop.originalState', originalState = current); TSTUtils.setTreePref('tabsOnTop.originalState', originalState = current);
} }
if (this.browser.treeStyleTab.position != 'top' || if (this.browser.treeStyleTab.position != 'top' ||
@ -1057,7 +1063,7 @@ TreeStyleTabWindow.prototype = {
else { else {
if (TabsOnTop.enabled != originalState) if (TabsOnTop.enabled != originalState)
TabsOnTop.enabled = originalState; TabsOnTop.enabled = originalState;
this.clearTreePref('tabsOnTop.originalState'); TSTUtils.clearTreePref('tabsOnTop.originalState');
} }
} }
finally { finally {
@ -1142,7 +1148,7 @@ TreeStyleTabWindow.prototype = {
return; return;
var b = aTabBrowser || this.browser; var b = aTabBrowser || this.browser;
this._handleNewTabCommand(b.selectedTab, this.getTreePref('autoAttach.newTabCommand')); this._handleNewTabCommand(b.selectedTab, TSTUtils.getTreePref('autoAttach.newTabCommand'));
}, },
handleNewTabActionOnButton : function TSTWindow_handleNewTabActionOnButton(aEvent) handleNewTabActionOnButton : function TSTWindow_handleNewTabActionOnButton(aEvent)
@ -1153,7 +1159,7 @@ TreeStyleTabWindow.prototype = {
var newTabButton = this.getNewTabButtonFromEvent(aEvent); var newTabButton = this.getNewTabButtonFromEvent(aEvent);
if (newTabButton) { if (newTabButton) {
this._handleNewTabCommand(this.browser.selectedTab, this.getTreePref('autoAttach.newTabButton')); this._handleNewTabCommand(this.browser.selectedTab, TSTUtils.getTreePref('autoAttach.newTabButton'));
let self = this.windowService || this; let self = this.windowService || this;
self._clickEventOnNewTabButtonHandled = true; self._clickEventOnNewTabButtonHandled = true;
this.Deferred.next(function() { this.Deferred.next(function() {
@ -1161,7 +1167,7 @@ TreeStyleTabWindow.prototype = {
}); });
} }
else if (aEvent.target.id == 'urlbar-go-button' || aEvent.target.id == 'go-button') { else if (aEvent.target.id == 'urlbar-go-button' || aEvent.target.id == 'go-button') {
this._handleNewTabCommand(this.browser.selectedTab, this.getTreePref('autoAttach.goButton')); this._handleNewTabCommand(this.browser.selectedTab, TSTUtils.getTreePref('autoAttach.goButton'));
} }
}, },
_clickEventOnNewTabButtonHandled : false, _clickEventOnNewTabButtonHandled : false,
@ -1175,7 +1181,7 @@ TreeStyleTabWindow.prototype = {
var behaviorPref = !aDelta ? 'autoAttach.duplicateTabCommand' : var behaviorPref = !aDelta ? 'autoAttach.duplicateTabCommand' :
aDelta < 0 ? 'autoAttach.duplicateTabCommand.back' : aDelta < 0 ? 'autoAttach.duplicateTabCommand.back' :
'autoAttach.duplicateTabCommand.forward' 'autoAttach.duplicateTabCommand.forward'
var behavior = this.getTreePref(behaviorPref); var behavior = TSTUtils.getTreePref(behaviorPref);
this._handleNewTabCommand(aTab || b.selectedTab, behavior); this._handleNewTabCommand(aTab || b.selectedTab, behavior);
}, },
@ -1300,7 +1306,7 @@ TreeStyleTabWindow.prototype = {
this.setTabbrowserAttribute(this.kFIXED+'-'+orient, newFixed || null, b); this.setTabbrowserAttribute(this.kFIXED+'-'+orient, newFixed || null, b);
this.setPrefForActiveWindow(function() { this.setPrefForActiveWindow(function() {
b.treeStyleTab.fixed = newFixed; b.treeStyleTab.fixed = newFixed;
this.setTreePref('tabbar.fixed.'+orient, newFixed); TSTUtils.setTreePref('tabbar.fixed.'+orient, newFixed);
}); });
b.treeStyleTab.updateTabbarState(); b.treeStyleTab.updateTabbarState();
@ -1429,7 +1435,7 @@ TreeStyleTabWindow.prototype = {
aTabs.indexOf(next) > -1 aTabs.indexOf(next) > -1
); );
var root = this.getTreePref('createSubtree.underParent') ? var root = TSTUtils.getTreePref('createSubtree.underParent') ?
b.addTab(this.getGroupTabURI()) : b.addTab(this.getGroupTabURI()) :
aTabs.shift() ; aTabs.shift() ;
var self = this; var self = this;
@ -1538,7 +1544,7 @@ TreeStyleTabWindow.prototype = {
expandTreeAfterKeyReleased : function TSTWindow_expandTreeAfterKeyReleased(aTab) expandTreeAfterKeyReleased : function TSTWindow_expandTreeAfterKeyReleased(aTab)
{ {
if (this.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut')) return; if (TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut')) return;
this._tabShouldBeExpandedAfterKeyReleased = aTab || null; this._tabShouldBeExpandedAfterKeyReleased = aTab || null;
}, },
_tabShouldBeExpandedAfterKeyReleased : null, _tabShouldBeExpandedAfterKeyReleased : null,
@ -1689,7 +1695,7 @@ TreeStyleTabWindow.prototype = {
{ {
case 'extensions.treestyletab.tabbar.autoHide.mode': case 'extensions.treestyletab.tabbar.autoHide.mode':
// don't set on this time, because appearance of all tabbrowsers are not updated yet. // don't set on this time, because appearance of all tabbrowsers are not updated yet.
// this.autoHide.mode = this.getTreePref('tabbar.autoHide.mode'); // this.autoHide.mode = TSTUtils.getTreePref('tabbar.autoHide.mode');
case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown': case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown':
case 'extensions.treestyletab.tabbar.autoShow.tabSwitch': case 'extensions.treestyletab.tabbar.autoShow.tabSwitch':
case 'extensions.treestyletab.tabbar.autoShow.feedback': case 'extensions.treestyletab.tabbar.autoShow.feedback':

View File

@ -1,8 +1,6 @@
var namespace = { window : { addEventListener : function() {} } }; utils.import('../../modules/utils.js');
utils.include('../../content/treestyletab/res/prefs.js', namespace, 'Shift_JIS'); assert.isDefined(TreeStyleTabUtils);
utils.include('../../content/treestyletab/treestyletab.js', namespace, 'Shift_JIS');
var sv;
var random = parseInt(Math.random() * 65000); var random = parseInt(Math.random() * 65000);
var root = 'extensions.treestyletab.'; var root = 'extensions.treestyletab.';
@ -21,8 +19,6 @@ function clearTestPrefs()
function setUp() function setUp()
{ {
sv = {};
sv.__proto__ = namespace.TreeStyleTabService;
clearTestPrefs(); clearTestPrefs();
} }
@ -33,42 +29,20 @@ function tearDown()
function test_setAndGetPref() function test_setAndGetPref()
{ {
function assertSetAndGetPref(aPref, aValue)
{
assert.isNull(utils.getPref(aPref));
assert.isNull(sv.getPref(aPref));
sv.setPref(aPref, aValue);
assert.isNotNull(utils.getPref(aPref));
assert.equals(aValue, utils.getPref(aPref));
assert.isNotNull(sv.getPref(aPref));
assert.equals(aValue, sv.getPref(aPref));
sv.clearPref(aPref);
assert.isNull(utils.getPref(aPref));
assert.isNull(sv.getPref(aPref));
}
function assertSetAndGetTreePref(aPref, aValue) function assertSetAndGetTreePref(aPref, aValue)
{ {
assert.isNull(utils.getPref(root+aPref)); assert.isNull(utils.getPref(root+aPref));
assert.isNull(sv.getTreePref(aPref)); assert.isNull(TreeStyleTabUtils.getTreePref(aPref));
sv.setTreePref(aPref, aValue); TreeStyleTabUtils.setTreePref(aPref, aValue);
assert.isNotNull(utils.getPref(root+aPref)); assert.isNotNull(utils.getPref(root+aPref));
assert.equals(aValue, utils.getPref(root+aPref)); assert.equals(aValue, utils.getPref(root+aPref));
assert.isNotNull(sv.getTreePref(aPref)); assert.isNotNull(TreeStyleTabUtils.getTreePref(aPref));
assert.equals(aValue, sv.getTreePref(aPref)); assert.equals(aValue, TreeStyleTabUtils.getTreePref(aPref));
} }
assertSetAndGetPref(random+'.bool', true);
assertSetAndGetPref(random+'.int', 29);
assertSetAndGetPref(random+'.string', 'string');
assertSetAndGetTreePref(random+'.bool', true); assertSetAndGetTreePref(random+'.bool', true);
assertSetAndGetTreePref(random+'.int', 29); assertSetAndGetTreePref(random+'.int', 29);
assertSetAndGetTreePref(random+'.string', 'string'); assertSetAndGetTreePref(random+'.string', 'string');
@ -97,7 +71,7 @@ function test_listeners()
messages : [] messages : []
}; };
sv.addPrefListener(singleDomainListener); TreeStyleTabUtils.prefs.addPrefListener(singleDomainListener);
utils.setPref(root+random+'.domain1.pref', true); utils.setPref(root+random+'.domain1.pref', true);
utils.setPref(root+random+'.domain1.pref', false); utils.setPref(root+random+'.domain1.pref', false);
assert.equals( assert.equals(
@ -108,12 +82,12 @@ function test_listeners()
singleDomainListener.messages singleDomainListener.messages
); );
singleDomainListener.messages = []; singleDomainListener.messages = [];
sv.removePrefListener(singleDomainListener); TreeStyleTabUtils.prefs.removePrefListener(singleDomainListener);
utils.setPref(root+random+'.domain1.pref', true); utils.setPref(root+random+'.domain1.pref', true);
utils.setPref(root+random+'.domain1.pref', false); utils.setPref(root+random+'.domain1.pref', false);
assert.equals([], singleDomainListener.messages); assert.equals([], singleDomainListener.messages);
sv.addPrefListener(multipleDomainsListener); TreeStyleTabUtils.prefs.addPrefListener(multipleDomainsListener);
utils.setPref(root+random+'.domain2.pref', true); utils.setPref(root+random+'.domain2.pref', true);
utils.setPref(root+random+'.domain3.pref', true); utils.setPref(root+random+'.domain3.pref', true);
utils.setPref(root+random+'.domain2.pref', false); utils.setPref(root+random+'.domain2.pref', false);
@ -128,7 +102,7 @@ function test_listeners()
multipleDomainsListener.messages multipleDomainsListener.messages
); );
multipleDomainsListener.messages = []; multipleDomainsListener.messages = [];
sv.removePrefListener(multipleDomainsListener); TreeStyleTabUtils.prefs.removePrefListener(multipleDomainsListener);
utils.setPref(root+random+'.domain2.pref', true); utils.setPref(root+random+'.domain2.pref', true);
utils.setPref(root+random+'.domain3.pref', true); utils.setPref(root+random+'.domain3.pref', true);
utils.setPref(root+random+'.domain2.pref', false); utils.setPref(root+random+'.domain2.pref', false);