From c732d5e32b559f308a2c2e13c4e25fc421683f99 Mon Sep 17 00:00:00 2001 From: Rodrigo Silveira Date: Fri, 12 Jul 2013 17:12:46 -0700 Subject: [PATCH] Bug 851344 - Extend the duration of the tab bar showing when the user opens a link in a new tab r=mbrubeck --HG-- extra : rebase_source : 434e4215947e3072eb8b35928e9a493a5c9a33e6 --- browser/metro/base/content/ContextCommands.js | 2 +- browser/metro/base/content/ContextUI.js | 43 +++---------------- browser/metro/base/content/browser-ui.js | 28 ++++++------ 3 files changed, 20 insertions(+), 53 deletions(-) diff --git a/browser/metro/base/content/ContextCommands.js b/browser/metro/base/content/ContextCommands.js index 67634c0cf4c..362b67d78ab 100644 --- a/browser/metro/base/content/ContextCommands.js +++ b/browser/metro/base/content/ContextCommands.js @@ -161,7 +161,7 @@ var ContextCommands = { openLinkInNewTab: function cc_openLinkInNewTab() { Browser.addTab(ContextMenuUI.popupState.linkURL, false, Browser.selectedTab); - ContextUI.peekTabs(); + ContextUI.peekTabs(kOpenInNewTabAnimationDelayMsec); }, copyLink: function cc_copyLink() { diff --git a/browser/metro/base/content/ContextUI.js b/browser/metro/base/content/ContextUI.js index 67d7d25ed8f..785567983cc 100644 --- a/browser/metro/base/content/ContextUI.js +++ b/browser/metro/base/content/ContextUI.js @@ -10,12 +10,6 @@ const kContextUIDismissEvent = "MozContextUIDismiss"; const kContextUITabsShowEvent = "MozContextUITabsShow"; // add more as needed... -// delay for ContextUI's dismissTabsWithDelay -const kHideContextAndTrayDelayMsec = 3000; - -// delay when showing the tab bar briefly as a new tab opens -const kNewTabAnimationDelayMsec = 1000; - /* * Manages context UI (navbar, tabbar, appbar) and track visibility. Also * tracks events that summon and hide the context UI. @@ -160,35 +154,24 @@ var ContextUI = { /* * Briefly show the tab bar and then hide it. Fires context ui events. */ - peekTabs: function peekTabs() { - if (this.tabbarVisible) { - setTimeout(function () { - ContextUI.dismissTabsWithDelay(kNewTabAnimationDelayMsec); - }, 0); - } else { - BrowserUI.setOnTabAnimationEnd(function () { - ContextUI.dismissTabsWithDelay(kNewTabAnimationDelayMsec); - }); + peekTabs: function peekTabs(aDelay) { + if (!this.tabbarVisible) this.displayTabs(); - } + + ContextUI.dismissTabsWithDelay(aDelay); }, /* * Dismiss tab bar after a delay. Fires context ui events. */ dismissTabsWithDelay: function (aDelay) { - aDelay = aDelay || kHideContextAndTrayDelayMsec; + aDelay = aDelay || kNewTabAnimationDelayMsec; this._clearDelayedTimeout(); this._hidingId = setTimeout(function () { ContextUI.dismissTabs(); }, aDelay); }, - // Cancel any pending delayed dismiss - cancelDismiss: function cancelDismiss() { - this._clearDelayedTimeout(); - }, - // Display the nav bar displayNavbar: function () { this._clearDelayedTimeout(); @@ -201,12 +184,6 @@ var ContextUI = { this._setIsExpanded(true); }, - // Display the app bar - displayContextAppbar: function () { - this._clearDelayedTimeout(); - Elements.contextappbar.show(); - }, - // Dismiss the navbar if visible. dismissNavbar: function dismissNavbar() { Elements.navbar.dismiss(); @@ -312,15 +289,9 @@ var ContextUI = { if (aEvent.button == 0 && this.isVisible) this.dismiss(); break; - case 'URLChanged': - this.dismissTabs(); - break; - case 'TabSelect': - this.dismissTabs(); - break; - case 'ToolPanelShown': - case 'ToolPanelHidden': + case "ToolPanelShown": + case "ToolPanelHidden": case "touchstart": case "AlertActive": this.dismiss(); diff --git a/browser/metro/base/content/browser-ui.js b/browser/metro/base/content/browser-ui.js index 28511d0d133..97019bcbed4 100644 --- a/browser/metro/base/content/browser-ui.js +++ b/browser/metro/base/content/browser-ui.js @@ -22,6 +22,13 @@ const kStartOverlayURI = "about:start"; const debugServerStateChanged = "devtools.debugger.remote-enabled"; const debugServerPortChanged = "devtools.debugger.remote-port"; +// delay when showing the tab bar briefly after a new (empty) tab opens +const kNewTabAnimationDelayMsec = 1000; +// delay when showing the tab bar after opening a link on a new tab +const kOpenInNewTabAnimationDelayMsec = 3000; +// delay before closing tab bar after selecting another tab +const kSelectTabAnimationDelayMsec = 500; + /** * Cache of commonly used elements. */ @@ -465,21 +472,9 @@ var BrowserUI = { newTab: function newTab(aURI, aOwner) { aURI = aURI || kStartOverlayURI; let tab = Browser.addTab(aURI, true, aOwner); - ContextUI.peekTabs(); return tab; }, - newOrSelectTab: function newOrSelectTab(aURI, aOwner) { - let tabs = Browser.tabs; - for (let i = 0; i < tabs.length; i++) { - if (tabs[i].browser.currentURI.spec == aURI) { - Browser.selectedTab = tabs[i]; - return; - } - } - this.newTab(aURI, aOwner); - }, - setOnTabAnimationEnd: function setOnTabAnimationEnd(aCallback) { Elements.tabs.addEventListener("animationend", function onAnimationEnd() { Elements.tabs.removeEventListener("animationend", onAnimationEnd); @@ -502,9 +497,9 @@ var BrowserUI = { } this.setOnTabAnimationEnd(function() { - Browser.closeTab(tabToClose, { forceClose: true } ); - if (wasCollapsed) - ContextUI.dismissTabsWithDelay(kNewTabAnimationDelayMsec); + Browser.closeTab(tabToClose, { forceClose: true } ); + if (wasCollapsed) + ContextUI.dismissTabsWithDelay(kNewTabAnimationDelayMsec); }); }, @@ -546,7 +541,7 @@ var BrowserUI = { selectTabAndDismiss: function selectTabAndDismiss(aTab) { this.selectTab(aTab); - ContextUI.dismissTabs(); + ContextUI.dismissTabsWithDelay(kSelectTabAnimationDelayMsec); }, selectTabAtIndex: function selectTabAtIndex(aIndex) { @@ -1333,6 +1328,7 @@ var BrowserUI = { case "cmd_newTab": this.newTab(); this._editURI(false); + ContextUI.peekTabs(kNewTabAnimationDelayMsec); break; case "cmd_closeTab": this.closeTab();