+ Fixed: Quit Firefox with TabCandy open then open Firefox again. Your tabs and and navbar get hidden.
authorIan Gilman <iangilman@gmail.com>
Thu, 13 May 2010 15:14:08 -0700
changeset 49878 027686b05fe26175056e8886d0b39075d8a0510d
parent 49877 c8a649e0eb56ac045bb11fa9b76c22ea24c1a4cc
child 49879 c0eea763394f85c62300186a95911d0acf0a0a7b
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
+ Fixed: Quit Firefox with TabCandy open then open Firefox again. Your tabs and and navbar get hidden. + Fixed: If you quit tab candy (but not the browser), all of the tabs need to be reshown. + Starting firefox with tab candy selected now hides the tab bar + Utils.activeTab now returns a Tabs tab, rather than a raw tab
browser/base/content/tabcandy/app/ui.js
browser/base/content/tabcandy/core/tabs.js
browser/base/content/tabcandy/core/utils.js
--- a/browser/base/content/tabcandy/app/ui.js
+++ b/browser/base/content/tabcandy/app/ui.js
@@ -55,37 +55,47 @@ Navbar = {
 // ##########
 var Tabbar = {
   // ----------
   // Variable: _hidden
   // We keep track of whether the tabs are hidden in this (internal) variable
   // so we still have access to that information during the window's unload event,
   // when window.Tabs no longer exists.
   _hidden: false, 
+  
+  // ----------
   get el(){ return window.Tabs[0].raw.parentNode; },
+
+  // ----------
   height: window.Tabs[0].raw.parentNode.getBoundingClientRect().height,
+
+  // ----------
   hide: function(animate) {
     var self = this;
     this._hidden = true;
     
     if( animate == false ) speed = 0;
     else speed = 150;
     
     $(self.el).animate({"marginTop":-self.height}, speed, function(){
       self.el.collapsed = true;
     });
   },
+
+  // ----------
   show: function(animate) {
     this._hidden = false;
-
-    if( animate == false ) speed = 0;
-    else speed = 150;
-        
     this.el.collapsed = false;
-    $(this.el).animate({"marginTop":0}, speed);
+    
+    if(animate == false) {
+      $(this.el).css({"marginTop":0});
+    } else {
+      var speed = 150;
+      $(this.el).animate({"marginTop":0}, speed);
+    }
   },
   
   // ----------
   // Function: getVisibleTabs
   // Returns an array of the tabs which are currently visibible in the
   // tab bar.
   getVisibleTabs: function(){
     var visibleTabs = [];
@@ -130,18 +140,29 @@ var Tabbar = {
     // Show all of the tabs in the group and move them (in order)
     // that they appear in the group to the end of the tab strip.
     // This way the tab order is matched up to the group's thumbnail
     // order.
     visibleTabs.forEach(function(tab){
       tab.collapsed = false;
       Utils.activeWindow.gBrowser.moveTabTo(tab, UI.tabBar.el.children.length-1);
     });
-    
   },
+
+  // ----------
+  // Function: showAllTabs
+  // Shows all of the tabs in the tab bar.
+  showAllTabs: function(){
+    for( var i=0; i<UI.tabBar.el.children.length; i++ ){
+      var tab = UI.tabBar.el.children[i];
+      tab.collapsed = false;
+    }
+  },
+
+  // ----------
   get isHidden(){ return this._hidden; }
 }
 
 // ##########
 window.Page = {
   startX: 30, 
   startY: 70,
   
@@ -398,17 +419,17 @@ ArrangeClass.prototype = {
   }
 }
 
 // ##########
 function UIClass(){ 
   this.navBar = Navbar;
   this.tabBar = Tabbar;
   this.devMode = false;
-  this.focused = true;
+  this.focused = (Utils.activeTab == Utils.homeTab);
   
   var self = this;
   
   // ___ URL Params
   var params = document.location.search.replace('?', '').split('&');
   $.each(params, function(index, param) {
     var parts = param.split('=');
     if(parts[0] == 'dev' && parts[1] == '1') 
@@ -418,17 +439,20 @@ function UIClass(){
   // ___ Dev Mode
   if(this.devMode) {
     Switch.insert('body', '');
     $('<br><br>').appendTo("#actions");
     this._addArrangements();
   }
   
   // ___ Navbar
-  this.navBar.hide();
+  if(this.focused) {
+    this.tabBar.hide();
+    this.navBar.hide();
+  }
   
   Tabs.onFocus(function() {
     try{
       if(this.contentWindow.location.host == "tabcandy") {
         self.focused = true;
         self.navBar.hide();
       } else {
         self.focused = false;
@@ -459,16 +483,19 @@ function UIClass(){
   }
    
   Groups.reconstitute(data.groups);
   TabItems.reconstitute(data.tabs);
   
   $(window).bind('beforeunload', function() {
     if(self.initialized) 
       self.save();
+      
+    self.tabBar.show();    
+    self.tabBar.showAllTabs();
   });
   
   // ___ resizing
   if(data.pageBounds) {
     this.pageBounds = data.pageBounds;
     this.resize();
   } else 
     this.pageBounds = Items.getPageBounds();    
--- a/browser/base/content/tabcandy/core/tabs.js
+++ b/browser/base/content/tabcandy/core/tabs.js
@@ -314,16 +314,18 @@ function EventListenerMixIn(options) {
       listeners = null;
       if (options.observe)
         options.observe.removeEventListener(options.eventName,
                                             onEvent,
                                             options.useCapture);
     });
 }
 
+// Class: Tabs
+// Singelton for dealing with the actual tabs in the browser. 
 function Tabs() {
   var trackedWindows = new Dictionary();
   var trackedTabs = new Dictionary();
 
   var windows = {
     get focused() {
       var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
                .getService(Ci.nsIWindowMediator);
--- a/browser/base/content/tabcandy/core/utils.js
+++ b/browser/base/content/tabcandy/core/utils.js
@@ -305,30 +305,55 @@ window.Subscribable.prototype = {
   }
 };
 
 // ##########
 // Class: Utils
 // Singelton with common utility functions.
 var Utils = {
   // ___ Windows and Tabs
+
+  // ----------
+  // Variable: activeWindow
   get activeWindow(){
     var win = Cc["@mozilla.org/embedcomp/window-watcher;1"]
                .getService(Ci.nsIWindowWatcher)
                .activeWindow;
                
-    if( win != null ) return win;  
-    else return homeWindow;
+    if( win != null ) 
+      return win;  
+      
+    if(homeWindow != null)
+      return homeWindow;
+      
+    win = Cc["@mozilla.org/appshell/window-mediator;1"]
+      .getService(Components.interfaces.nsIWindowMediator)
+      .getMostRecentWindow("navigator:browser");
+
+    return win;
   },
   
+  // ----------
+  // Variable: activeTab
+  // The <Tabs> tab that represents the active tab in the active window.
   get activeTab(){
     var tabBrowser = this.activeWindow.gBrowser;
-    return tabBrowser.selectedTab;
+    var rawTab = tabBrowser.selectedTab;
+    for( var i=0; i<Tabs.length; i++){
+      if(Tabs[i].raw == rawTab)
+        return Tabs[i];
+    }
+    
+    return null;
   },
   
+  // ----------
+  // Variable: homeTab
+  // The <Tabs> tab that represents the tab candy tab.
+  // TODO: what if there are multiple tab candy tabs?
   get homeTab(){
     for( var i=0; i<Tabs.length; i++){
       if(Tabs[i].contentWindow.location.host == "tabcandy"){
         return Tabs[i];
       }
     }
     
     return null;