Bug 577445: Show tab candy title in the tab candy interface and change 'let' to 'var'
authorRaymond Lee <raymond@appcoast.com>
Thu, 15 Jul 2010 16:41:08 +0800
changeset 50127 f9b9fde4345780f6aed0f1209263c534c4b8c17e
parent 50126 0acf67333c04def877fed34cb79c87170881f98c
child 50128 ba208978ccca7c02739e3bf6a13ab20c12e34abd
push id15039
push useredward.lee@engineering.uiuc.edu
push dateThu, 12 Aug 2010 19:47:36 +0000
treeherdermozilla-central@5da28c582cc7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs577445
milestone2.0b2pre
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 577445: Show tab candy title in the tab candy interface and change 'let' to 'var'
browser/base/content/browser-tabcandy.js
browser/base/content/tabbrowser.xml
browser/base/content/tabcandy/app/drag.js
browser/base/content/tabcandy/app/groups.js
browser/base/content/tabcandy/app/items.js
browser/base/content/tabcandy/app/tabitems.js
browser/base/content/tabcandy/app/trench.js
browser/base/content/tabcandy/app/ui.js
browser/base/content/tabcandy/core/utils.js
browser/locales/en-US/chrome/browser/browser.properties
--- a/browser/base/content/browser-tabcandy.js
+++ b/browser/base/content/browser-tabcandy.js
@@ -56,10 +56,16 @@ var TabCandy = {
     let length = gBrowser.tabs.length;
 
     for (let i = 0; i < length; i++) {
       if (!gBrowser.tabs[i].collapsed) {
         visibleTabs.push(gBrowser.tabs[i]);
       } 
     }
     return visibleTabs;
+  },
+  
+  getWindowTitle: function() {
+    var brandBundle = document.getElementById("bundle_brand");
+    var brandShortName = brandBundle.getString("brandShortName");
+    return gNavigatorBundle.getFormattedString("tabCandy.title", [brandShortName]);
   }
 };
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -710,17 +710,22 @@
             return newTitle;
           ]]>
         </body>
       </method>
 
       <method name="updateTitlebar">
         <body>
           <![CDATA[
-            this.ownerDocument.title = this.getWindowTitleForBrowser(this.mCurrentBrowser);
+            if (TabCandy.isVisible()) {
+              // ToDo: this will be removed when we gain ability to draw o the menu bar. 
+              this.ownerDocument.title = TabCandy.getWindowTitle();
+            } else {
+              this.ownerDocument.title = this.getWindowTitleForBrowser(this.mCurrentBrowser);
+            }
           ]]>
         </body>
       </method>
 
       <method name="updateCurrentBrowser">
         <parameter name="aForceUpdate"/>
         <body>
           <![CDATA[
--- a/browser/base/content/tabcandy/app/drag.js
+++ b/browser/base/content/tabcandy/app/drag.js
@@ -136,18 +136,18 @@ Drag.prototype = {
     newRect = this.snapToEdge(bounds,stationaryCorner,assumeConstantSize,keepProportional);
     if (newRect) {
       update = true;
       bounds = newRect;
       iQ.extend(snappedTrenches,newRect.snappedTrenches);
     }
 
     Trenches.hideGuides();
-    for (let edge in snappedTrenches) {
-      let trench = snappedTrenches[edge];
+    for (var edge in snappedTrenches) {
+      var trench = snappedTrenches[edge];
       if (typeof trench == 'object') {
         trench.showGuide = true;
         trench.show();
       } else if (trench === 'edge') {
         // show the edge...?
       }
     }
 
--- a/browser/base/content/tabcandy/app/groups.js
+++ b/browser/base/content/tabcandy/app/groups.js
@@ -905,17 +905,17 @@ window.Group.prototype = iQ.extend(new I
         this.yDensity = (rects[rects.length - 1].bottom - bb.top) / (bb.height);
 
         // xDensity = (the distance from the left of the content area to the right of the rightmost
         // tab) / (the total available content width)
         
         // first, find the right of the rightmost tab! luckily, they're in order.
         // TODO: does this change for rtl?
         var rightMostRight = 0;
-        for each (let rect in rects) {
+        for each (var rect in rects) {
           if (rect.right > rightMostRight)
             rightMostRight = rect.right;
           else
             break;
         }
         this.xDensity = (rightMostRight - bb.left) / (bb.width);
         
         this._children.forEach(function(child, index) {
--- a/browser/base/content/tabcandy/app/items.js
+++ b/browser/base/content/tabcandy/app/items.js
@@ -546,21 +546,21 @@ window.Item.prototype = {
     Trenches.getById(gT.bottom).setWithRect(rect);
 
   },
   
   // ----------
   // Function: removeTrenches
   // Removes the trenches for snapping to this item.
   removeTrenches: function() {
-    for (let edge in this.borderTrenches) {
+    for (var edge in this.borderTrenches) {
       Trenches.unregister(this.borderTrenches[edge]); // unregister can take an array
     }
     this.borderTrenches = null;
-    for (let edge in this.guideTrenches) {
+    for (var edge in this.guideTrenches) {
       Trenches.unregister(this.guideTrenches[edge]); // unregister can take an array
     }
     this.guideTrenches = null;
   },
   
   // ----------
   // Function: snap
   // The snap function used during group creation via drag-out
--- a/browser/base/content/tabcandy/app/tabitems.js
+++ b/browser/base/content/tabcandy/app/tabitems.js
@@ -710,17 +710,17 @@ window.TabItems = {
                   Components.interfaces.nsIWebProgressListener.STATE_IS_WINDOW) {
                   iQ.timeout(function() {
                     if (!hidPlaceholder) {
                       hidPlaceholder = true;
                       hidePlaceholder();
                     }
                   }, 100);
 
-                  rawtab.linkedBrowser.removeProgressListener(webProgress);
+                  rawTab.linkedBrowser.removeProgressListener(webProgress);
                 }
               }
             },
           
             onLocationChange: function(aProgress, aRequest, aURI) { },
             onProgressChange: function(
               aWebProgress, aRequest, curSelf, maxSelf, curTot, maxTot) { },
             onStatusChange: function(
--- a/browser/base/content/tabcandy/app/trench.js
+++ b/browser/base/content/tabcandy/app/trench.js
@@ -576,17 +576,17 @@ var Trenches = {
       return;
     
     var updated = false;
     var updatedX = false;
     var updatedY = false;
 
     var snappedTrenches = {};
 
-    for (let i in this.trenches) {
+    for (var i in this.trenches) {
       var t = this.trenches[i];
       if (!t.active)
         continue;
       // newRect will be a new rect, or false
       var newRect = t.rectOverlaps(rect,stationaryCorner,assumeConstantSize,keepProportional);
 
       if (newRect) { // if rectOverlaps returned an updated rect...
       
--- a/browser/base/content/tabcandy/app/ui.js
+++ b/browser/base/content/tabcandy/app/ui.js
@@ -44,17 +44,17 @@
 (function(){
 
 window.Keys = {meta: false};
 
 // ##########
 Navbar = {
   // ----------
   get urlBar() {
-    let win = Utils.getCurrentWindow();
+    var win = Utils.getCurrentWindow();
     if (win)
       return win.gURLBar;
     return null;
   }
 };
 
 // ##########
 // Class: Tabbar
@@ -64,34 +64,34 @@ var Tabbar = {
   get el() {
     return window.Tabs[0].raw.parentNode; 
   },
   
   // ----------
   // Function: getVisibleTabCount
   // Returns the number of tabs that are currently visible
   getVisibleTabCount: function(){
-    let visibleTabCount = 0;
+    var visibleTabCount = 0;
     this.getAllTabs().forEach(function(tab){
       if ( !tab.collapsed )
         visibleTabCount++
     });
     return visibleTabCount;
   },
   
   // ----------
   // Function: getAllTabs
   // Returns an array of all tabs which exist in the current window
   // tabbrowser. Returns an Array.
   getAllTabs: function() {
-    let tabBarTabs = [];
+    var tabBarTabs = [];
     if (this.el) {
       // this.el.children is not a real array and does contain
       // useful functions like filter or forEach. Convert it into a real array.
-      for (let i = 0; i < this.el.children.length; i++) {
+      for (var i = 0; i < this.el.children.length; i++) {
         tabBarTabs.push(this.el.children[i]);
       }
     }
     return tabBarTabs;
   },
   
   // ----------
   // Function: showOnlyTheseTabs
@@ -155,68 +155,70 @@ window.Page = {
   stopZoomPreparation: false,
     
   isTabCandyVisible: function(){
     return (Utils.getCurrentWindow().document.getElementById("tab-candy-deck").
              selectedIndex == 1);
   },
   
   hideChrome: function(){
-    let currentWin = Utils.getCurrentWindow();
-    currentWin.document.getElementById("tab-candy-deck").selectedIndex = 1;    
+    var currentWin = Utils.getCurrentWindow();
+    currentWin.document.getElementById("tab-candy-deck").selectedIndex = 1;
     
+    currentWin.gBrowser.updateTitlebar();
     this._setActiveTitleColor(true);
   },
     
   showChrome: function(){
-    let currentWin = Utils.getCurrentWindow();
-    let tabContainer = currentWin.gBrowser.tabContainer;
+    var currentWin = Utils.getCurrentWindow();
+    var tabContainer = currentWin.gBrowser.tabContainer;
     currentWin.document.getElementById("tab-candy-deck").selectedIndex = 0;
     
     // set the close button on tab
 /*     iQ.timeout(function() { // Marshal event from chrome thread to DOM thread    */
       tabContainer.adjustTabstrip();
 /*     }, 1); */
 
+    currentWin.gBrowser.updateTitlebar();
     this._setActiveTitleColor(false);
   },
 
   _setActiveTitleColor: function(set) {
     // Mac Only
     if (Utils.isMac()) {
-      let mainWindow =
+      var mainWindow =
         Utils.getCurrentWindow().document.getElementById("main-window");
       if (set)
         mainWindow.setAttribute("activetitlebarcolor", "#C4C4C4");
       else
         mainWindow.removeAttribute("activetitlebarcolor");
     }
   },
 
   showTabCandy: function() {
-    let self = this;
-    let currentTab = UI.currentTab;
-    let item = null;
+    var self = this;
+    var currentTab = UI.currentTab;
+    var item = null;
 
     if (currentTab && currentTab.mirror)
       item = TabItems.getItemByTabElement(currentTab.mirror.el);
 
     if (item) {
       // If there was a previous currentTab we want to animate
       // its mirror for the zoom out.
       // Note that we start the animation on the chrome thread.
 
       // Zoom out!
       item.zoomOut(function() {
         if (!currentTab.mirror) // if the tab's been destroyed
           item = null;
 
         self.setActiveTab(item);
 
-        let activeGroup = Groups.getActiveGroup();
+        var activeGroup = Groups.getActiveGroup();
         if ( activeGroup )
           activeGroup.setTopChild(item);
   
         window.Groups.setActiveGroup(null);
         UI.resize(true);
       });
     }
   },
@@ -279,17 +281,17 @@ window.Page = {
   },
     
   // ----------  
   init: function() {
     var self = this;
         
     // When you click on the background/empty part of TabCandy,
     // we create a new group.
-    let tabCandyContentDoc =
+    var tabCandyContentDoc =
       Utils.getCurrentWindow().document.getElementById("tab-candy").
         contentDocument;
     iQ(tabCandyContentDoc).mousedown(function(e){
       if ( e.originalTarget.id == "content" )
         Page.createGroupOnDrag(e)
     });
 
     this.setupKeyHandlers();
@@ -334,20 +336,20 @@ window.Page = {
     
     Tabs.onFocus(function() {
       self.tabOnFocus(this);
     });
   },
   
   // ----------  
   tabOnFocus: function(tab) {
-    let focusTab = tab;
-    let currentTab = UI.currentTab;
-    let currentWindow = Utils.getCurrentWindow();
-    let self = this;
+    var focusTab = tab;
+    var currentTab = UI.currentTab;
+    var currentWindow = Utils.getCurrentWindow();
+    var self = this;
     
     UI.currentTab = focusTab;
     // if the last visible tab has just been closed, don't show the chrome UI.
     if (this.isTabCandyVisible() && (this.closedLastVisibleTab || this.closedSelectedTabInTabCandy)) {
       this.closedLastVisibleTab = false;
       this.closedSelectedTabInTabCandy = false;
       return;      
     }
@@ -361,32 +363,32 @@ window.Page = {
     this.closedSelectedTabInTabCandy = false;
     
     iQ.timeout(function() { // Marshal event from chrome thread to DOM thread      
       // this value is true when tabcandy is open at browser startup.
       if (Page.stopZoomPreparation) {
         self.stopZoomPreparation = false;
         return;
       }
-      let visibleTabCount = Tabbar.getVisibleTabCount();
+      var visibleTabCount = Tabbar.getVisibleTabCount();
  
       if (focusTab != UI.currentTab) {
         // things have changed while we were in timeout
         return;
       }
        
-      let newItem = null;
+      var newItem = null;
       if (focusTab && focusTab.mirror)
         newItem = TabItems.getItemByTabElement(focusTab.mirror.el);
   
       if (newItem)
         Groups.setActiveGroup(newItem.parent);
 
       // ___ prepare for when we return to TabCandy
-      let oldItem = null;
+      var oldItem = null;
       if (currentTab && currentTab.mirror)
         oldItem = TabItems.getItemByTabElement(currentTab.mirror.el);
 
       if (newItem != oldItem) {
         if (oldItem)
           oldItem.setZoomPrep(false);
         
         // if the last visible tab is removed, don't set zoom prep because
@@ -637,17 +639,17 @@ UIClass.prototype = {
         if (self.showChrome)
           self.showChrome();  
           
         if (self.tabBar && self.tabBar.showAllTabs)
           self.tabBar.showAllTabs();
       });
       
       // ___ Page
-      let currentWindow = Utils.getCurrentWindow();
+      var currentWindow = Utils.getCurrentWindow();
       Page.init();
       
       currentWindow.addEventListener(
         "tabcandyshow", function() {
           Page.hideChrome();
           Page.showTabCandy();
         }, false);
         
@@ -669,24 +671,24 @@ UIClass.prototype = {
   },
 
   // ----------
   // Function: _delayInit
   // Called automatically by _secondaryInit once sessionstore is online. 
   _delayInit : function() {
     try {
       // ___ Storage
-      let currentWindow = Utils.getCurrentWindow();
+      var currentWindow = Utils.getCurrentWindow();
       
-      let data = Storage.readUIData(currentWindow);
+      var data = Storage.readUIData(currentWindow);
       this.storageSanity(data);
   
-      let groupsData = Storage.readGroupsData(currentWindow);
-      let firstTime = !groupsData || iQ.isEmptyObject(groupsData);
-      let groupData = Storage.readGroupData(currentWindow);
+      var groupsData = Storage.readGroupsData(currentWindow);
+      var firstTime = !groupsData || iQ.isEmptyObject(groupsData);
+      var groupData = Storage.readGroupData(currentWindow);
       Groups.reconstitute(groupsData, groupData);
   
       TabItems.init();
   
       if (firstTime) {
         var padding = 10;
         var infoWidth = 350;
         var infoHeight = 350;
@@ -698,17 +700,17 @@ UIClass.prototype = {
         box.width = Math.min(box.width * 0.667, pageBounds.width - (infoWidth + padding));
         box.height = box.height * 0.667;
         var options = {
           bounds: box
         };
   
         var group = new Group([], options); 
 
-        let items = TabItems.getItems();
+        var items = TabItems.getItems();
         items.forEach(function(item) {
           if (item.parent)
             item.parent.remove(item);
             
           group.add(item);
         });
         
         // ___ make info item
@@ -736,31 +738,31 @@ UIClass.prototype = {
       var self = this;
       iQ(window).resize(function() {
         self.resize();
       });
       
       // ___ show tab candy at startup
       var visibilityData = Storage.readVisibilityData(currentWindow);
       if (visibilityData && visibilityData.visible) {
-        let currentTab = UI.currentTab;
-        let item;
+        var currentTab = UI.currentTab;
+        var item;
 
         if (currentTab && currentTab.mirror) 
           item = TabItems.getItemByTabElement(currentTab.mirror.el);
           
         if (item)
           item.setZoomPrep(false);
         else
           Page.stopZoomPreparation = true;
 
         Page.hideChrome();
       } else
         Page.showChrome();        
-
+      
       // ___ setup observer to save canvas images
       Components.utils.import("resource://gre/modules/Services.jsm");
       var observer = {
         observe : function(subject, topic, data) {
           if (topic == "quit-application-requested") {
             if (Page.isTabCandyVisible()) {
               TabItems.saveAll(true);
               self.saveVisibility(true);
--- a/browser/base/content/tabcandy/core/utils.js
+++ b/browser/base/content/tabcandy/core/utils.js
@@ -480,17 +480,17 @@ var Utils = {
   // i.e. the window belonging to the active page's DOM "window" object.
   getCurrentWindow: function() {
     var wm = Cc["@mozilla.org/appshell/window-mediator;1"]
              .getService(Ci.nsIWindowMediator);
     var browserEnumerator = wm.getEnumerator("navigator:browser");
     while (browserEnumerator.hasMoreElements()) {
       var browserWin = browserEnumerator.getNext();
       var tabbrowser = browserWin.gBrowser;
-      let tabCandyContainer = browserWin.document.getElementById("tab-candy");
+      var tabCandyContainer = browserWin.document.getElementById("tab-candy");
       if (tabCandyContainer && tabCandyContainer.contentWindow == window) {
         return browserWin;
       }
     }
     
     return null;
   },
   
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -270,10 +270,13 @@ privateBrowsingNeverAsk=&Do not show thi
 # of tabs in the current browser window. It will always be 2 at least.
 # See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
 ctrlTab.showAll.label=;Show all #1 tabs
 
 # LOCALIZATION NOTE (addKeywordTitleAutoFill): %S will be replaced by the page's title
 # Used as the bookmark name when saving a keyword for a search field.
 addKeywordTitleAutoFill=Search %S
 
+# Tab Candy
+tabCandy.title=%S Tab Sets
+
 extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.name=Default
 extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.description=The default theme.