From 55fa2764b8ce0f1b335ad12849b045986376d449 Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Mon, 22 Feb 2016 12:49:48 +0900 Subject: [PATCH] Keep current tab visible after the window is resized #660 --- modules/browser.js | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index 7c9ca3c0..92ba45b6 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -1960,6 +1960,10 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { } this._updateFloatingTabbarReason |= aReason; + this._currentTabWasVisible = ( + this._currentTabWasVisible || + this.isTabInViewport(this.browser.selectedTab) + ); if (this._updateFloatingTabbarReason & this.kTABBAR_UPDATE_NOW) { this._updateFloatingTabbarInternal(this._updateFloatingTabbarReason); @@ -1984,7 +1988,8 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { (aReason & this.kTABBAR_UPDATE_BY_PREF_CHANGE ? 'prefchange ' : '' ) + (aReason & this.kTABBAR_UPDATE_BY_APPEARANCE_CHANGE ? 'appearance-change ' : '' ) + (aReason & this.kTABBAR_UPDATE_BY_TABBAR_RESIZE ? 'tabbar-resize ' : '' ) + - (aReason & this.kTABBAR_UPDATE_BY_WINDOW_RESIZE ? 'window-resize ' : '' ) + + (aReason & this.kTABBAR_UPDATE_BY_WINDOW_RESIZE ? + 'window-resize(currentTabWasVisible='+this._currentTabWasVisible+') ' : '' ) + (aReason & this.kTABBAR_UPDATE_BY_FULLSCREEN ? 'fullscreen ' : '' ) + (aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE ? 'autohide ' : '' ) + (aReason & this.kTABBAR_UPDATE_BY_INITIALIZE ? 'initialize ' : '' ) + @@ -2121,11 +2126,34 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { setTimeout((function() { this.notifyingRenderedEvent = false; - if (!collapsed && + var shownAutomatically = ( + !collapsed && this.autoHide.mode == this.autoHide.kMODE_HIDE && - aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE && - this.browser) // ignore calling after destroyed... - this.scrollToTab(this.browser.selectedTab); + aReason & this.kTABBAR_UPDATE_BY_AUTOHIDE + ); + var scrollToCurrentAfterResize = ( + this._currentTabWasVisible && + aReason & this.kTABBAR_UPDATE_BY_WINDOW_RESIZE + ); + log('after floating tab is updated: ', { + shownAutomatically : shownAutomatically, + scrollToCurrentAfterResize : scrollToCurrentAfterResize + }); + + if (this.browser) { // ignore calling after destroyed... + if (shownAutomatically) { + this.scrollToTab(this.browser.selectedTab); + } + else if (scrollToCurrentAfterResize) { + // Make the tab visible immediately! + // If we use scrollToTab with animation, the current tab + // can be invisible sometimes. + this.scrollBoxObject.ensureElementIsVisible(this.browser.selectedTab); + } + } + + if (!this._updateFloatingTabbarTimer) + delete this._currentTabWasVisible; }).bind(this), 0); }, getTabbarPlaceholderSize: function TSTBrowser_getTabbarPlaceholderSize()