diff --git a/content/treestyletab/windowHelper.js b/content/treestyletab/windowHelper.js index e6281358..8f3d4dcb 100644 --- a/content/treestyletab/windowHelper.js +++ b/content/treestyletab/windowHelper.js @@ -33,12 +33,7 @@ var TreeStyleTabWindowHelper = { eval('nsBrowserAccess.prototype.openURI = '+ nsBrowserAccess.prototype.openURI.toSource().replace( /(switch\s*\(aWhere\))/, - + 'TreeStyleTabService.onBeforeBrowserAccessOpenURI(aOpener, aWhere); $1' ) ); @@ -190,28 +185,19 @@ var TreeStyleTabWindowHelper = { eval('nsContextMenu.prototype.'+viewImageMethod+' = '+ nsContextMenu.prototype[viewImageMethod].toSource().replace( 'openUILink(', - + 'TreeStyleTabService.onBeforeViewMedia(e, this.target.ownerDocument.defaultView); $&' ) ); eval('nsContextMenu.prototype.viewBGImage = '+ nsContextMenu.prototype.viewBGImage.toSource().replace( 'openUILink(', - + 'TreeStyleTabService.onBeforeViewMedia(e, this.target.ownerDocument.defaultView); $&' ) ); eval('nsContextMenu.prototype.addDictionaries = '+ nsContextMenu.prototype.addDictionaries.toSource().replace( 'openUILinkIn(', - + 'TreeStyleTabService.onBeforeOpenLink(aWhere, this.target.ownerDocument.defaultView); $&' ) ); @@ -219,19 +205,8 @@ var TreeStyleTabWindowHelper = { 'loadSearch' in BrowserSearch) { eval('BrowserSearch.loadSearch = '+ BrowserSearch.loadSearch.toSource().replace( - // for old Firefox 4 and olders - 'if (useNewTab) {', - - ).replace( - // for Firefox 5 and later 'openLinkIn(', - + 'TreeStyleTabService.onBeforeBrowserSearch(arguments[0], useNewTab); $&' ) ); } @@ -262,11 +237,7 @@ var TreeStyleTabWindowHelper = { eval('window.openLinkIn = '+ window.openLinkIn.toSource().replace( 'browser.loadOneTab(', - .toString() + 'TreeStyleTabService.onBeforeOpenLinkWithParams(params); $&' ) ); } @@ -287,9 +258,7 @@ var TreeStyleTabWindowHelper = { // for Tab Utilities, etc. Some addons insert openNewTabWith() to the function. // (calls for the function is not included by Firefox default.) /(openNewTabWith\()/g, - + 'TreeStyleTabService.onBeforeOpenNewTabByThirdParty(event.target.ownerDocument.defaultView); $1' )); } } @@ -315,10 +284,7 @@ var TreeStyleTabWindowHelper = { continue; eval(func+' = '+source.replace( /((?:openUILinkIn|duplicateTabIn)\()/g, - + 'TreeStyleTabService.onBeforeOpenLink(where); $1' )); } } @@ -334,10 +300,7 @@ var TreeStyleTabWindowHelper = { continue; eval(func+' = '+source.replace( /((?:openUILinkIn|duplicateTabIn)\()/g, - + 'TreeStyleTabService.onBeforeTabReloadOrDuplicate(where); $&' )); } } @@ -355,9 +318,7 @@ var TreeStyleTabWindowHelper = { continue; eval(func+' = '+source.replace( 'gBrowser.loadTabs(', - + 'TreeStyleTabService.readyToOpenNewTabGroup(gBrowser); $&' )); } } @@ -365,10 +326,7 @@ var TreeStyleTabWindowHelper = { eval('FeedHandler.loadFeed = '+ FeedHandler.loadFeed.toSource().replace( 'openUILink(', - + 'TreeStyleTabService.onBeforeViewMedia(event, gBrowser); $&' ) ); @@ -381,15 +339,7 @@ var TreeStyleTabWindowHelper = { eval('FullScreen.toggle = '+ FullScreen.toggle.toSource().replace( '{', - + '{ gBrowser.treeStyleTab.onBeforeFullScreenToggle(); ' ) ); @@ -458,8 +408,7 @@ var TreeStyleTabWindowHelper = { eval('searchbar.doSearch = '+searchbar.doSearch.toSource().replace( /(openUILinkIn\(.+?\);)/, .toString() diff --git a/modules/browser.js b/modules/browser.js index ac2fe16f..fe002133 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -4628,6 +4628,16 @@ TreeStyleTabBrowser.prototype = { }); }, + onBeforeFullScreenToggle : function TSTBrowser_onBeforeFullScreenToggle() + { + if (this.position != 'top') { + if (this.window.fullScreen) + this.autoHide.endForFullScreen(); + else + this.autoHide.startForFullScreen(); + } + }, + onTreeStyleTabPrintPreviewEntered : function TSTBrowser_onTreeStyleTabPrintPreviewEntered(aEvent) { this.setTabbrowserAttribute(this.kPRINT_PREVIEW, true); diff --git a/modules/window.js b/modules/window.js index 54b74d41..93b068a7 100644 --- a/modules/window.js +++ b/modules/window.js @@ -1170,6 +1170,50 @@ TreeStyleTabWindow.prototype = { var b = this.getTabBrowserFromChild(aTab) || this.browser; this._handleNewTabCommand(aTab || b.selectedTab, this.getTreePref('autoAttach.duplicateTabCommand')); }, + + onBeforeTabReloadOrDuplicate : function TSTWindow_onBeforeTabReloadOrDuplicate(aWhere) + { + if (aWhere == 'tab' || aWhere == 'tabshifted') + this.onBeforeTabDuplicate(null); + }, + + onBeforeOpenLink : function TSTWindow_onBeforeOpenLink(aWhere, aOwner) + { + if (aWhere == 'tab' || aWhere == 'tabshifted') + this.readyToOpenChildTab(aOwner); + }, + + onBeforeOpenLinkWithParams : function TSTWindow_onBeforeOpenLinkWithParams(aParams) + { + if (aParams.linkNode && + !this.checkToOpenChildTab(aParams.linkNode.ownerDocument.defaultView)) + this.readyToOpenChildTab(aParams.linkNode.ownerDocument.defaultView); + }, + + onBeforeOpenNewTabByThirdParty : function TSTWindow_onBeforeOpenNewTabByThirdParty(aOwner) + { + if (!this.checkToOpenChildTab(aOwner)) + this.readyToOpenChildTab(aOwner); + }, + + onBeforeBrowserAccessOpenURI : function TSTWindow_onBeforeBrowserAccessOpenURI(aOpener, aWhere) + { + if (aOpener && aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWTAB) + this.readyToOpenChildTab(aOpener); + }, + + onBeforeViewMedia : function TSTWindow_onBeforeViewMedia(aEvent, aOwner) + { + if (String(this.window.whereToOpenLink(aEvent, false, true)).indexOf('tab') == 0) + this.readyToOpenChildTab(aOwner); + }, + + onBeforeBrowserSearch : function TSTWindow_onBeforeBrowserSearch(aTerm, aForceNewTab) + { + if ((argumeuts.length == 1 || aForceNewTab) && + this.shouldOpenSearchResultAsChild(aTerm)) + this.readyToOpenChildTab(); + }, /* Tree Style Tabの初期化が行われる前に復元されたセッションについてツリー構造を復元 */