Bug 840913 - Remove use of nsISupportsArray in Calendar's treeview implementation. r=philipp
authorMatthew Mecca <matthew.mecca@gmail.com>
Sat, 09 Mar 2013 16:18:40 -0500
changeset 15104 324320ba7679363ed9bc2005d14c0373ab162a89
parent 15103 7a679f849f6564caa010f3d942e11b44dcf59d9f
child 15105 68a3857fbcabe1280c4132a5561de8653088f84b
push id898
push userbugzilla@standard8.plus.com
push dateMon, 13 May 2013 17:03:31 +0000
treeherdercomm-beta@3106694b14de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs840913
Bug 840913 - Remove use of nsISupportsArray in Calendar's treeview implementation. r=philipp
calendar/base/content/calendar-task-tree.xml
calendar/base/content/calendar-unifinder.js
calendar/base/content/widgets/calendar-list-tree.xml
--- a/calendar/base/content/calendar-task-tree.xml
+++ b/calendar/base/content/calendar-task-tree.xml
@@ -489,59 +489,57 @@
           get rowCount() {
               return this.binding.mTaskArray.length;
           },
 
           // TODO this code is currently identical to the unifinder. We should
           // create an itemTreeView that these tree views can inherit, that
           // contains this code, and possibly other code related to sorting and
           // storing items. See bug 432582 for more details.
-          getCellProperties: function mTV_getCellProperties(aRow, aCol, aProps) {
-              this.getRowProperties(aRow, aProps);
-              this.getColumnProperties(aCol, aProps);
+          getCellProperties: function mTV_getCellProperties(aRow, aCol) {
+              let rowProps = this.getRowProperties(aRow);
+              let colProps = this.getColumnProperties(aCol);
+              return rowProps + (rowProps && colProps ? " " : "") + colProps;
           },
 
           // Called to get properties to paint a column background.
           // For shading the sort column, etc.
-          getColumnProperties: function mTV_getColumnProperties(aCol, aProps) {
-              if (aCol.element.hasAttribute("anonid")) {
-                  aProps.AppendElement(getAtomFromService(aCol.element.getAttribute("anonid")));
-              }
+          getColumnProperties: function mTV_getColumnProperties(aCol) {
+              return aCol.element.getAttribute("anonid") || "";
           },
 
-          getRowProperties: function mTV_getRowProperties(aRow, aProps) {
-              var item = this.binding.mTaskArray[aRow];
+          getRowProperties: function mTV_getRowProperties(aRow) {
+              let properties = [];
+              let item = this.binding.mTaskArray[aRow];
               if (item.priority > 0 && item.priority < 5) {
-                  aProps.AppendElement(getAtomFromService("highpriority"));
+                  properties.push("highpriority");
               } else if (item.priority > 5 && item.priority < 10) {
-                  aProps.AppendElement(getAtomFromService("lowpriority"));
+                  properties.push("lowpriority");
               }
-              aProps.AppendElement(getAtomFromService(getProgressAtom(item)));
+              properties.push(getProgressAtom(item));
 
               // Add calendar name and id atom
-              var calendarNameAtom = "calendar-" + formatStringForCSSRule(item.calendar.name);
-              var calendarIdAtom = "calendarid-" +  formatStringForCSSRule(item.calendar.id);
-              aProps.AppendElement(getAtomFromService(calendarNameAtom));
-              aProps.AppendElement(getAtomFromService(calendarIdAtom));
+              properties.push("calendar-" + formatStringForCSSRule(item.calendar.name));
+              properties.push("calendarid-" +  formatStringForCSSRule(item.calendar.id));
 
               // Add item status atom
               if (item.status) {
-                  aProps.AppendElement(getAtomFromService("status-" + item.status.toLowerCase()));
+                  properties.push("status-" + item.status.toLowerCase());
               }
 
               // Alarm status atom
               if (item.getAlarms({}).length) {
-                  aProps.AppendElement(getAtomFromService("alarm"));
+                  properties.push("alarm");
               }
 
               // Task categories
-              var categories = item.getCategories({});
-              categories.map(formatStringForCSSRule)
-                        .map(getAtomFromService)
-                        .forEach(aProps.AppendElement, aProps);
+              properties = properties.concat(item.getCategories({})
+                                                 .map(formatStringForCSSRule));
+
+              return properties.join(" ");
           },
 
           // Called on the view when a cell in a non-selectable cycling
           // column (e.g., unread/flag/etc.) is clicked.
           cycleCell: function mTV_cycleCell(aRow, aCol) {
               var task = this.binding.mTaskArray[aRow];
 
               // prevent toggling completed status for parent items of repeating tasks
--- a/calendar/base/content/calendar-unifinder.js
+++ b/calendar/base/content/calendar-unifinder.js
@@ -670,48 +670,50 @@ var unifinderTreeView = {
         return this.eventArray.length;
     },
 
 
     // TODO this code is currently identical to the task tree. We should create
     // an itemTreeView that these tree views can inherit, that contains this
     // code, and possibly other code related to sorting and storing items. See
     // bug 432582 for more details.
-    getCellProperties: function uTV_getCellProperties(aRow, aCol, aProps) {
-        this.getRowProperties(aRow, aProps);
-        this.getColumnProperties(aCol, aProps);
+    getCellProperties: function uTV_getCellProperties(aRow, aCol) {
+        let rowProps = this.getRowProperties(aRow);
+        let colProps = this.getColumnProperties(aCol);
+        return rowProps + (rowProps && colProps ? " " : "") + colProps;
     },
-    getRowProperties: function uTV_getRowProperties(aRow, aProps) {
+    getRowProperties: function uTV_getRowProperties(aRow) {
+        let properties = [];
         let item = this.eventArray[aRow];
         if (item.priority > 0 && item.priority < 5) {
-            aProps.AppendElement(getAtomFromService("highpriority"));
+            properties.push("highpriority");
         } else if (item.priority > 5 && item.priority < 10) {
-            aProps.AppendElement(getAtomFromService("lowpriority"));
+            properties.push("lowpriority");
         }
 
         // Add calendar name atom
-        let calendarAtom = "calendar-" + formatStringForCSSRule(item.calendar.name);
-        aProps.AppendElement(getAtomFromService(calendarAtom));
+        properties.push("calendar-" + formatStringForCSSRule(item.calendar.name));
 
         // Add item status atom
         if (item.status) {
-            aProps.AppendElement(getAtomFromService("status-" + item.status.toLowerCase()));
+            properties.push("status-" + item.status.toLowerCase());
         }
 
         // Alarm status atom
         if (item.getAlarms({}).length) {
-            aProps.AppendElement(getAtomFromService("alarm"));
+            properties.push("alarm");
         }
 
         // Task categories
-        item.getCategories({}).map(formatStringForCSSRule)
-                              .map(getAtomFromService)
-                              .forEach(aProps.AppendElement, aProps);
+        properties = properties.concat(item.getCategories({})
+                                           .map(formatStringForCSSRule));
+
+        return properties.join(" ");
     },
-    getColumnProperties: function uTV_getColumnProperties(aCol, aProps) {},
+    getColumnProperties: function uTV_getColumnProperties(aCol) "",
 
     isContainer: function uTV_isContainer() {
         return false;
     },
 
     isContainerOpen: function uTV_isContainerOpen(aRow) {
         return false;
     },
--- a/calendar/base/content/widgets/calendar-list-tree.xml
+++ b/calendar/base/content/widgets/calendar-list-tree.xml
@@ -616,83 +616,74 @@
       <!-- Implement nsITreeView -->
       <property name="rowCount"
                 readonly="true"
                 onget="return this.mCalendarList.length"/>
 
       <method name="getCellProperties">
         <parameter name="aRow"/>
         <parameter name="aCol"/>
-        <parameter name="aProps"/>
         <body><![CDATA[
           try {
-              this.getRowProperties(aRow, aProps);
-              this.getColumnProperties(aCol, aProps);
+              let rowProps = this.getRowProperties(aRow);
+              let colProps = this.getColumnProperties(aCol);
+              return rowProps + (rowProps && colProps ? " " : "") + colProps;
           } catch (e) {
               // It seems errors in these functions are not shown, do this
               // explicitly.
               cal.ERROR("Error getting cell props: " + e);
           }
         ]]></body>
       </method>
 
       <method name="getRowProperties">
         <parameter name="aRow"/>
-        <parameter name="aProps"/>
         <body><![CDATA[
+          let properties = [];
           let calendar = this.getCalendar(aRow);
           let composite = this.compositeCalendar;
 
           // Set up the composite calendar status
-          if (composite.getCalendarById(calendar.id)) {
-              aProps.AppendElement(cal.getAtomFromService("checked"));
-          } else {
-              aProps.AppendElement(cal.getAtomFromService("unchecked"));
-          }
+          properties.push(composite.getCalendarById(calendar.id) ? "checked" : "unchecked");
 
           // Set up the calendar id
-          aProps.AppendElement(cal.getAtomFromService("id-" + calendar.id));
+          properties.push("id-" + calendar.id);
 
           // Get the calendar color
           let color = (calendar.getProperty("color") || "").substr(1);
 
           // Set up the calendar color (background)
-          let bgColorProp = "color-" + (color || "default");
-          aProps.AppendElement(cal.getAtomFromService(bgColorProp));
+          properties.push("color-" + (color || "default"));
 
           // Set a property to get the contrasting text color (foreground)
-          let fgColorProp = cal.getContrastingTextColor(color || "a8c2e1");
-          aProps.AppendElement(cal.getAtomFromService(fgColorProp));
+          properties.push(cal.getContrastingTextColor(color || "a8c2e1"));
 
           let currentStatus = calendar.getProperty("currentStatus");
           if (!Components.isSuccessCode(currentStatus)) {
               // 'readfailed' is supposed to "win" over 'readonly', meaning that
               // if reading from a calendar fails there is no further need to also display
               // information about 'readonly' status
-              aProps.AppendElement(cal.getAtomFromService("readfailed"));
+              properties.push("readfailed");
           } else if (calendar.readOnly) {
-              aProps.AppendElement(cal.getAtomFromService("readonly"));
+              properties.push("readonly");
           }
 
           // Set up the disabled state
-          if (!this.ignoreDisabledState && calendar.getProperty("disabled")) {
-              aProps.AppendElement(cal.getAtomFromService("disabled"));
-          } else {
-              aProps.AppendElement(cal.getAtomFromService("enabled"));
-          }
+          properties.push(!this.ignoreDisabledState && calendar.getProperty("disabled") ?
+                          "disabled" : "enabled");
+
+          return properties.join(" ");
         ]]></body>
       </method>
 
       <method name="getColumnProperties">
         <parameter name="aCol"/>
-        <parameter name="aProps"/>
         <body><![CDATA[
           // Workaround for anonymous treecols
-          let colAtom = cal.getAtomFromService(aCol.element.getAttribute("anonid"));
-          aProps.AppendElement(colAtom);
+          return aCol.element.getAttribute("anonid");
         ]]></body>
       </method>
 
       <method name="isContainer">
         <parameter name="aRow"/>
         <body><![CDATA[
           return false;
         ]]></body>