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

View File

@ -38,6 +38,15 @@ const EXPORTED_SYMBOLS = ['AutoHideBrowser', 'AutoHideWindow'];
const Cc = Components.classes;
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)
{
this.init(aTabBrowser);
@ -82,12 +91,12 @@ AutoHideBrowser.prototype = {
getModeForNormal : function AHB_getModeForNormal(aTabBrowser)
{
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)
{
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()
@ -156,8 +165,8 @@ AutoHideBrowser.prototype = {
default:
case this.kMODE_SHRINK:
return sv.getTreePref('tabbar.width')
- sv.getTreePref('tabbar.shrunkenWidth');
return TSTUtils.getTreePref('tabbar.width')
- TSTUtils.getTreePref('tabbar.shrunkenWidth');
}
},
get YOffset()
@ -281,7 +290,7 @@ AutoHideBrowser.prototype = {
{
this.mode = this.getModeForFullScreen();
this.end();
this.mode = this.treeStyleTab.getTreePref('tabbar.autoHide.mode');
this.mode = TSTUtils.getTreePref('tabbar.autoHide.mode');
this.treeStyleTab.checkTabsIndentOverflow();
if (this.mode != this.kMODE_DISABLED)
this.start();
@ -313,13 +322,13 @@ AutoHideBrowser.prototype = {
get shouldListenMouseMove()
{
return this.treeStyleTab.getTreePref('tabbar.autoShow.mousemove');
return TSTUtils.getTreePref('tabbar.autoShow.mousemove');
},
get shouldListenKeyEventsForAutoHide()
{
return this.treeStyleTab.getTreePref('tabbar.autoShow.accelKeyDown') ||
this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch');
return TSTUtils.getTreePref('tabbar.autoShow.accelKeyDown') ||
TSTUtils.getTreePref('tabbar.autoShow.tabSwitch');
},
showHideOnMouseMove : function AHB_showHideOnMouseMove(aEvent)
@ -340,7 +349,7 @@ AutoHideBrowser.prototype = {
if (
shouldShow &&
this.showHideReason & this.kKEEP_SHOWN_ON_MOUSEOVER &&
sv.getTreePref('tabbar.autoShow.keepShownOnMouseover')
TSTUtils.getTreePref('tabbar.autoShow.keepShownOnMouseover')
) {
this.showHideReason = this.kSHOWN_BY_MOUSEMOVE;
this.cancelDelayedShowForShortcut();
@ -348,7 +357,7 @@ AutoHideBrowser.prototype = {
}
else if (
!shouldShow &&
sv.getTreePref('tabbar.autoShow.mousemove')
TSTUtils.getTreePref('tabbar.autoShow.mousemove')
) {
this.showHideOnMouseMoveTimer = w.setTimeout(
function(aSelf) {
@ -356,7 +365,7 @@ AutoHideBrowser.prototype = {
if (aSelf.showHideReason == aSelf.kSHOWN_BY_MOUSEMOVE)
aSelf.hide(aSelf.kSHOWN_BY_MOUSEMOVE);
},
sv.getTreePref('tabbar.autoHide.delay'),
TSTUtils.getTreePref('tabbar.autoHide.delay'),
this
);
}
@ -368,7 +377,7 @@ AutoHideBrowser.prototype = {
aSelf.cancelHideForFeedback();
aSelf.show(aSelf.kSHOWN_BY_MOUSEMOVE);
},
sv.getTreePref('tabbar.autoHide.delay'),
TSTUtils.getTreePref('tabbar.autoHide.delay'),
this
);
}
@ -516,7 +525,7 @@ AutoHideBrowser.prototype = {
showForFeedback : function AHB_showForFeedback()
{
if (!this.enabled ||
!this.treeStyleTab.getTreePref('tabbar.autoShow.feedback'))
!TSTUtils.getTreePref('tabbar.autoShow.feedback'))
return;
var w = this.window;
@ -545,7 +554,7 @@ AutoHideBrowser.prototype = {
if (aSelf.showHideReason == aSelf.kSHOWN_BY_FEEDBACK)
aSelf.hide();
},
this.treeStyleTab.getTreePref('tabbar.autoShow.feedback.delay'),
TSTUtils.getTreePref('tabbar.autoShow.feedback.delay'),
this
);
},
@ -563,9 +572,9 @@ AutoHideBrowser.prototype = {
if (aForceExpanded ||
this.expanded ||
this.mode != this.kMODE_SHRINK)
this.treeStyleTab.setTreePref('tabbar.width', this.treeStyleTab.maxTabbarWidth(aWidth));
TSTUtils.setTreePref('tabbar.width', this.treeStyleTab.maxTabbarWidth(aWidth));
else
this.treeStyleTab.setTreePref('tabbar.shrunkenWidth', this.treeStyleTab.maxTabbarWidth(aWidth));
TSTUtils.setTreePref('tabbar.shrunkenWidth', this.treeStyleTab.maxTabbarWidth(aWidth));
},
updateMenuItem : function AHB_updateMenuItem(aNode)
@ -597,14 +606,14 @@ AutoHideBrowser.prototype = {
get widthFromMode()
{
return (this.shrunken) ?
this.treeStyleTab.getTreePref('tabbar.shrunkenWidth') :
this.treeStyleTab.getTreePref('tabbar.width') ;
TSTUtils.getTreePref('tabbar.shrunkenWidth') :
TSTUtils.getTreePref('tabbar.width') ;
},
get placeHolderWidthFromMode()
{
return (this.mode == this.kMODE_SHRINK) ?
this.treeStyleTab.getTreePref('tabbar.shrunkenWidth') :
this.treeStyleTab.getTreePref('tabbar.width') ;
TSTUtils.getTreePref('tabbar.shrunkenWidth') :
TSTUtils.getTreePref('tabbar.width') ;
},
get height()
@ -728,7 +737,7 @@ AutoHideBrowser.prototype = {
default:
case this.kMODE_SHRINK:
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);
}
break;
@ -766,7 +775,7 @@ AutoHideBrowser.prototype = {
sv.setTabbrowserAttribute(this.kAUTOHIDE, 'show');
sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_SHRUNKEN);
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);
break;
}
@ -947,7 +956,7 @@ AutoHideBrowser.prototype = {
case this.treeStyleTab.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START:
this.cancelDelayedShowForShortcut();
if (this.enabled &&
this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch') &&
TSTUtils.getTreePref('tabbar.autoShow.tabSwitch') &&
(
aEvent.getData('scrollDown') ||
aEvent.getData('scrollUp') ||
@ -1099,7 +1108,7 @@ AutoHideBrowser.prototype = {
w.TreeStyleTabService.accelKeyPressed
) {
if (this.enabled &&
sv.getTreePref('tabbar.autoShow.accelKeyDown') &&
TSTUtils.getTreePref('tabbar.autoShow.accelKeyDown') &&
!this.expanded &&
!this.delayedAutoShowTimer &&
!this.delayedShowForShortcutTimer) {
@ -1110,7 +1119,7 @@ AutoHideBrowser.prototype = {
sv = null;
b = null;
},
sv.getTreePref('tabbar.autoShow.accelKeyDown.delay'),
TSTUtils.getTreePref('tabbar.autoShow.accelKeyDown.delay'),
this
);
this.delayedShowForShortcutDone = false;
@ -1153,8 +1162,8 @@ AutoHideBrowser.prototype = {
this.showHideOnMouseMoveTimer = null;
this.delayedShowForFeedbackTimer = null;
b.setAttribute(this.kMODE+'-normal', sv.getTreePref('tabbar.autoHide.mode'));
b.setAttribute(this.kMODE+'-fullscreen', sv.getTreePref('tabbar.autoHide.mode.fullscreen'));
b.setAttribute(this.kMODE+'-normal', TSTUtils.getTreePref('tabbar.autoHide.mode'));
b.setAttribute(this.kMODE+'-fullscreen', TSTUtils.getTreePref('tabbar.autoHide.mode.fullscreen'));
sv.addPrefListener(this);
this.onPrefChange('browser.tabs.closeButtons');
this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area');
@ -1207,8 +1216,8 @@ AutoHideBrowser.prototype = {
};
for (var i in prefs)
{
if (this.treeStyleTab.getTreePref(i) != prefs[i])
this.treeStyleTab.setTreePref(i, prefs[i]);
if (TSTUtils.getTreePref(i) != prefs[i])
TSTUtils.setTreePref(i, prefs[i]);
}
}
@ -1263,10 +1272,10 @@ AutoHideWindow.prototype = {
}
var mode = this.getMode(b) == AutoHideBrowser.prototype.kMODE_DISABLED ?
this.treeStyleTab.getTreePref(toggleKey) :
TSTUtils.getTreePref(toggleKey) :
AutoHideBrowser.prototype.kMODE_DISABLED ;
this.treeStyleTab.setTreePref(key, mode);
TSTUtils.setTreePref(key, mode);
b.setAttribute(AutoHideBrowser.prototype.kMODE+'-'+(w.fullScreen ? 'fullscreen' : 'normal' ), mode);
b.treeStyleTab.autoHide.updateMode();
},
@ -1310,9 +1319,9 @@ AutoHideWindow.prototype = {
{
return !this.treeStyleTab.ctrlTabPreviewsEnabled &&
(
this.treeStyleTab.getTreePref('tabbar.autoShow.accelKeyDown') ||
this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch') ||
this.treeStyleTab.getTreePref('tabbar.autoShow.feedback')
TSTUtils.getTreePref('tabbar.autoShow.accelKeyDown') ||
TSTUtils.getTreePref('tabbar.autoShow.tabSwitch') ||
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);
return ns.confirmWithPopup;
});
XPCOMUtils.defineLazyGetter(this, 'TSTUtils', function() {
var ns = {};
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
return ns.TreeStyleTabUtils;
});
var TreeStyleTabBase = {
__proto__ : window['piro.sakura.ne.jp'].prefs,
@ -373,7 +379,7 @@ var TreeStyleTabBase = {
{
// migrate old prefs
var orientalPrefs = [];
switch (this.getTreePref('prefsVersion'))
switch (TSTUtils.getTreePref('prefsVersion'))
{
case 0:
orientalPrefs = orientalPrefs.concat([
@ -383,42 +389,42 @@ var TreeStyleTabBase = {
]);
case 1:
case 2:
if (this.getTreePref('urlbar.loadSameDomainToNewChildTab') !== null) {
let value = this.getTreePref('urlbar.loadSameDomainToNewChildTab');
this.setTreePref('urlbar.loadSameDomainToNewTab', value);
this.setTreePref('urlbar.loadSameDomainToNewTab.asChild', value);
if (value) this.setTreePref('urlbar.loadDifferentDomainToNewTab', value);
this.clearTreePref('urlbar.loadSameDomainToNewChildTab');
if (TSTUtils.getTreePref('urlbar.loadSameDomainToNewChildTab') !== null) {
let value = TSTUtils.getTreePref('urlbar.loadSameDomainToNewChildTab');
TSTUtils.setTreePref('urlbar.loadSameDomainToNewTab', value);
TSTUtils.setTreePref('urlbar.loadSameDomainToNewTab.asChild', value);
if (value) TSTUtils.setTreePref('urlbar.loadDifferentDomainToNewTab', value);
TSTUtils.clearTreePref('urlbar.loadSameDomainToNewChildTab');
}
case 3:
if (this.getTreePref('loadDroppedLinkToNewChildTab') !== null) {
this.setTreePref('dropLinksOnTab.behavior',
this.getTreePref('loadDroppedLinkToNewChildTab.confirm') ?
if (TSTUtils.getTreePref('loadDroppedLinkToNewChildTab') !== null) {
TSTUtils.setTreePref('dropLinksOnTab.behavior',
TSTUtils.getTreePref('loadDroppedLinkToNewChildTab.confirm') ?
this.kDROPLINK_ASK :
this.getTreePref('loadDroppedLinkToNewChildTab') ?
TSTUtils.getTreePref('loadDroppedLinkToNewChildTab') ?
this.kDROPLINK_NEWTAB :
this.kDROPLINK_LOAD
);
this.clearTreePref('loadDroppedLinkToNewChildTab.confirm');
this.clearTreePref('loadDroppedLinkToNewChildTab');
TSTUtils.clearTreePref('loadDroppedLinkToNewChildTab.confirm');
TSTUtils.clearTreePref('loadDroppedLinkToNewChildTab');
}
if (this.getTreePref('openGroupBookmarkAsTabSubTree') !== null) {
if (TSTUtils.getTreePref('openGroupBookmarkAsTabSubTree') !== null) {
let behavior = 0;
if (this.getTreePref('openGroupBookmarkAsTabSubTree.underParent'))
if (TSTUtils.getTreePref('openGroupBookmarkAsTabSubTree.underParent'))
behavior += this.kGROUP_BOOKMARK_USE_DUMMY;
if (!this.getTreePref('openGroupBookmarkBehavior.confirm')) {
if (!TSTUtils.getTreePref('openGroupBookmarkBehavior.confirm')) {
behavior += (
this.getTreePref('openGroupBookmarkAsTabSubTree') ?
TSTUtils.getTreePref('openGroupBookmarkAsTabSubTree') ?
this.kGROUP_BOOKMARK_SUBTREE :
this.getTreePref('browser.tabs.loadFolderAndReplace') ?
TSTUtils.getTreePref('browser.tabs.loadFolderAndReplace') ?
this.kGROUP_BOOKMARK_REPLACE :
this.kGROUP_BOOKMARK_SEPARATE
);
}
this.setTreePref('openGroupBookmark.behavior', behavior);
this.clearTreePref('openGroupBookmarkBehavior.confirm');
this.clearTreePref('openGroupBookmarkAsTabSubTree');
this.clearTreePref('openGroupBookmarkAsTabSubTree.underParent');
TSTUtils.setTreePref('openGroupBookmark.behavior', behavior);
TSTUtils.clearTreePref('openGroupBookmarkBehavior.confirm');
TSTUtils.clearTreePref('openGroupBookmarkAsTabSubTree');
TSTUtils.clearTreePref('openGroupBookmarkAsTabSubTree.underParent');
this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
}
case 4:
@ -446,31 +452,31 @@ var TreeStyleTabBase = {
}
}
case 5:
let (behavior = this.getTreePref('openGroupBookmark.behavior')) {
let (behavior = TSTUtils.getTreePref('openGroupBookmark.behavior')) {
behavior = behavior | 2048;
this.setTreePref('openGroupBookmark.behavior', behavior);
TSTUtils.setTreePref('openGroupBookmark.behavior', behavior);
}
case 6:
let (
general = this.getTreePref('autoAttachNewTabsAsChildren'),
search = this.getTreePref('autoAttachSearchResultAsChildren')
general = TSTUtils.getTreePref('autoAttachNewTabsAsChildren'),
search = TSTUtils.getTreePref('autoAttachSearchResultAsChildren')
) {
if (general !== null)
this.setTreePref('autoAttach', general);
TSTUtils.setTreePref('autoAttach', general);
if (search !== null)
this.setTreePref('autoAttach.searchResult', search);
TSTUtils.setTreePref('autoAttach.searchResult', search);
}
case 7:
let (
enabled = this.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut'),
delay = this.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay')
enabled = TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut'),
delay = TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay')
) {
if (enabled !== null) {
this.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut', enabled);
this.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.collapseOthers', enabled);
TSTUtils.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut', enabled);
TSTUtils.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.collapseOthers', enabled);
}
if (delay !== null)
this.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay', delay);
TSTUtils.setTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay', delay);
}
case 8:
orientalPrefs = orientalPrefs.concat([
@ -489,7 +495,7 @@ var TreeStyleTabBase = {
}
break;
}
this.setTreePref('prefsVersion', this.kPREF_VERSION);
TSTUtils.setTreePref('prefsVersion', this.kPREF_VERSION);
},
updateAeroPeek : function TSTUtils_updateAeroPeek()
@ -503,7 +509,7 @@ var TreeStyleTabBase = {
{
// Scriptish
// https://addons.mozilla.org/firefox/addon/scriptish/
if (this.getTreePref('compatibility.Scriptish')) {
if (TSTUtils.getTreePref('compatibility.Scriptish')) {
try {
let tabModule = Components.utils.import('resource://scriptish/utils/Scriptish_openInTab.js', {});
let Scriptish_openInTab = tabModule.Scriptish_openInTab;
@ -560,11 +566,11 @@ var TreeStyleTabBase = {
'%FORCE_NARROW_SCROLLBAR%')
.replace(/%FORCE_NARROW_SCROLLBAR%/g,
this.getTreePref('tabbar.narrowScrollbar.overrideSystemAppearance') ?
TSTUtils.getTreePref('tabbar.narrowScrollbar.overrideSystemAppearance') ?
this.kOVERRIDE_SYSTEM_SCROLLBAR_APPEARANCE : '' )
.replace(/%MODE%/g, this.kMODE)
.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);
SSS.loadAndRegisterSheet(this.lastAgentSheet, SSS.AGENT_SHEET);
@ -662,7 +668,7 @@ var TreeStyleTabBase = {
dropLinksOnTabBehavior : function TSTUtils_dropLinksOnTabBehavior()
{
var behavior = this.getTreePref('dropLinksOnTab.behavior');
var behavior = TSTUtils.getTreePref('dropLinksOnTab.behavior');
if (behavior & this.kDROPLINK_FIXED) return behavior;
var checked = { value : false };
@ -680,7 +686,7 @@ var TreeStyleTabBase = {
behavior = newChildTab ? this.kDROPLINK_NEWTAB : this.kDROPLINK_LOAD ;
if (checked.value)
this.setTreePref('dropLinksOnTab.behavior', behavior);
TSTUtils.setTreePref('dropLinksOnTab.behavior', behavior);
return behavior
},
@ -691,7 +697,7 @@ var TreeStyleTabBase = {
openGroupBookmarkBehavior : function TSTUtils_openGroupBookmarkBehavior()
{
var behavior = this.getTreePref('openGroupBookmark.behavior');
var behavior = TSTUtils.getTreePref('openGroupBookmark.behavior');
if (behavior & this.kGROUP_BOOKMARK_FIXED) return behavior;
var dummyTabFlag = behavior & this.kGROUP_BOOKMARK_USE_DUMMY;
@ -719,7 +725,7 @@ var TreeStyleTabBase = {
behavior = behaviors[button];
if (checked.value) {
this.setTreePref('openGroupBookmark.behavior', behavior);
TSTUtils.setTreePref('openGroupBookmark.behavior', behavior);
this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
}
return behavior;
@ -736,7 +742,7 @@ var TreeStyleTabBase = {
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;
var checked = { value : false };
@ -760,7 +766,7 @@ var TreeStyleTabBase = {
behavior = behaviors[button];
if (checked.value)
this.setTreePref('bookmarkDroppedTabs.behavior', behavior);
TSTUtils.setTreePref('bookmarkDroppedTabs.behavior', behavior);
return behavior;
},
@ -793,14 +799,14 @@ var TreeStyleTabBase = {
}
if (aButtonIndex > 0) {
behavior ^= self.kUNDO_ASK;
self.setTreePref('undoCloseTabSet.behavior', behavior);
TSTUtils.setTreePref('undoCloseTabSet.behavior', behavior);
}
return behavior;
});
},
get undoCloseTabSetBehavior()
{
return this.getTreePref('undoCloseTabSet.behavior');
return TSTUtils.getTreePref('undoCloseTabSet.behavior');
},
kUNDO_ASK : 1,
kUNDO_CLOSE_SET : 2,
@ -1812,7 +1818,7 @@ var TreeStyleTabBase = {
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);
if (!frame)
@ -1911,7 +1917,7 @@ var TreeStyleTabBase = {
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);
if (!frame) return false;
@ -2040,7 +2046,7 @@ var TreeStyleTabBase = {
return (
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)
)
);
@ -2584,7 +2590,7 @@ var TreeStyleTabBase = {
get position() /* PUBLIC API */
{
return this.getTreePref('tabbar.position') || 'top';
return TSTUtils.getTreePref('tabbar.position') || 'top';
},
set position(aValue)
{
@ -2592,8 +2598,8 @@ var TreeStyleTabBase = {
if (!position || !/^(top|bottom|left|right)$/.test(position))
position = 'top';
if (position != this.getTreePref('tabbar.position'))
this.setTreePref('tabbar.position', position);
if (position != TSTUtils.getTreePref('tabbar.position'))
TSTUtils.setTreePref('tabbar.position', position);
return aValue;
},
@ -2705,8 +2711,8 @@ var TreeStyleTabBase = {
updateTabWidthPrefs : function TSTUtils_updateTabWidthPrefs(aPrefName)
{
var expanded = this.getTreePref('tabbar.width');
var shrunken = this.getTreePref('tabbar.shrunkenWidth');
var expanded = TSTUtils.getTreePref('tabbar.width');
var shrunken = TSTUtils.getTreePref('tabbar.shrunkenWidth');
var originalExpanded = expanded;
var originalShrunken = shrunken;
if (aPrefName == 'extensions.treestyletab.tabbar.shrunkenWidth') {
@ -2725,28 +2731,11 @@ var TreeStyleTabBase = {
}
if (expanded != originalExpanded ||
shrunken != originalShrunken) {
this.setTreePref('tabbar.width', Math.max(0, expanded));
this.setTreePref('tabbar.shrunkenWidth', Math.max(0, shrunken));
TSTUtils.setTreePref('tabbar.width', Math.max(0, expanded));
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()
{
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.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');
function TreeStyleTabBrowser(aWindowService, aTabBrowser)
@ -123,7 +129,7 @@ TreeStyleTabBrowser.prototype = {
get scrollBox()
{
return ( // Tab Mix Plus
this.getTreePref('compatibility.TMP') &&
TSTUtils.getTreePref('compatibility.TMP') &&
this.document.getAnonymousElementByAttribute(this.mTabBrowser.mTabContainer, 'class', 'tabs-frame')
) ||
this.mTabBrowser.mTabContainer.mTabstrip;
@ -199,7 +205,7 @@ TreeStyleTabBrowser.prototype = {
{
var orient = this.isVertical ? 'vertical' : 'horizontal' ;
if (!this.windowService.preInitialized)
return this.getTreePref('tabbar.fixed.'+orient);
return TSTUtils.getTreePref('tabbar.fixed.'+orient);
var b = this.mTabBrowser;
if (!b) return false;
@ -308,7 +314,7 @@ TreeStyleTabBrowser.prototype = {
return (
!this.isVertical &&
this.canCollapseSubtree() &&
this.getTreePref('stackCollapsedTabs')
TSTUtils.getTreePref('stackCollapsedTabs')
);
},
@ -331,7 +337,7 @@ TreeStyleTabBrowser.prototype = {
var d = this.document;
var label = d.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-stack') || // Mac OS X
( // Tab Mix Plus
this.getTreePref('compatibility.TMP') &&
TSTUtils.getTreePref('compatibility.TMP') &&
d.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-container')
) ||
d.getAnonymousElementByAttribute(aTab, 'class', 'tab-text tab-label');
@ -342,7 +348,7 @@ TreeStyleTabBrowser.prototype = {
{
var d = this.document;
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');
@ -411,9 +417,9 @@ TreeStyleTabBrowser.prototype = {
isMultiRow : function TSTBrowser_isMultiRow()
{
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) :
('TabmixTabbar' in w && this.getTreePref('compatibility.TMP')) ?
('TabmixTabbar' in w && TSTUtils.getTreePref('compatibility.TMP')) ?
w.TabmixTabbar.isMultiRow :
false ;
},
@ -441,7 +447,7 @@ TreeStyleTabBrowser.prototype = {
var maxWidth = tabbarPlaceHolderWidth || tabbarWidth;
var faviconized = this.getTreePref('pinnedTab.faviconized');
var faviconized = TSTUtils.getTreePref('pinnedTab.faviconized');
var faviconizedSize = tabbar.childNodes[0].boxObject.height;
var width = faviconized ? faviconizedSize : maxWidth ;
@ -581,21 +587,21 @@ TreeStyleTabBrowser.prototype = {
if (this.isVertical) {
let key = this.autoHide.expanded ?
'tabbar.width' : 'tabbar.shrunkenWidth' ;
let width = this.getTreePref(key);
let width = TSTUtils.getTreePref(key);
let minWidth = this.scrollBox.boxObject.width
if (minWidth > width) {
this.setPrefForActiveWindow(function() {
this.setTreePref(key, minWidth);
TSTUtils.setTreePref(key, minWidth);
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PREF_CHANGE);
});
}
}
else {
let height = this.getTreePref('tabbar.height');
let height = TSTUtils.getTreePref('tabbar.height');
let minHeight = this.scrollBox.boxObject.height
if (minHeight > height) {
this.setPrefForActiveWindow(function() {
this.setTreePref('tabbar.height', minHeight);
TSTUtils.setTreePref('tabbar.height', minHeight);
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PREF_CHANGE);
});
}
@ -630,8 +636,8 @@ TreeStyleTabBrowser.prototype = {
var position = this.position;
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+'-vertical', this.getTreePref('tabbar.fixed.vertical') ? 'true' : null, b);
this.setTabbrowserAttribute(this.kFIXED+'-horizontal', TSTUtils.getTreePref('tabbar.fixed.horizontal') ? '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
@ -956,14 +962,14 @@ TreeStyleTabBrowser.prototype = {
aTab.removeAttribute('flex');
aTab.maxWidth = 65000;
aTab.minWidth = 0;
if (this.getTreePref('compatibility.TMP'))
if (TSTUtils.getTreePref('compatibility.TMP'))
aTab.setAttribute('dir', 'ltr'); // Tab Mix Plus
}
else {
aTab.removeAttribute('align');
aTab.removeAttribute('maxwidth');
aTab.removeAttribute('minwidth');
if (this.getTreePref('compatibility.TMP'))
if (TSTUtils.getTreePref('compatibility.TMP'))
aTab.removeAttribute('dir'); // Tab Mix Plus
}
},
@ -1186,7 +1192,7 @@ TreeStyleTabBrowser.prototype = {
var pos = aNewPosition || this.getPositionFlag(this.position);
if (b.getAttribute('id') != 'content' &&
!this.getTreePref('tabbar.position.subbrowser.enabled')) {
!TSTUtils.getTreePref('tabbar.position.subbrowser.enabled')) {
pos = this.kTABBAR_TOP;
}
@ -1213,7 +1219,7 @@ TreeStyleTabBrowser.prototype = {
// Tab Mix Plus
var scrollFrame, newTabBox, tabBarMode;
if (this.getTreePref('compatibility.TMP')) {
if (TSTUtils.getTreePref('compatibility.TMP')) {
scrollFrame = d.getAnonymousElementByAttribute(b.mTabContainer, 'class', 'tabs-frame') ||
d.getAnonymousElementByAttribute(b.mTabContainer, 'anonid', 'scroll-tabs-frame');
newTabBox = d.getAnonymousElementByAttribute(b.mTabContainer, 'id', 'tabs-newbutton-box');
@ -1260,7 +1266,7 @@ TreeStyleTabBrowser.prototype = {
if (scrollInnerBox)
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');
scrollFrame.parentNode.orient =
scrollFrame.orient = 'vertical';
@ -1275,7 +1281,7 @@ TreeStyleTabBrowser.prototype = {
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.removeTabStripAttribute('height');
b.mPanelContainer.removeAttribute('height');
@ -1295,7 +1301,7 @@ TreeStyleTabBrowser.prototype = {
if (pos == this.kTABBAR_RIGHT) {
this.setTabbrowserAttribute(this.kTABBAR_POSITION, 'right');
if (this.getTreePref('tabbar.invertTab')) {
if (TSTUtils.getTreePref('tabbar.invertTab')) {
this.setTabbrowserAttribute(this.kTAB_INVERTED, 'true');
this.indentTarget = 'right';
}
@ -1350,7 +1356,7 @@ TreeStyleTabBrowser.prototype = {
if (scrollInnerBox)
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);
scrollFrame.parentNode.orient =
scrollFrame.orient = 'horizontal';
@ -1361,7 +1367,7 @@ TreeStyleTabBrowser.prototype = {
if (toolboxContainer)
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);
if (strip.localName == 'toolbar') {
@ -1409,7 +1415,7 @@ TreeStyleTabBrowser.prototype = {
tab.style.removeProperty(this.collapseCSSProp);
}
this.indentProp = this.getTreePref('indent.property');
this.indentProp = TSTUtils.getTreePref('indent.property');
this.indentCSSProp = this.indentProp+'-'+this.indentTarget;
this.collapseCSSProp = 'margin-'+this.collapseTarget;
@ -1582,12 +1588,12 @@ TreeStyleTabBrowser.prototype = {
if (TabsOnTop && !this.windowService.isPopupWindow &&
this.windowService.initialized) {
let currentState = TabsOnTop.enabled;
let originalState = this.getTreePref('tabsOnTop.originalState');
let originalState = TSTUtils.getTreePref('tabsOnTop.originalState');
if (originalState !== null &&
currentState != originalState &&
this.windowService.tabsOnTopChangingByUI &&
!this.windowService.changingTabsOnTop)
this.setTreePref('tabsOnTop.originalState', currentState);
TSTUtils.setTreePref('tabsOnTop.originalState', currentState);
// Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=555987
// This should be done when the value of the "ordinal" attribute
// is modified dynamically. So, we don' have to do it before
@ -1605,7 +1611,7 @@ TreeStyleTabBrowser.prototype = {
}
else {
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 (this.position == 'top')
@ -1638,12 +1644,12 @@ TreeStyleTabBrowser.prototype = {
delete self.deferredTasks['updateTabbarState'];
});
var allowToCollapse = this.getTreePref('allowSubtreeCollapseExpand.'+orient);
var allowToCollapse = TSTUtils.getTreePref('allowSubtreeCollapseExpand.'+orient);
if (this.allowSubtreeCollapseExpand != allowToCollapse)
this.collapseExpandAllSubtree(false, false);
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.updateTabsZIndex(this.canStackTabs);
@ -1665,10 +1671,10 @@ TreeStyleTabBrowser.prototype = {
canCollapse : b.getAttribute(this.kALLOW_COLLAPSE) == 'true'
};
var newState = {
fixed : this.getTreePref('tabbar.fixed.'+orient),
maxTreeLevel : this.getTreePref('maxTreeLevel.'+orient),
indented : this.getTreePref('maxTreeLevel.'+orient) != 0,
canCollapse : this.getTreePref('allowSubtreeCollapseExpand.'+orient)
fixed : TSTUtils.getTreePref('tabbar.fixed.'+orient),
maxTreeLevel : TSTUtils.getTreePref('maxTreeLevel.'+orient),
indented : TSTUtils.getTreePref('maxTreeLevel.'+orient) != 0,
canCollapse : TSTUtils.getTreePref('allowSubtreeCollapseExpand.'+orient)
};
if (oldState.fixed == newState.fixed &&
@ -1775,11 +1781,11 @@ TreeStyleTabBrowser.prototype = {
let realWidth = parseInt(this._tabStripPlaceHolder.getAttribute('width') || box.width);
let realHeight = parseInt(this._tabStripPlaceHolder.getAttribute('height') || box.height);
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
) || realWidth;
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
) || realHeight;
let yOffset = pos == 'bottom' ? height - realHeight : 0 ;
@ -1802,7 +1808,7 @@ TreeStyleTabBrowser.prototype = {
strip.collapsed = tabContainerBox.collapsed = collapsed;
if (statusPanel && this.getTreePref('repositionStatusPanel')) {
if (statusPanel && TSTUtils.getTreePref('repositionStatusPanel')) {
let offsetParentBox = this.utils.findOffsetParent(statusPanel).boxObject;
let contentBox = this.mTabBrowser.mPanelContainer.boxObject;
let chromeMargins = (d.documentElement.getAttribute('chromemargin') || '0,0,0,0').split(',');
@ -1827,7 +1833,7 @@ TreeStyleTabBrowser.prototype = {
if (
statusPanel &&
(
this.getTreePref('repositionStatusPanel') ||
TSTUtils.getTreePref('repositionStatusPanel') ||
statusPanel.__treestyletab__repositioned
)
) {
@ -2093,8 +2099,8 @@ TreeStyleTabBrowser.prototype = {
};
for (var i in prefs)
{
if (prefs[i] !== void(0) && this.getTreePref(i) != prefs[i])
this.setTreePref(i, prefs[i]);
if (prefs[i] !== void(0) && TSTUtils.getTreePref(i) != prefs[i])
TSTUtils.setTreePref(i, prefs[i]);
}
this.position = this.position;
},
@ -2330,8 +2336,8 @@ TreeStyleTabBrowser.prototype = {
case 'extensions.treestyletab.tabbar.style':
case 'extensions.treestyletab.tabbar.style.aero':
this.setTabbarStyle(this.getTreePref('tabbar.style'));
value = this.getTreePref('twisty.style');
this.setTabbarStyle(TSTUtils.getTreePref('tabbar.style'));
value = TSTUtils.getTreePref('twisty.style');
if (value != 'auto')
return;
case 'extensions.treestyletab.twisty.style':
@ -2460,7 +2466,7 @@ TreeStyleTabBrowser.prototype = {
aStyle = aStyle.toLowerCase();
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) {
@ -2473,7 +2479,7 @@ TreeStyleTabBrowser.prototype = {
additionalValues.push('color');
if (/^(plain|mixed)$/.test(aStyle))
additionalValues.push('shadow');
if (this.getTreePref('tabbar.style.aero'))
if (TSTUtils.getTreePref('tabbar.style.aero'))
additionalValues.push('aero');
if (additionalValues.length)
aStyle = additionalValues.join(' ')+' '+aStyle;
@ -2493,7 +2499,7 @@ TreeStyleTabBrowser.prototype = {
aStyle = 'modern-black';
if (this.getTreePref('tabbar.style') == 'sidebar') {
if (TSTUtils.getTreePref('tabbar.style') == 'sidebar') {
aStyle = 'osx';
}
else if (
@ -2762,7 +2768,7 @@ TreeStyleTabBrowser.prototype = {
}
else if (
parent &&
this.getTreePref('insertNewChildAt') == this.kINSERT_FISRT &&
TSTUtils.getTreePref('insertNewChildAt') == this.kINSERT_FISRT &&
(this.multipleCount <= 0 || this._addedCountInThisLoop <= 0)
) {
/*
@ -3698,7 +3704,7 @@ TreeStyleTabBrowser.prototype = {
_restoreSubtreeCollapsedState : function TSTBrowser_restoreSubtreeCollapsedState(aTab, aCollapsed)
{
var shouldCollapse = this.getTreePref('collapseExpandSubtree.sessionRestore');
var shouldCollapse = TSTUtils.getTreePref('collapseExpandSubtree.sessionRestore');
if (aCollapsed === void(0))
aCollapsed = this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true';
@ -4081,13 +4087,13 @@ TreeStyleTabBrowser.prototype = {
)
return;
var shouldCollapseExpandNow = this.getTreePref('autoCollapseExpandSubtreeOnSelect');
var shouldCollapseExpandNow = TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect');
var newActiveTabOptions = {
canCollapseTree : shouldCollapseExpandNow,
canExpandTree : shouldCollapseExpandNow
};
if (this.isCollapsed(tab)) {
if (this.getTreePref('autoExpandSubtreeOnCollapsedChildFocused')) {
if (TSTUtils.getTreePref('autoExpandSubtreeOnCollapsedChildFocused')) {
this.getAncestorTabs(tab).forEach(function(aAncestor) {
this.collapseExpandSubtree(aAncestor, false);
}, this);
@ -4112,7 +4118,7 @@ TreeStyleTabBrowser.prototype = {
* only when it is activated by user preference expressly.
*/
this._focusChangedByCurrentTabRemove &&
!this.getTreePref('autoCollapseExpandSubtreeOnSelect.onCurrentTabRemove')
!TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect.onCurrentTabRemove')
)
) {
// do nothing!
@ -4122,13 +4128,13 @@ TreeStyleTabBrowser.prototype = {
this._focusChangedByShortcut &&
this.windowService.accelKeyPressed
) {
if (this.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut')) {
if (TSTUtils.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut')) {
newActiveTabOptions.canExpandTree = true;
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) {
this._autoExpandOnTabSelectTimer = this.window.setTimeout(function(aSelf) {
if (tab && tab.parentNode)
@ -4197,7 +4203,7 @@ TreeStyleTabBrowser.prototype = {
this._focusChangedByShortcut = this.windowService.accelKeyPressed;
if (!this.canCollapseSubtree(this.mTabBrowser.selectedTab) ||
this.getTreePref('focusMode') != this.kFOCUS_VISIBLE)
TSTUtils.getTreePref('focusMode') != this.kFOCUS_VISIBLE)
return false;
if (this.processArrowKeyOnFocusAdvanced())
@ -4242,7 +4248,7 @@ TreeStyleTabBrowser.prototype = {
break;
case 'right':
if (this.getTreePref('tabbar.invertTab')) {
if (TSTUtils.getTreePref('tabbar.invertTab')) {
collapse = event.right;
expand = event.left;
}
@ -4352,7 +4358,7 @@ TreeStyleTabBrowser.prototype = {
let tab = this.getTabFromEvent(aEvent);
if (tab &&
this.hasChildTabs(tab) &&
this.getTreePref('collapseExpandSubtree.dblclick')) {
TSTUtils.getTreePref('collapseExpandSubtree.dblclick')) {
this.manualCollapseExpandSubtree(tab, tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true');
aEvent.preventDefault();
aEvent.stopPropagation();
@ -4476,7 +4482,7 @@ TreeStyleTabBrowser.prototype = {
let item = aEvent.currentTarget.querySelector('*[id^="'+id+'"]');
if (!item) continue;
items[id] = item;
if (this.getTreePref('show.'+id))
if (TSTUtils.getTreePref('show.'+id))
item.removeAttribute('hidden');
else
item.setAttribute('hidden', true);
@ -4682,11 +4688,11 @@ TreeStyleTabBrowser.prototype = {
resetTabbarSize : function TSTBrowser_resetTabbarSize()
{
if (this.isVertical) {
this.setTreePref('tabbar.shrunkenWidth', this.getTreePref('tabbar.shrunkenWidth.default'));
this.setTreePref('tabbar.width', this.getTreePref('tabbar.width.default'));
TSTUtils.setTreePref('tabbar.shrunkenWidth', TSTUtils.getTreePref('tabbar.shrunkenWidth.default'));
TSTUtils.setTreePref('tabbar.width', TSTUtils.getTreePref('tabbar.width.default'));
}
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);
tabContainerBox.removeAttribute('height');
this._tabStripPlaceHolder.height = tabContainerBox.boxObject.height;
@ -4858,7 +4864,7 @@ TreeStyleTabBrowser.prototype = {
this.collapseExpandSubtree(aParent, false, aInfo.dontAnimate);
}
else if (!aInfo.dontExpand) {
if (this.getTreePref('autoCollapseExpandSubtreeOnSelect')) {
if (TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect')) {
if (this.shouldTabAutoExpanded(aParent))
this.collapseExpandTreesIntelligentlyFor(aParent);
newAncestors.forEach(function(aAncestor) {
@ -4867,7 +4873,7 @@ TreeStyleTabBrowser.prototype = {
}, this);
}
else if (this.shouldTabAutoExpanded(aParent)) {
if (this.getTreePref('autoExpandSubtreeOnAppendChild')) {
if (TSTUtils.getTreePref('autoExpandSubtreeOnAppendChild')) {
newAncestors.forEach(function(aAncestor) {
if (this.shouldTabAutoExpanded(aAncestor))
this.collapseExpandSubtree(aAncestor, false, aInfo.dontAnimate);
@ -4991,7 +4997,7 @@ TreeStyleTabBrowser.prototype = {
var insertBefore = null;
if (aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN &&
!this.getTreePref('closeParentBehavior.moveDetachedTabsToBottom')) {
!TSTUtils.getTreePref('closeParentBehavior.moveDetachedTabsToBottom')) {
insertBefore = this.getNextSiblingTab(this.getRootTab(aTab));
}
for (let i = 0, maxi = children.length; i < maxi; i++)
@ -5061,8 +5067,8 @@ TreeStyleTabBrowser.prototype = {
getCloseParentBehaviorForTab : function TSTBrowser_getCloseParentBehaviorForTab(aTab, aDefaultBehavior)
{
var closeParentBehavior = this.getTreePref('closeParentBehavior');
var closeRootBehavior = this.getTreePref('closeRootBehavior');
var closeParentBehavior = TSTUtils.getTreePref('closeParentBehavior');
var closeRootBehavior = TSTUtils.getTreePref('closeRootBehavior');
var parentTab = this.getParentTab(aTab);
var behavior = aDefaultBehavior ?
@ -5262,7 +5268,7 @@ TreeStyleTabBrowser.prototype = {
checkTabsIndentOverflowTimer : null,
checkTabsIndentOverflowCallback : function TSTBrowser_checkTabsIndentOverflowCallback()
{
if (!this.getTreePref('indent.autoShrink')) {
if (!TSTUtils.getTreePref('indent.autoShrink')) {
this.indent = -1;
return;
}
@ -5299,7 +5305,7 @@ TreeStyleTabBrowser.prototype = {
}
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);
if (indent > maxIndent) {
this.indent = indentUnit;
@ -5640,8 +5646,8 @@ TreeStyleTabBrowser.prototype = {
if (aCollapse)
this.deleteTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY);
if (this.getTreePref('indent.autoShrink') &&
this.getTreePref('indent.autoShrink.onlyForVisible'))
if (TSTUtils.getTreePref('indent.autoShrink') &&
TSTUtils.getTreePref('indent.autoShrink.onlyForVisible'))
this.checkTabsIndentOverflow();
this.doingCollapseExpand = false;
@ -5652,8 +5658,8 @@ TreeStyleTabBrowser.prototype = {
if (!aCollapse)
this.setTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY, true);
if (this.getTreePref('indent.autoShrink') &&
this.getTreePref('indent.autoShrink.onlyForVisible')) {
if (TSTUtils.getTreePref('indent.autoShrink') &&
TSTUtils.getTreePref('indent.autoShrink.onlyForVisible')) {
this.cancelCheckTabsIndentOverflow();
if (!aTab.__treestyletab__checkTabsIndentOverflowOnMouseLeave) {
var self = this;
@ -6198,7 +6204,7 @@ TreeStyleTabBrowser.prototype = {
if (this.useTMPSessionAPI && this.getPref('extensions.tabmix.sessions.manager'))
return;
var level = this.getTreePref('restoreTree.level');
var level = TSTUtils.getTreePref('restoreTree.level');
dump('TSTBrowser::restoreTree\n');
dump(' level = '+level+'\n');
dump(' tabsToRestore = '+this.window.__SS_tabsToRestore+'\n');

View File

@ -38,9 +38,17 @@ const EXPORTED_SYMBOLS = ['FullTooltipManager'];
const Cc = Components.classes;
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/pseudoTreeBuilder.js');
XPCOMUtils.defineLazyGetter(this, 'TSTUtils', function() {
var ns = {};
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
return ns.TreeStyleTabUtils;
});
function FullTooltipManager(aOwner)
{
this.init(aOwner);
@ -277,7 +285,7 @@ FullTooltipManager.prototype = {
var label;
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 descendant = this.getDescendantTabs(tab);
@ -287,7 +295,7 @@ FullTooltipManager.prototype = {
if (mode > this.kTOOLTIP_MODE_DEFAULT &&
descendant.length) {
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
.map(function(aTab) {
let label = aTab.getAttribute('label');
@ -308,7 +316,7 @@ FullTooltipManager.prototype = {
var shouldShowTree = mode != this.kTOOLTIP_MODE_DEFAULT && (collapsed || mode == this.kTOOLTIP_MODE_ALWAYS);
if ('mOverCloseButton' in tab && tab.mOverCloseButton) {
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 = label && shouldShowTree ?
this.treeBundle.getFormattedString('tooltip.closeTree.labeled', [label]) :
@ -345,7 +353,7 @@ FullTooltipManager.prototype = {
{
this.cancel();
var delay = this.getTreePref('tooltip.fullTooltipDelay');
var delay = TSTUtils.getTreePref('tooltip.fullTooltipDelay');
if (delay < 0)
return;

View File

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

View File

@ -38,6 +38,15 @@ const EXPORTED_SYMBOLS = ['TabpanelDNDObserver'];
const Cc = Components.classes;
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)
{
this.init(aTabBrowser);
@ -118,10 +127,10 @@ TabpanelDNDObserver.prototype = {
var position = this.getDropPosition(aEvent);
if (position != 'center' &&
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) {
let orient = (position == 'left' || position == 'right') ? 'vertical' : 'horizontal' ;
sv.setTreePref('tabbar.fixed.'+orient, false);
TSTUtils.setTreePref('tabbar.fixed.'+orient, false);
}
sv.setPrefForActiveWindow(function() {
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);
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)
{
@ -255,7 +261,7 @@ TreeStyleTabWindow.prototype = {
{
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) {
return true;
}
@ -285,9 +291,9 @@ TreeStyleTabWindow.prototype = {
return this.window.fullScreen ?
(
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()
@ -454,7 +460,7 @@ TreeStyleTabWindow.prototype = {
aTabBrowser = aTabBrowser || this.browser;
var allTabsButton = d.getElementById('alltabs-button') ||
( // Tab Mix Plus
this.getTreePref('compatibility.TMP') &&
TSTUtils.getTreePref('compatibility.TMP') &&
d.getAnonymousElementByAttribute(aTabBrowser.mTabContainer, 'anonid', 'alltabs-button')
);
@ -464,7 +470,7 @@ TreeStyleTabWindow.prototype = {
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 firstItemIndex = 0;
@ -826,8 +832,8 @@ TreeStyleTabWindow.prototype = {
{
return !this.ctrlTabPreviewsEnabled &&
(
this.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut') ||
this.getTreePref('autoCollapseExpandSubtreeOnSelect')
TSTUtils.getTreePref('autoExpandSubtreeOnSelect.whileFocusMovingByShortcut') ||
TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect')
);
},
@ -900,15 +906,15 @@ TreeStyleTabWindow.prototype = {
width = this.maxTabbarWidth(width, b);
if (expanded || b.treeStyleTab.autoHide.expanded) {
this.setPrefForActiveWindow(function() {
this.setTreePref('tabbar.width', width);
TSTUtils.setTreePref('tabbar.width', width);
});
if (b.treeStyleTab.autoHide.mode == b.treeStyleTab.autoHide.kMODE_SHRINK &&
b.treeStyleTab.tabStripPlaceHolder)
b.treeStyleTab.tabStripPlaceHolder.setAttribute('width', this.getTreePref('tabbar.shrunkenWidth'));
b.treeStyleTab.tabStripPlaceHolder.setAttribute('width', TSTUtils.getTreePref('tabbar.shrunkenWidth'));
}
else {
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;
height += (pos == 'top' ? delta : -delta );
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);
@ -980,7 +986,7 @@ TreeStyleTabWindow.prototype = {
if (
this.updateAeroPeekPreviewsTimer ||
!this.getPref('browser.taskbar.previews.enable') ||
!this.getTreePref('taskbarPreviews.hideCollapsedTabs') ||
!TSTUtils.getTreePref('taskbarPreviews.hideCollapsedTabs') ||
!('Win7Features' in w) ||
!w.Win7Features ||
!this.AeroPeek ||
@ -1004,7 +1010,7 @@ TreeStyleTabWindow.prototype = {
{
if (
!this.getPref('browser.taskbar.previews.enable') ||
!this.getTreePref('taskbarPreviews.hideCollapsedTabs')
!TSTUtils.getTreePref('taskbarPreviews.hideCollapsedTabs')
)
return;
@ -1041,12 +1047,12 @@ TreeStyleTabWindow.prototype = {
try {
var TabsOnTop = w.TabsOnTop;
var originalState = this.getTreePref('tabsOnTop.originalState');
var originalState = TSTUtils.getTreePref('tabsOnTop.originalState');
if (originalState === null) {
let current = this.getDefaultPref('browser.tabs.onTop') === null ?
TabsOnTop.enabled :
this.getPref('browser.tabs.onTop') ;
this.setTreePref('tabsOnTop.originalState', originalState = current);
TSTUtils.setTreePref('tabsOnTop.originalState', originalState = current);
}
if (this.browser.treeStyleTab.position != 'top' ||
@ -1057,7 +1063,7 @@ TreeStyleTabWindow.prototype = {
else {
if (TabsOnTop.enabled != originalState)
TabsOnTop.enabled = originalState;
this.clearTreePref('tabsOnTop.originalState');
TSTUtils.clearTreePref('tabsOnTop.originalState');
}
}
finally {
@ -1142,7 +1148,7 @@ TreeStyleTabWindow.prototype = {
return;
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)
@ -1153,7 +1159,7 @@ TreeStyleTabWindow.prototype = {
var newTabButton = this.getNewTabButtonFromEvent(aEvent);
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;
self._clickEventOnNewTabButtonHandled = true;
this.Deferred.next(function() {
@ -1161,7 +1167,7 @@ TreeStyleTabWindow.prototype = {
});
}
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,
@ -1175,7 +1181,7 @@ TreeStyleTabWindow.prototype = {
var behaviorPref = !aDelta ? 'autoAttach.duplicateTabCommand' :
aDelta < 0 ? 'autoAttach.duplicateTabCommand.back' :
'autoAttach.duplicateTabCommand.forward'
var behavior = this.getTreePref(behaviorPref);
var behavior = TSTUtils.getTreePref(behaviorPref);
this._handleNewTabCommand(aTab || b.selectedTab, behavior);
},
@ -1300,7 +1306,7 @@ TreeStyleTabWindow.prototype = {
this.setTabbrowserAttribute(this.kFIXED+'-'+orient, newFixed || null, b);
this.setPrefForActiveWindow(function() {
b.treeStyleTab.fixed = newFixed;
this.setTreePref('tabbar.fixed.'+orient, newFixed);
TSTUtils.setTreePref('tabbar.fixed.'+orient, newFixed);
});
b.treeStyleTab.updateTabbarState();
@ -1429,7 +1435,7 @@ TreeStyleTabWindow.prototype = {
aTabs.indexOf(next) > -1
);
var root = this.getTreePref('createSubtree.underParent') ?
var root = TSTUtils.getTreePref('createSubtree.underParent') ?
b.addTab(this.getGroupTabURI()) :
aTabs.shift() ;
var self = this;
@ -1538,7 +1544,7 @@ TreeStyleTabWindow.prototype = {
expandTreeAfterKeyReleased : function TSTWindow_expandTreeAfterKeyReleased(aTab)
{
if (this.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut')) return;
if (TSTUtils.getTreePref('autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut')) return;
this._tabShouldBeExpandedAfterKeyReleased = aTab || null;
},
_tabShouldBeExpandedAfterKeyReleased : null,
@ -1689,7 +1695,7 @@ TreeStyleTabWindow.prototype = {
{
case 'extensions.treestyletab.tabbar.autoHide.mode':
// 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.tabSwitch':
case 'extensions.treestyletab.tabbar.autoShow.feedback':

View File

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