From 72d38659d8b8786c685074f020d838d2b9150d00 Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Sun, 6 Jan 2013 11:47:50 +0900 Subject: [PATCH] TreeStyleTabBase should not inherit "prefs" --- content/treestyletab/windowHelperHacks.js | 42 ++++++++++----------- modules/autoHide.js | 24 ++++++++---- modules/base.js | 27 +++++++------- modules/browser.js | 40 ++++++++++++-------- modules/tabbarDNDObserver.js | 18 +++++++-- modules/utils.js | 6 +-- modules/window.js | 45 +++++++++++++---------- 7 files changed, 118 insertions(+), 84 deletions(-) diff --git a/content/treestyletab/windowHelperHacks.js b/content/treestyletab/windowHelperHacks.js index 3dd7fc84..22652a2a 100644 --- a/content/treestyletab/windowHelperHacks.js +++ b/content/treestyletab/windowHelperHacks.js @@ -370,7 +370,7 @@ TreeStyleTabWindowHelper.overrideExtensionsBeforeBrowserInit = function TSTWH_ov case 'TreeStyleTabTabbarPositionChanged': var b = aEvent.originalTarget; if (b.treeStyleTab.isVertical) - b.treeStyleTab.setPref('tabberwocky.multirow', false); + TreeStyleTabUtils.prefs.setPref('tabberwocky.multirow', false); break; case 'unload': @@ -467,7 +467,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove break; case sv.kEVENT_TYPE_FOCUS_NEXT_TAB: - let mode = sv.getPref('extensions.tabmix.focusTab'); + let mode = TreeStyleTabUtils.prefs.getPref('extensions.tabmix.focusTab'); if (mode != 2 && mode != 5) aEvent.preventDefault(); break; @@ -581,7 +581,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove if ('flst' in window && TreeStyleTabUtils.getTreePref('compatibility.FLST')) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { - return !aTabBrowser.treeStyleTab.getPref('extensions.flst.enabled'); + return !TreeStyleTabUtils.prefs.getPref('extensions.flst.enabled'); }); } @@ -600,7 +600,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove if ('LastTab' in window && TreeStyleTabUtils.getTreePref('compatibility.LastTab')) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { - return !aTabBrowser.treeStyleTab.getPref('extensions.lasttab.focusLastTabOnClose'); + return !TreeStyleTabUtils.prefs.getPref('extensions.lasttab.focusLastTabOnClose'); }); } @@ -848,8 +848,8 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove if ( autoHIDE.statBar && gBrowser.treeStyleTab.currentTabbarPosition == 'bottom' && - !gBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') && - gBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar') + !TreeStyleTabUtils.prefs.getPref('extensions.autohide.bars.statBar.always') && + TreeStyleTabUtils.prefs.getPref('extensions.autohide.bars.statBar') ) { autoHIDE.statBar.setAttribute('ahHIDE', true); } @@ -859,8 +859,8 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove if ( autoHIDE.statBar && aTabBrowser.treeStyleTab.currentTabbarPosition == 'bottom' && - !aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') && - aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar') + !TreeStyleTabUtils.prefs.getPref('extensions.autohide.bars.statBar.always') && + TreeStyleTabUtils.prefs.getPref('extensions.autohide.bars.statBar') ) { autoHIDE.statBar.removeAttribute('ahHIDE'); } @@ -991,15 +991,15 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove case 'extensions.stm.tabBarMultiRows': case 'extensions.stm.tabBarPosition': if ( - sv.getPref('extensions.stm.tabBarMultiRows') && - sv.getPref('extensions.stm.tabBarPosition') == 0 + TreeStyleTabUtils.prefs.getPref('extensions.stm.tabBarMultiRows') && + TreeStyleTabUtils.prefs.getPref('extensions.stm.tabBarPosition') == 0 ) { - sv.setPref('extensions.stm.tabBarMultiRows.override', false); + TreeStyleTabUtils.prefs.setPref('extensions.stm.tabBarMultiRows.override', false); } return; case 'extensions.stm.newTabBtnPos': - if (TreeStyleTabService.getPref(aData) == 0) + if (TreeStyleTabUtils.prefs.getPref(aData) == 0) document.documentElement.removeAttribute(TreeStyleTabService.kHIDE_NEWTAB); else document.documentElement.setAttribute(TreeStyleTabService.kHIDE_NEWTAB, true); @@ -1009,16 +1009,16 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove }; observer.observe(null, null, 'extensions.stm.tabBarMultiRows'); observer.observe(null, null, 'extensions.stm.newTabBtnPos'); - sv.addPrefListener(observer); + TreeStyleTabUtils.prefs.addPrefListener(observer); document.addEventListener('unload', function() { document.removeEventListener('unload', arguments.callee, false); - sv.removePrefListener(observer); + TreeStyleTabUtils.prefs.removePrefListener(observer); }, false); let warnPref = 'extensions.treestyletab.compatibility.STM.warnForNewTabPosition'; if ( - sv.getPref(warnPref) && - sv.getPref('extensions.stm.newTabPosition') != 0 + TreeStyleTabUtils.prefs.getPref(warnPref) && + TreeStyleTabUtils.prefs.getPref('extensions.stm.newTabPosition') != 0 ) { let checked = { value : false }; if (Services.prompt.confirmEx( @@ -1033,14 +1033,14 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove TreeStyleTabUtils.treeBundle.getString('compatibility_STM_warning_never'), checked ) == 0) { - sv.setPref('extensions.stm.newTabPosition', 0); + TreeStyleTabUtils.prefs.setPref('extensions.stm.newTabPosition', 0); } if (checked.value) - sv.setPref(warnPref, false); + TreeStyleTabUtils.prefs.setPref(warnPref, false); } sv.registerTabFocusAllowance(function(aTabBrowser) { - return aTabBrowser.treeStyleTab.getPref('extensions.stm.focusAfterCloseTab') == 0; + return TreeStyleTabUtils.prefs.getPref('extensions.stm.focusAfterCloseTab') == 0; }); } @@ -1049,7 +1049,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove if ('tabutils' in window && TreeStyleTabUtils.getTreePref('compatibility.TabUtilities')) { TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) { - return aTabBrowser.treeStyleTab.getPref('extensions.tabutils.selectOnClose') == 0; + return TreeStyleTabUtils.prefs.getPref('extensions.tabutils.selectOnClose') == 0; }); } @@ -1185,7 +1185,7 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte ' (function() {\n' + ' var tabs = this.treeStyleTab.getDescendantTabs(this.mCurrentTab);\n' + ' if (tabs.length) {\n' + - ' var index = this.treeStyleTab.getPref("extensions.tabmix.openTabNextInverse") ?\n' + + ' var index = TreeStyleTabUtils.prefs.getPref("extensions.tabmix.openTabNextInverse") ?\n' + ' tabs[tabs.length - 1]._tPos :\n' + ' this.mCurrentTab._tPos ;\n' + ' if (index < aTab._tPos) index++;\n' + diff --git a/modules/autoHide.js b/modules/autoHide.js index 9d3840ab..b0260101 100644 --- a/modules/autoHide.js +++ b/modules/autoHide.js @@ -14,7 +14,7 @@ * 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 + * Portions created by the Initial Developer are Copyright (C) 2010-2013 * the Initial Developer. All Rights Reserved. * * Contributor(s): YUKI "Piro" Hiroshi @@ -37,11 +37,21 @@ const EXPORTED_SYMBOLS = ['AutoHideBrowser', 'AutoHideWindow']; const Cc = Components.classes; const Ci = Components.interfaces; +const Cu = Components.utils; -Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); +Cu.import('resource://gre/modules/XPCOMUtils.jsm'); XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils'); +XPCOMUtils.defineLazyGetter(this, 'window', function() { + Cu.import('resource://treestyletab-modules/lib/namespace.jsm'); + return getNamespaceFor('piro.sakura.ne.jp'); +}); +XPCOMUtils.defineLazyGetter(this, 'prefs', function() { + Cu.import('resource://treestyletab-modules/lib/prefs.js'); + return window['piro.sakura.ne.jp'].prefs; +}); + function AutoHideBrowser(aTabBrowser) { @@ -118,7 +128,7 @@ AutoHideBrowser.prototype = { // update internal property after the appearance of the tab bar is updated. var w = this.window; w.setTimeout(function(aSelf) { - aSelf.mode = (w.fullScreen && aSelf.treeStyleTab.getPref('browser.fullscreen.autohide')) ? + aSelf.mode = (w.fullScreen && prefs.getPref('browser.fullscreen.autohide')) ? aSelf.getModeForFullScreen() : aSelf.getModeForNormal() ; if (aSelf.mode != aSelf.kMODE_DISABLED) @@ -273,7 +283,7 @@ AutoHideBrowser.prototype = { { this.mode = this.getMode(); this.end(); - this.mode = this.treeStyleTab.getPref('browser.fullscreen.autohide') ? + this.mode = prefs.getPref('browser.fullscreen.autohide') ? this.getModeForFullScreen() : this.kMODE_DISABLED ; if (this.mode != this.kMODE_DISABLED) { @@ -841,7 +851,7 @@ AutoHideBrowser.prototype = { if (!this.window || !this.window.TreeStyleTabService) return; - var value = this.treeStyleTab.getPref(aPrefName); + var value = prefs.getPref(aPrefName); switch (aPrefName) { case 'extensions.treestyletab.tabbar.autoHide.mode': @@ -1160,7 +1170,7 @@ AutoHideBrowser.prototype = { b.setAttribute(this.kMODE+'-normal', utils.getTreePref('tabbar.autoHide.mode')); b.setAttribute(this.kMODE+'-fullscreen', utils.getTreePref('tabbar.autoHide.mode.fullscreen')); - sv.addPrefListener(this); + prefs.addPrefListener(this); this.onPrefChange('browser.tabs.closeButtons'); this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area'); this.onPrefChange('extensions.treestyletab.tabbar.togglerSize'); @@ -1183,7 +1193,7 @@ AutoHideBrowser.prototype = { destroy : function AHB_destroy() { this.end(); - this.treeStyleTab.removePrefListener(this); + prefs.removePrefListener(this); var sv = this.treeStyleTab; var b = this.browser; diff --git a/modules/base.js b/modules/base.js index b4047aad..abc25c97 100644 --- a/modules/base.js +++ b/modules/base.js @@ -83,7 +83,6 @@ if (Services.appinfo.OS === 'WINNT') { } var TreeStyleTabBase = { - __proto__ : prefs, tabsHash : null, inWindowDestoructionProcess : false, @@ -302,7 +301,7 @@ var TreeStyleTabBase = { this.applyPlatformDefaultPrefs(); utils.migratePrefs(); - this.addPrefListener(this); + prefs.addPrefListener(this); this.initUninstallationListener(); @@ -341,7 +340,7 @@ var TreeStyleTabBase = { { let originalKey = originalKeys[i]; let key = originalKey.replace('platform.'+OS+'.', ''); - this.setDefaultPref(key, this.getPref(originalKey)); + prefs.setDefaultPref(key, prefs.getPref(originalKey)); processed[key] = true; } originalKeys = this.getDescendant('extensions.treestyletab.platform.default'); @@ -350,7 +349,7 @@ var TreeStyleTabBase = { let originalKey = originalKeys[i]; let key = originalKey.replace('platform.default.', ''); if (!(key in processed)) - this.setDefaultPref(key, this.getPref(originalKey)); + prefs.setDefaultPref(key, prefs.getPref(originalKey)); } }, @@ -580,7 +579,7 @@ var TreeStyleTabBase = { if (checked.value) { utils.setTreePref('openGroupBookmark.behavior', behavior); - this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE)); + prefs.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE)); } return behavior; }, @@ -2499,7 +2498,7 @@ var TreeStyleTabBase = { onPrefChange : function utils_onPrefChange(aPrefName) { - var value = this.getPref(aPrefName); + var value = prefs.getPref(aPrefName); switch (aPrefName) { case 'extensions.treestyletab.indent.vertical': @@ -2520,29 +2519,29 @@ var TreeStyleTabBase = { case 'extensions.stm.tabBarMultiRows': // Super Tab Mode if (this.prefOverriding) return; aPrefName += '.override'; - this.setPref(aPrefName, value); + prefs.setPref(aPrefName, value); case 'browser.tabs.insertRelatedAfterCurrent.override': case 'browser.tabs.loadFolderAndReplace.override': case 'extensions.stm.tabBarMultiRows.override': // Super Tab Mode - if (this.getPref(aPrefName+'.force')) { - let defaultValue = this.getDefaultPref(aPrefName); + if (prefs.getPref(aPrefName+'.force')) { + let defaultValue = prefs.getDefaultPref(aPrefName); if (value != defaultValue) { - this.setPref(aPrefName, defaultValue); + prefs.setPref(aPrefName, defaultValue); return; } } this.prefOverriding = true; let (target = aPrefName.replace('.override', '')) { - let originalValue = this.getPref(target); + let originalValue = prefs.getPref(target); if (originalValue !== null && originalValue != value) - this.setPref(target+'.backup', originalValue); - this.setPref(target, this.getPref(aPrefName)); + prefs.setPref(target+'.backup', originalValue); + prefs.setPref(target, prefs.getPref(aPrefName)); } this.prefOverriding = false; return; case 'extensions.treestyletab.clickOnIndentSpaces.enabled': - return this.shouldDetectClickOnIndentSpaces = this.getPref(aPrefName); + return this.shouldDetectClickOnIndentSpaces = prefs.getPref(aPrefName); case 'extensions.treestyletab.tabbar.scroll.smooth': return this.smoothScrollEnabled = value; diff --git a/modules/browser.js b/modules/browser.js index f7b4d738..1949e2be 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -37,8 +37,9 @@ const EXPORTED_SYMBOLS = ['TreeStyleTabBrowser']; const Cc = Components.classes; const Ci = Components.interfaces; +const Cu = Components.utils; -Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); +Cu.import('resource://gre/modules/XPCOMUtils.jsm'); XPCOMUtils.defineLazyModuleGetter(this, 'Services', 'resource://gre/modules/Services.jsm'); XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils'); @@ -47,7 +48,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 'TabbarDNDObserver', 'resource://treesty XPCOMUtils.defineLazyModuleGetter(this, 'TabpanelDNDObserver', 'resource://treestyletab-modules/tabpanelDNDObserver.js'); XPCOMUtils.defineLazyModuleGetter(this, 'AutoHideBrowser', 'resource://treestyletab-modules/autoHide.js'); -Components.utils.import('resource://treestyletab-modules/window.js'); +XPCOMUtils.defineLazyGetter(this, 'window', function() { + Cu.import('resource://treestyletab-modules/lib/namespace.jsm'); + return getNamespaceFor('piro.sakura.ne.jp'); +}); +XPCOMUtils.defineLazyGetter(this, 'prefs', function() { + Cu.import('resource://treestyletab-modules/lib/prefs.js'); + return window['piro.sakura.ne.jp'].prefs; +}); + +Cu.import('resource://treestyletab-modules/window.js'); function TreeStyleTabBrowser(aWindowService, aTabBrowser) { @@ -447,7 +457,7 @@ TreeStyleTabBrowser.prototype = { { var w = this.window; return ('tabberwocky' in w && utils.getTreePref('compatibility.Tabberwocky')) ? - (this.getPref('tabberwocky.multirow') && !this.isVertical) : + (prefs.getPref('tabberwocky.multirow') && !this.isVertical) : ('TabmixTabbar' in w && utils.getTreePref('compatibility.TMP')) ? w.TabmixTabbar.isMultiRow : false ; @@ -721,7 +731,7 @@ TreeStyleTabBrowser.prototype = { Services.obs.addObserver(this, this.kTOPIC_CHANGE_TREEVIEW_AVAILABILITY, false); Services.obs.addObserver(this, 'private-browsing-change-granted', false); Services.obs.addObserver(this, 'lightweight-theme-styling-update', false); - this.addPrefListener(this); + prefs.addPrefListener(this); // Don't init these ovservers on this point to avoid needless initializations. // this.tabbarDNDObserver; @@ -1245,7 +1255,7 @@ TreeStyleTabBrowser.prototype = { let newTabButton = d.getElementById('new-tab-button'); if (newTabButton && newTabButton.parentNode == b.tabContainer._container) newTabBox = newTabButton; - tabBarMode = this.getPref('extensions.tabmix.tabBarMode'); + tabBarMode = prefs.getPref('extensions.tabmix.tabBarMode'); } // All-in-One Sidebar @@ -1292,7 +1302,7 @@ TreeStyleTabBrowser.prototype = { if (newTabBox) newTabBox.orient = 'horizontal'; if (tabBarMode == 2) - this.setPref('extensions.tabmix.tabBarMode', 1); + prefs.setPref('extensions.tabmix.tabBarMode', 1); } if (toolboxContainer) @@ -1770,7 +1780,7 @@ TreeStyleTabBrowser.prototype = { if (splitter.collapsed || splitter.getAttribute('state') != 'collapsed') { this._tabStripPlaceHolder.collapsed = splitter.collapsed = - (this.getPref('browser.tabs.autoHide') && this.getExistingTabsCount() == 1); + (prefs.getPref('browser.tabs.autoHide') && this.getExistingTabsCount() == 1); } var strip = this.tabStrip; @@ -2052,7 +2062,7 @@ TreeStyleTabBrowser.prototype = { Services.obs.removeObserver(this, this.kTOPIC_CHANGE_TREEVIEW_AVAILABILITY); Services.obs.removeObserver(this, 'private-browsing-change-granted'); Services.obs.removeObserver(this, 'lightweight-theme-styling-update'); - this.removePrefListener(this); + prefs.removePrefListener(this); delete this.windowService; delete this.window; @@ -2323,7 +2333,7 @@ TreeStyleTabBrowser.prototype = { return; var b = this.mTabBrowser; - var value = this.getPref(aPrefName); + var value = prefs.getPref(aPrefName); var tabContainer = b.mTabContainer; var tabs = this.getAllTabs(b); switch (aPrefName) @@ -2431,7 +2441,7 @@ TreeStyleTabBrowser.prototype = { case 'browser.tabs.animate': this.setTabbrowserAttribute(this.kANIMATION_ENABLED, - this.getPref('browser.tabs.animate') !== false + prefs.getPref('browser.tabs.animate') !== false ? 'true' : null ); return; @@ -2524,8 +2534,8 @@ TreeStyleTabBrowser.prototype = { aStyle = 'osx'; } else if ( - this.getPref('extensions.informationaltab.thumbnail.enabled') && - this.getPref('extensions.informationaltab.thumbnail.position') < 100 + prefs.getPref('extensions.informationaltab.thumbnail.enabled') && + prefs.getPref('extensions.informationaltab.thumbnail.position') < 100 ) { let self = this; this.extensions.isAvailable('informationaltab@piro.sakura.ne.jp', { @@ -2844,7 +2854,7 @@ TreeStyleTabBrowser.prototype = { this.updateInsertionPositionInfo(tab); - if (this.getPref('browser.tabs.autoHide')) + if (prefs.getPref('browser.tabs.autoHide')) this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR); if (this.canStackTabs) @@ -3073,7 +3083,7 @@ TreeStyleTabBrowser.prototype = { if (tab.getAttribute('pinned') == 'true') this.positionPinnedTabsWithDelay(); - if (this.getPref('browser.tabs.autoHide')) + if (prefs.getPref('browser.tabs.autoHide')) this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR); if (this.canStackTabs) @@ -6251,7 +6261,7 @@ TreeStyleTabBrowser.prototype = { this.needRestoreTree = false; - if (this.useTMPSessionAPI && this.getPref('extensions.tabmix.sessions.manager')) + if (this.useTMPSessionAPI && prefs.getPref('extensions.tabmix.sessions.manager')) return; var level = utils.getTreePref('restoreTree.level'); diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js index ae637b6b..9edb51d3 100644 --- a/modules/tabbarDNDObserver.js +++ b/modules/tabbarDNDObserver.js @@ -14,7 +14,7 @@ * 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 + * Portions created by the Initial Developer are Copyright (C) 2010-2013 * the Initial Developer. All Rights Reserved. * * Contributor(s): YUKI "Piro" Hiroshi @@ -39,12 +39,22 @@ const DEBUG = false; const Cc = Components.classes; const Ci = Components.interfaces; +const Cu = Components.utils; -Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); -Components.utils.import('resource://gre/modules/Services.jsm'); +Cu.import('resource://gre/modules/XPCOMUtils.jsm'); +Cu.import('resource://gre/modules/Services.jsm'); XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils'); +XPCOMUtils.defineLazyGetter(this, 'window', function() { + Cu.import('resource://treestyletab-modules/lib/namespace.jsm'); + return getNamespaceFor('piro.sakura.ne.jp'); +}); +XPCOMUtils.defineLazyGetter(this, 'prefs', function() { + Cu.import('resource://treestyletab-modules/lib/prefs.js'); + return window['piro.sakura.ne.jp'].prefs; +}); + const TAB_DROP_TYPE = 'application/x-moz-tabbrowser-tab'; const SSS = Cc['@mozilla.org/content/style-sheet-service;1'] @@ -1064,7 +1074,7 @@ catch(e) { var w = this.window; var self = this; - let bgLoad = sv.getPref('browser.tabs.loadInBackground'); + let bgLoad = prefs.getPref('browser.tabs.loadInBackground'); if (aEvent.shiftKey) bgLoad = !bgLoad; let tab = sv.getTabFromEvent(aEvent); diff --git a/modules/utils.js b/modules/utils.js index 4ad35514..a3b02ef1 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -47,19 +47,17 @@ XPCOMUtils.defineLazyGetter(this, 'window', function() { Cu.import('resource://treestyletab-modules/lib/namespace.jsm'); return getNamespaceFor('piro.sakura.ne.jp'); }); - XPCOMUtils.defineLazyGetter(this, 'prefs', function() { Cu.import('resource://treestyletab-modules/lib/prefs.js'); return window['piro.sakura.ne.jp'].prefs; }); - XPCOMUtils.defineLazyGetter(this, 'stringBundle', function() { Cu.import('resource://treestyletab-modules/lib/stringBundle.js', {}); return window['piro.sakura.ne.jp'].stringBundle; }); -XPCOMUtils.defineLazyModuleGetter(this, 'base', - 'resource://treestyletab-modules/base.js', 'TreeStyleTabBase'); +XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabConstants', + 'resource://treestyletab-modules/constants.js', 'TreeStyleTabConstants'); const TST_PREF_PREFIX = 'extensions.treestyletab.'; const TST_PREF_VERSION = 9; diff --git a/modules/window.js b/modules/window.js index b72d4fec..bce28b19 100644 --- a/modules/window.js +++ b/modules/window.js @@ -14,7 +14,7 @@ * 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) 2012 + * Portions created by the Initial Developer are Copyright (C) 2012-2013 * the Initial Developer. All Rights Reserved. * * Contributor(s): YUKI "Piro" Hiroshi @@ -37,17 +37,24 @@ const EXPORTED_SYMBOLS = ['TreeStyleTabWindow']; const Cc = Components.classes; const Ci = Components.interfaces; +const Cu = Components.utils; -Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); +Cu.import('resource://gre/modules/XPCOMUtils.jsm'); + +XPCOMUtils.defineLazyGetter(this, 'window', function() { + Cu.import('resource://treestyletab-modules/lib/namespace.jsm'); + return getNamespaceFor('piro.sakura.ne.jp'); +}); +XPCOMUtils.defineLazyGetter(this, 'prefs', function() { + Cu.import('resource://treestyletab-modules/lib/prefs.js'); + return window['piro.sakura.ne.jp'].prefs; -XPCOMUtils.defineLazyModuleGetter(this, "prefs", - 'resource://treestyletab-modules/lib/prefs.js'); XPCOMUtils.defineLazyModuleGetter(this, 'UninstallationListener', 'resource://treestyletab-modules/lib/UninstallationListener.js'); -XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, 'Services', 'resource://gre/modules/Services.jsm'); -Components.utils.import('resource://treestyletab-modules/base.js'); +Cu.import('resource://treestyletab-modules/base.js'); XPCOMUtils.defineLazyModuleGetter(this, 'TreeStyleTabBrowser', 'resource://treestyletab-modules/browser.js'); XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils'); XPCOMUtils.defineLazyModuleGetter(this, 'AutoHideWindow', 'resource://treestyletab-modules/autoHide.js'); @@ -280,7 +287,7 @@ TreeStyleTabWindow.prototype = { { return this.window.fullScreen ? ( - this.getPref('browser.fullscreen.autohide') && + prefs.getPref('browser.fullscreen.autohide') && utils.getTreePref('tabbar.autoHide.mode.fullscreen') ) : utils.getTreePref('tabbar.autoHide.mode'); @@ -361,7 +368,7 @@ TreeStyleTabWindow.prototype = { w.addEventListener('UIOperationHistoryUndo:TabbarOperations', this, false); w.addEventListener('UIOperationHistoryRedo:TabbarOperations', this, false); - this.addPrefListener(this); + prefs.addPrefListener(this); this.initUninstallationListener(); @@ -521,7 +528,7 @@ TreeStyleTabWindow.prototype = { w.removeEventListener('UIOperationHistoryUndo:TabbarOperations', this, false); w.removeEventListener('UIOperationHistoryRedo:TabbarOperations', this, false); - this.removePrefListener(this); + prefs.removePrefListener(this); } catch(e) { throw e; @@ -807,7 +814,7 @@ TreeStyleTabWindow.prototype = { get ctrlTabPreviewsEnabled() { return 'allTabs' in this.window && - this.getPref('browser.ctrlTab.previews'); + prefs.getPref('browser.ctrlTab.previews'); }, onTabbarResizeStart : function TSTWindow_onTabbarResizeStart(aEvent) @@ -915,7 +922,7 @@ TreeStyleTabWindow.prototype = { var tab = aEvent.originalTarget; var b = this.getTabBrowserFromChild(tab); if ( - this.getPref('browser.tabs.selectOwnerOnClose') && + prefs.getPref('browser.tabs.selectOwnerOnClose') && tab.owner && ( !b._removingTabs || @@ -952,7 +959,7 @@ TreeStyleTabWindow.prototype = { var w = this.window; if ( this.updateAeroPeekPreviewsTimer || - !this.getPref('browser.taskbar.previews.enable') || + !prefs.getPref('browser.taskbar.previews.enable') || !utils.getTreePref('taskbarPreviews.hideCollapsedTabs') || !('Win7Features' in w) || !w.Win7Features || @@ -976,7 +983,7 @@ TreeStyleTabWindow.prototype = { updateAeroPeekPreviewsInternal : function TSTWindow_updateAeroPeekPreviewsInternal() { if ( - !this.getPref('browser.taskbar.previews.enable') || + !prefs.getPref('browser.taskbar.previews.enable') || !utils.getTreePref('taskbarPreviews.hideCollapsedTabs') ) return; @@ -1016,9 +1023,9 @@ TreeStyleTabWindow.prototype = { var TabsOnTop = w.TabsOnTop; var originalState = utils.getTreePref('tabsOnTop.originalState'); if (originalState === null) { - let current = this.getDefaultPref('browser.tabs.onTop') === null ? + let current = prefs.getDefaultPref('browser.tabs.onTop') === null ? TabsOnTop.enabled : - this.getPref('browser.tabs.onTop') ; + prefs.getPref('browser.tabs.onTop') ; utils.setTreePref('tabsOnTop.originalState', originalState = current); } @@ -1361,7 +1368,7 @@ TreeStyleTabWindow.prototype = { { if ( aTabsCount <= 1 || - !this.getPref('browser.tabs.warnOnClose') + !prefs.getPref('browser.tabs.warnOnClose') ) return true; var checked = { value:true }; @@ -1378,7 +1385,7 @@ TreeStyleTabWindow.prototype = { checked ) == 0; if (shouldClose && !checked.value) - this.setPref('browser.tabs.warnOnClose', false); + prefs.setPref('browser.tabs.warnOnClose', false); return shouldClose; }, @@ -1663,7 +1670,7 @@ TreeStyleTabWindow.prototype = { onPrefChange : function TSTWindow_onPrefChange(aPrefName) { - var value = this.getPref(aPrefName); + var value = prefs.getPref(aPrefName); switch (aPrefName) { case 'extensions.treestyletab.tabbar.autoHide.mode': @@ -1677,7 +1684,7 @@ TreeStyleTabWindow.prototype = { case 'extensions.treestyletab.tabbar.style': case 'extensions.treestyletab.tabbar.position': - this.themeManager.set(this.getPref('extensions.treestyletab.tabbar.style'), this.position); + this.themeManager.set(prefs.getPref('extensions.treestyletab.tabbar.style'), this.position); break; case 'browser.ctrlTab.previews':