+ Group.add now refuses to add a tab if it was already attached to another group, instead of just warning about it. Though maybe it should automatically remove it from the previous group?
authorIan Gilman <ian@iangilman.com>
Thu, 15 Jul 2010 17:23:39 -0700
changeset 50129 66afc21f704dc4cf3ae1290e166b3281185c34da
parent 50128 ba208978ccca7c02739e3bf6a13ab20c12e34abd
child 50131 011d19c78a50ada060f79281946e65132416fdf3
child 50135 c70c8f86bce6164344dbd4afc9528c0b520a4313
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)
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
+ Group.add now refuses to add a tab if it was already attached to another group, instead of just warning about it. Though maybe it should automatically remove it from the previous group? + Documentation updates
browser/base/content/tabcandy/app/groups.js
browser/base/content/tabcandy/app/items.js
browser/base/content/tabcandy/app/storage.js
--- a/browser/base/content/tabcandy/app/groups.js
+++ b/browser/base/content/tabcandy/app/groups.js
@@ -626,20 +626,20 @@ window.Group.prototype = iQ.extend(new I
       if (a.isAnItem) {
         item = a;
         $el = iQ(a.container);  
       } else {
         $el = iQ(a);
         item = Items.item($el);
       }
       
+      Utils.assertThrow('shouldn\'t already be in another group', !item.parent || item.parent == this);
+
       item.removeTrenches();
-      
-      Utils.assert('shouldn\'t already be in another group', !item.parent || item.parent == this);
-  
+        
       if (!dropPos) 
         dropPos = {top:window.innerWidth, left:window.innerHeight};
         
       if (typeof(options) == 'undefined')
         options = {};
         
       var self = this;
       
--- a/browser/base/content/tabcandy/app/items.js
+++ b/browser/base/content/tabcandy/app/items.js
@@ -303,17 +303,17 @@ window.Item.prototype = {
   // Rotates the object to the given number of degrees.
   setRotation: function(degrees) {
     var value = "rotate(%deg)".replace(/%/, degrees);
     iQ(this.container).css({"-moz-transform": value});
   },
     
   // ----------
   // Function: setParent
-  //
+  // Sets the receiver's parent to the given <Item>. 
   setParent: function(parent) {
     this.parent = parent;
     this.removeTrenches();
     this.save();
   },
 
   // ----------  
   // Function: pushAway
--- a/browser/base/content/tabcandy/app/storage.js
+++ b/browser/base/content/tabcandy/app/storage.js
@@ -34,16 +34,18 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 // **********
 // Title: storage.js 
 
 // ##########
+// Class: Storage
+// Singleton for permanent storage of TabCandy data. 
 Storage = {
   GROUP_DATA_IDENTIFIER:  "tabcandy-group",
   GROUPS_DATA_IDENTIFIER: "tabcandy-groups",
   TAB_DATA_IDENTIFIER:    "tabcandy-tab",
   UI_DATA_IDENTIFIER:    "tabcandy-ui",
   VISIBILITY_DATA_IDENTIFIER:    "tabcandy-visibility",
 
   // ----------
@@ -80,23 +82,27 @@ Storage = {
           observer, "browser-delayed-startup-finished", false);
       }
     } catch(e) {
       Utils.log(e);
     }  
   },
 
   // ----------
+  // Function: init
+  // Sets up the object. 
   init: function() {
     this._sessionStore =
       Components.classes["@mozilla.org/browser/sessionstore;1"]
         .getService(Components.interfaces.nsISessionStore);
   },
 
   // ----------
+  // Function: wipe
+  // Cleans out all the stored data, leaving empty objects. 
   wipe: function() {
     try {
       var win = Utils.getCurrentWindow();
       
       var self = this;
       
       // ___ Tabs
       Tabs.forEach(function(tab) {
@@ -111,24 +117,28 @@ Storage = {
       this._sessionStore.setWindowValue(win, this.GROUP_DATA_IDENTIFIER,
         JSON.stringify({}));
     } catch (e) {
       Utils.log("Error in wipe: "+e);
     }
   },
   
   // ----------
+  // Function: saveTab
+  // Saves the data for a single tab. 
   saveTab: function(tab, data) {
     Utils.assert('tab', tab);
 
     this._sessionStore.setTabValue(tab, this.TAB_DATA_IDENTIFIER,
       JSON.stringify(data));
   },
 
   // ----------
+  // Function: getTabData
+  // Returns the data object associated with a single tab.
   getTabData: function(tab) {
     Utils.assert('tab', tab);
 
     var existingData = null;
     try {
 /*         Utils.log("readTabData: " + this._sessionStore.getTabValue(tab, this.TAB_DATA_IDENTIFIER)); */
       var tabData = this._sessionStore.getTabValue(tab, this.TAB_DATA_IDENTIFIER);
       if (tabData != "") {
@@ -139,98 +149,121 @@ Storage = {
       Utils.log(e);
     }
     
 /*     Utils.log('tab', existingData); */
     return existingData;
   },
 
   // ----------
+  // Function: saveGroup
+  // Saves the data for a single group, associated with a specific window. 
   saveGroup: function(win, data) {
     var id = data.id;
     var existingData = this.readGroupData(win);
     existingData[id] = data;
     this._sessionStore.setWindowValue(win, this.GROUP_DATA_IDENTIFIER,
       JSON.stringify(existingData));
   },
 
   // ----------
+  // Function: deleteGroup
+  // Deletes the data for a single group from the given window.
   deleteGroup: function(win, id) {
     var existingData = this.readGroupData(win);
     delete existingData[id];
     this._sessionStore.setWindowValue(win, this.GROUP_DATA_IDENTIFIER,
       JSON.stringify(existingData));
   },
 
   // ----------
+  // Function: readGroupData
+  // Returns the data for all groups associated with the given window.
   readGroupData: function(win) {
     var existingData = {};
     try {
 /*         Utils.log("readGroupData" + this._sessionStore.getWindowValue(win, this.GROUP_DATA_IDENTIFIER)); */
       existingData = JSON.parse(
         this._sessionStore.getWindowValue(win, this.GROUP_DATA_IDENTIFIER)
       );
     } catch (e) {
       // getWindowValue will fail if the property doesn't exist
       Utils.log("Error in readGroupData: "+e);
     }
     return existingData;
   },
 
   // ----------
+  // Function: saveGroupsData
+  // Saves the global data for the <Groups> singleton for the given window.  
   saveGroupsData: function(win, data) {
     this.saveData(win, this.GROUPS_DATA_IDENTIFIER, data);
   },
 
   // ----------
+  // Function: readGroupsData
+  // Reads the global data for the <Groups> singleton for the given window.  
   readGroupsData: function(win) {
     return this.readData(win, this.GROUPS_DATA_IDENTIFIER);
   },
   
   // ----------
+  // Function: saveUIData
+  // Saves the global data for the <UIClass> singleton for the given window.  
   saveUIData: function(win, data) {
     this.saveData(win, this.UI_DATA_IDENTIFIER, data);
   },
 
   // ----------
+  // Function: readUIData
+  // Reads the global data for the <UIClass> singleton for the given window.  
   readUIData: function(win) {
     return this.readData(win, this.UI_DATA_IDENTIFIER);
   },
 
   // ----------
+  // Function: saveVisibilityData
+  // TODO: fold into saveUIData
   saveVisibilityData: function(win, data) {
     this.saveData(win, this.VISIBILITY_DATA_IDENTIFIER, data);
   },
 
   // ----------
+  // Function: readVisibilityData
+  // TODO: fold into readUIData
   readVisibilityData: function(win) {
     return this.readData(win, this.VISIBILITY_DATA_IDENTIFIER);
   },
     
   // ----------
+  // Function: saveData
+  // Generic routine for saving data to a window. 
   saveData: function(win, id, data) {
     try {
       this._sessionStore.setWindowValue(win, id, JSON.stringify(data));
     } catch (e) {
       Utils.log("Error in saveData: "+e);
     }
     
 /*     Utils.log('save data', id, data); */
   },
 
   // ----------
+  // Function: readData
+  // Generic routine for reading data from a window. 
   readData: function(win, id) {
     var existingData = {};
     try {
       var data = this._sessionStore.getWindowValue(win, id);
       if (data)
         existingData = JSON.parse(data);
     } catch (e) {
       Utils.log("Error in readData: "+e);
     }
     
 /*     Utils.log('read data', id, existingData); */
     return existingData;
   }
 };
 
+// ----------
 Storage.init();