Bug 851344 - Extend the duration of the tab bar showing when the user opens a link in a new tab r=mbrubeck
authorRodrigo Silveira <rsilveira@mozilla.com>
Fri, 12 Jul 2013 17:12:46 -0700
changeset 138540 0a117a4e10a0a4b432238477725fbfa3ba8a54da
parent 138539 638ccf9872d8aca1569fe56d5565906990b184f2
child 138541 9844a9e9c9c43be476d335f4bbe2525a07f635f2
push id24961
push useremorley@mozilla.com
push dateTue, 16 Jul 2013 08:58:21 +0000
treeherdermozilla-central@41ed26826acb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs851344
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 851344 - Extend the duration of the tab bar showing when the user opens a link in a new tab r=mbrubeck
browser/metro/base/content/ContextCommands.js
browser/metro/base/content/ContextUI.js
browser/metro/base/content/browser-ui.js
--- a/browser/metro/base/content/ContextCommands.js
+++ b/browser/metro/base/content/ContextCommands.js
@@ -156,17 +156,17 @@ var ContextCommands = {
     aRichListItem.setAttribute("searchString", "");
     BrowserUI.newTab(defaultURI, Browser.selectedTab);
   },
 
   // Link specific
 
   openLinkInNewTab: function cc_openLinkInNewTab() {
     Browser.addTab(ContextMenuUI.popupState.linkURL, false, Browser.selectedTab);
-    ContextUI.peekTabs();
+    ContextUI.peekTabs(kOpenInNewTabAnimationDelayMsec);
   },
 
   copyLink: function cc_copyLink() {
     this.clipboard.copyString(ContextMenuUI.popupState.linkURL,
                               this.docRef);
   },
 
   bookmarkLink: function cc_bookmarkLink() {
--- a/browser/metro/base/content/ContextUI.js
+++ b/browser/metro/base/content/ContextUI.js
@@ -5,22 +5,16 @@
 // Fired when any context ui is displayed
 const kContextUIShowEvent = "MozContextUIShow";
 // Fired when any context ui is dismissed
 const kContextUIDismissEvent = "MozContextUIDismiss";
 // Fired when the tabtray is displayed
 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.
  */
 var ContextUI = {
   _expandable: true,
   _hidingId: 0,
 
@@ -155,63 +149,46 @@ var ContextUI = {
     }
 
     return dismissed;
   },
 
   /*
    * 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();
     Elements.navbar.show();
   },
 
   // Display the tab tray
   displayTabs: function () {
     this._clearDelayedTimeout();
     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();
   },
 
   // Dismiss the tabstray if visible.
   dismissTabs: function dimissTabs() {
     this._clearDelayedTimeout();
@@ -307,25 +284,19 @@ var ContextUI = {
         break;
       case "KeyboardChanged":
         this.dismissTabs();
         break;
       case "mousedown":
         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();
         break;
     }
   },
 
   _fire: function (name) {
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -17,16 +17,23 @@ const TOOLBARSTATE_LOADED   = 2;
 
 // Page for which the start UI is shown
 const kStartOverlayURI = "about:start";
 
 // Devtools Messages
 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.
  */
 
 let Elements = {};
 [
   ["contentShowing",     "bcast_contentShowing"],
   ["urlbarState",        "bcast_urlbarState"],
@@ -460,31 +467,19 @@ var BrowserUI = {
 
   /*********************************
    * Tab management
    */
 
   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);
       aCallback();
     });
   },
 
   closeTab: function closeTab(aTab) {
@@ -497,19 +492,19 @@ var BrowserUI = {
     tabToClose.chromeTab.setAttribute("closing", "true");
 
     let wasCollapsed = !ContextUI.tabbarVisible;
     if (wasCollapsed) {
       ContextUI.displayTabs();
     }
 
     this.setOnTabAnimationEnd(function() {
-	    Browser.closeTab(tabToClose, { forceClose: true } );
-        if (wasCollapsed)
-          ContextUI.dismissTabsWithDelay(kNewTabAnimationDelayMsec);
+      Browser.closeTab(tabToClose, { forceClose: true } );
+      if (wasCollapsed)
+        ContextUI.dismissTabsWithDelay(kNewTabAnimationDelayMsec);
     });
   },
 
   /**
     * Re-open a closed tab.
     * @param aIndex
     *        The index of the tab (via nsSessionStore.getClosedTabData)
     * @returns a reference to the reopened tab.
@@ -541,17 +536,17 @@ var BrowserUI = {
   },
 
   selectTab: function selectTab(aTab) {
     Browser.selectedTab = aTab;
   },
 
   selectTabAndDismiss: function selectTabAndDismiss(aTab) {
     this.selectTab(aTab);
-    ContextUI.dismissTabs();
+    ContextUI.dismissTabsWithDelay(kSelectTabAnimationDelayMsec);
   },
 
   selectTabAtIndex: function selectTabAtIndex(aIndex) {
     // count backwards for aIndex < 0
     if (aIndex < 0)
       aIndex += Browser._tabs.length;
 
     if (aIndex >= 0 && aIndex < Browser._tabs.length)
@@ -1328,16 +1323,17 @@ var BrowserUI = {
         this._closeOrQuit();
         break;
       case "cmd_close":
         this._closeOrQuit();
         break;
       case "cmd_newTab":
         this.newTab();
         this._editURI(false);
+        ContextUI.peekTabs(kNewTabAnimationDelayMsec);
         break;
       case "cmd_closeTab":
         this.closeTab();
         break;
       case "cmd_undoCloseTab":
         this.undoCloseTab();
         break;
       case "cmd_sanitize":