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
This commit is contained in:
Rodrigo Silveira 2013-07-12 17:12:46 -07:00
parent 43fea69e3f
commit c732d5e32b
3 changed files with 20 additions and 53 deletions

View File

@ -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() {

View File

@ -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();

View File

@ -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();