diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 6f87d23c..436d7121 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -142,77 +142,97 @@ var TreeStyleTabService = { }, get SessionStore() { - delete this.SessionStore; - return (this.SessionStore = Components + if (!this._SessionStore) { + this._SessionStore = Components .classes['@mozilla.org/browser/sessionstore;1'] - .getService(Components.interfaces.nsISessionStore)); + .getService(Components.interfaces.nsISessionStore); + } + return this._SessionStore; }, + _SessionStore : null, get ObserverService() { - delete this.ObserverService; - return (this.ObserverService = Components + if (!this._ObserverService) { + this._ObserverService = Components .classes['@mozilla.org/observer-service;1'] - .getService(Components.interfaces.nsIObserverService)); + .getService(Components.interfaces.nsIObserverService); + } + return this._ObserverService; }, + _ObserverService : null, get IOService() { - delete this.IOService; - return (this.IOService = Components + if (!this._IOService) { + this._IOService = Components .classes['@mozilla.org/network/io-service;1'] - .getService(Components.interfaces.nsIIOService)); + .getService(Components.interfaces.nsIIOService); + } + return this._IOService; }, + _IOService : null, get WindowMediator() { - delete this.WindowMediator; - return (this.WindowMediator = Components + if (!this._WindowMediator) { + this._WindowMediator = Components .classes['@mozilla.org/appshell/window-mediator;1'] - .getService(Components.interfaces.nsIWindowMediator)); + .getService(Components.interfaces.nsIWindowMediator); + } + return this._WindowMediator; }, + _WindowMediator : null, get EffectiveTLD() { - delete this.EffectiveTLD; - return (this.EffectiveTLD = ( - 'nsIEffectiveTLDService' in Components.interfaces ? - Components - .classes['@mozilla.org/network/effective-tld-service;1'] - .getService(Components.interfaces.nsIEffectiveTLDService) : - null - )); + if (!('_EffectiveTLD' in this)) { + this._EffectiveTLD = 'nsIEffectiveTLDService' in Components.interfaces ? + Components + .classes['@mozilla.org/network/effective-tld-service;1'] + .getService(Components.interfaces.nsIEffectiveTLDService) : + null ; + } + return this._EffectiveTLD; }, +// _EffectiveTLD : null, get PromptService() { - delete this.PromptService; - return (this.PromptService = Components + if (!this._PromptService) { + this._PromptService = Components .classes['@mozilla.org/embedcomp/prompt-service;1'] - .getService(Components.interfaces.nsIPromptService)); + .getService(Components.interfaces.nsIPromptService); + } + return this._PromptService; }, + _PromptService : null, get XULAppInfo() { - delete this.XULAppInfo; - return (this.XULAppInfo = Components + if (!this._XULAppInfo) { + this._XULAppInfo = Components .classes['@mozilla.org/xre/app-info;1'] - .getService(Components.interfaces.nsIXULAppInfo)); + .getService(Components.interfaces.nsIXULAppInfo); + } + return this._XULAppInfo; }, + _XULAppInfo : null, get Comparator() { - delete this.Comparator; - return (this.Comparator = Components + if (!this._Comparator) { + this._Comparator = Components .classes['@mozilla.org/xpcom/version-comparator;1'] - .getService(Components.interfaces.nsIVersionComparator)); + .getService(Components.interfaces.nsIVersionComparator); + } + return this._Comparator; }, + _Comparator : null, get treeBundle() { - delete this.treeBundle; - return (this.treeBundle = window['piro.sakura.ne.jp'] + return window['piro.sakura.ne.jp'] .stringBundle - .get('chrome://treestyletab/locale/treestyletab.properties')); + .get('chrome://treestyletab/locale/treestyletab.properties'); }, get tabbrowserBundle() { - delete this.tabbrowserBundle; - return (this.tabbrowserBundle = window['piro.sakura.ne.jp'] + return window['piro.sakura.ne.jp'] .stringBundle - .get('chrome://browser/locale/tabbrowser.properties')); + .get('chrome://browser/locale/tabbrowser.properties'); }, /* API */ diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 841f0289..f0e971de 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -54,17 +54,22 @@ TreeStyleTabBrowser.prototype = { get container() { - delete this.container; - return (this.container = document.getElementById('appcontent')); + if (!this._container) { + this._container = document.getElementById('appcontent'); + } + return this._container; }, + _container : null, get scrollBox() { - delete this.scrollBox; - var scrollBox = document.getAnonymousElementByAttribute(this.mTabBrowser.mTabContainer, 'class', 'tabs-frame') || // Tab Mix Plus + if (!this._scrollBox) { + this._scrollBox = document.getAnonymousElementByAttribute(this.mTabBrowser.mTabContainer, 'class', 'tabs-frame') || // Tab Mix Plus this.mTabBrowser.mTabContainer.mTabstrip; - return (this.scrollBox = scrollBox); + } + return this._scrollBox; }, + _scrollBox : null, get scrollBoxObject() { return (this.scrollBox.scrollBoxObject || this.scrollBox.boxObject) @@ -1024,9 +1029,9 @@ TreeStyleTabBrowser.prototype = { b.mPanelContainer.removeEventListener('dragdrop', this, false); this.tabbarDNDObserver.destroy(); - delete this.tabbarDNDObserver; + delete this._tabbarDNDObserver; this.panelDNDObserver.destroy(); - delete this.panelDNDObserver; + delete this._panelDNDObserver; this.scrollBox.removeEventListener('overflow', this, true); this.scrollBox.removeEventListener('underflow', this, true); @@ -2345,14 +2350,12 @@ TreeStyleTabBrowser.prototype = { get tabbarDNDObserver() { - delete this.tabbarDNDObserver; - return (this.tabbarDNDObserver = new TreeStyleTabBrowserTabbarDNDObserver(this)); + return this._tabbarDNDObserver || (this._tabbarDNDObserver = new TreeStyleTabBrowserTabbarDNDObserver(this)); }, get panelDNDObserver() { - delete this.panelDNDObserver; - return (this.panelDNDObserver = new TreeStyleTabBrowserTabpanelDNDObserver(this)); + return this._panelDNDObserver || (this._panelDNDObserver = new TreeStyleTabBrowserTabpanelDNDObserver(this)); }, getCurrentDragSession : function()