Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 254bffb

Browse files
author
Trevor Saunders
committed
bug 407956 - make nsITreeView not take a nsISupportsArray* r=neil, bz sr=neil
1 parent f757ba5 commit 254bffb

31 files changed

Lines changed: 203 additions & 358 deletions

File tree

accessible/tests/mochitest/treeview.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,16 @@ nsTreeView.prototype =
101101
var data = this.getDataForIndex(aRow);
102102
return data.value;
103103
},
104-
getRowProperties: function getRowProperties(aIndex, aProperties) {},
105-
getCellProperties: function getCellProperties(aIndex, aCol, aProperties)
104+
getRowProperties: function getRowProperties(aIndex) { return ""; },
105+
getCellProperties: function getCellProperties(aIndex, aCol)
106106
{
107107
if (!aCol.cycler)
108-
return;
108+
return "";
109109

110110
var data = this.getDataForIndex(aIndex);
111-
var atom = this.mCyclerStates[data.cyclerState];
112-
aProperties.AppendElement(atom);
111+
return this.mCyclerStates[data.cyclerState];
113112
},
114-
getColumnProperties: function getColumnProperties(aCol, aProperties) {},
113+
getColumnProperties: function getColumnProperties(aCol) { return ""; },
115114
getParentIndex: function getParentIndex(aRowIndex)
116115
{
117116
var info = this.getInfoByIndex(aRowIndex);
@@ -261,9 +260,9 @@ nsTreeView.prototype =
261260
},
262261

263262
mCyclerStates: [
264-
createAtom("cyclerState1"),
265-
createAtom("cyclerState2"),
266-
createAtom("cyclerState3")
263+
"cyclerState1",
264+
"cyclerState2",
265+
"cyclerState3"
267266
]
268267
};
269268

browser/base/content/pageinfo/pageInfo.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ pageInfoTreeView.prototype = {
103103
this.sortcol = treecol.index;
104104
},
105105

106-
getRowProperties: function(row, prop) { },
107-
getCellProperties: function(row, column, prop) { },
108-
getColumnProperties: function(column, prop) { },
106+
getRowProperties: function(row) { return ""; },
107+
getCellProperties: function(row, column) { return ""; },
108+
getColumnProperties: function(column) { return ""; },
109109
isContainer: function(index) { return false; },
110110
isContainerOpen: function(index) { return false; },
111111
isSeparator: function(index) { return false; },
@@ -151,21 +151,19 @@ const COPYCOL_IMAGE = COL_IMAGE_ADDRESS;
151151
var gMetaView = new pageInfoTreeView('metatree', COPYCOL_META_CONTENT);
152152
var gImageView = new pageInfoTreeView('imagetree', COPYCOL_IMAGE);
153153

154-
var atomSvc = Components.classes["@mozilla.org/atom-service;1"]
155-
.getService(Components.interfaces.nsIAtomService);
156-
gImageView._ltrAtom = atomSvc.getAtom("ltr");
157-
gImageView._brokenAtom = atomSvc.getAtom("broken");
158-
159-
gImageView.getCellProperties = function(row, col, props) {
154+
gImageView.getCellProperties = function(row, col) {
160155
var data = gImageView.data[row];
161156
var item = gImageView.data[row][COL_IMAGE_NODE];
157+
var props = "";
162158
if (!checkProtocol(data) ||
163159
item instanceof HTMLEmbedElement ||
164160
(item instanceof HTMLObjectElement && !item.type.startsWith("image/")))
165-
props.AppendElement(this._brokenAtom);
161+
props += "broken";
166162

167163
if (col.element.id == "image-address")
168-
props.AppendElement(this._ltrAtom);
164+
props += " ltr";
165+
166+
return props;
169167
};
170168

171169
gImageView.getCellText = function(row, column) {

browser/base/content/sanitizeDialog.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -804,9 +804,6 @@ var gContiguousSelectionTreeHelper = {
804804
*/
805805
_makeTreeView: function CSTH__makeTreeView(aProtoTreeView)
806806
{
807-
var atomServ = Cc["@mozilla.org/atom-service;1"].
808-
getService(Ci.nsIAtomService);
809-
810807
var view = aProtoTreeView;
811808
var that = this;
812809

@@ -837,28 +834,29 @@ var gContiguousSelectionTreeHelper = {
837834

838835
view._getCellProperties = view.getCellProperties;
839836
view.getCellProperties =
840-
function CSTH_View_getCellProperties(aRow, aCol, aProps)
837+
function CSTH_View_getCellProperties(aRow, aCol)
841838
{
842839
var grippyRow = that.getGrippyRow();
843840
if (aRow === grippyRow)
844-
aProps.AppendElement(atomServ.getAtom("grippyRow"));
845-
else if (aRow < grippyRow)
846-
this._getCellProperties(aRow, aCol, aProps);
847-
else
848-
this._getCellProperties(aRow - 1, aCol, aProps);
841+
return "grippyRow";
842+
if (aRow < grippyRow)
843+
return this._getCellProperties(aRow, aCol);
844+
845+
return this._getCellProperties(aRow - 1, aCol);
849846
};
850847

851848
view._getRowProperties = view.getRowProperties;
852849
view.getRowProperties =
853-
function CSTH_View_getRowProperties(aRow, aProps)
850+
function CSTH_View_getRowProperties(aRow)
854851
{
855852
var grippyRow = that.getGrippyRow();
856853
if (aRow === grippyRow)
857-
aProps.AppendElement(atomServ.getAtom("grippyRow"));
858-
else if (aRow < grippyRow)
859-
this._getRowProperties(aRow, aProps);
860-
else
861-
this._getRowProperties(aRow - 1, aProps);
854+
return "grippyRow";
855+
856+
if (aRow < grippyRow)
857+
return this._getRowProperties(aRow);
858+
859+
return this._getRowProperties(aRow - 1);
862860
};
863861

864862
view._getCellText = view.getCellText;

browser/base/content/sync/quota.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ let gUsageTreeView = {
218218
return this._collections.length;
219219
},
220220

221-
getRowProperties: function(index, properties) {},
222-
getCellProperties: function(row, col, properties) {},
223-
getColumnProperties: function(col, properties) {},
221+
getRowProperties: function(index) { return ""; },
222+
getCellProperties: function(row, col) { return ""; },
223+
getColumnProperties: function(col) { return ""; },
224224
isContainer: function(index) { return false; },
225225
isContainerOpen: function(index) { return false; },
226226
isContainerEmpty: function(index) { return false; },

browser/components/places/content/treeView.js

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,6 @@ function PlacesTreeView(aFlatList, aOnOpenFlatContainer, aController) {
2323
PlacesTreeView.prototype = {
2424
get wrappedJSObject() this,
2525

26-
_makeAtom: function PTV__makeAtom(aString) {
27-
return Cc["@mozilla.org/atom-service;1"].
28-
getService(Ci.nsIAtomService).
29-
getAtom(aString);
30-
},
31-
32-
_atoms: [],
33-
_getAtomFor: function PTV__getAtomFor(aName) {
34-
if (!this._atoms[aName])
35-
this._atoms[aName] = this._makeAtom(aName);
36-
37-
return this._atoms[aName];
38-
},
39-
4026
__dateService: null,
4127
get _dateService() {
4228
if (!this.__dateService) {
@@ -857,9 +843,8 @@ PlacesTreeView.prototype = {
857843
function (aStatus, aLivemark) {
858844
if (Components.isSuccessCode(aStatus)) {
859845
this._controller.cacheLivemarkInfo(aNode, aLivemark);
860-
let properties = this._cellProperties.get(aNode, null);
861-
if (properties)
862-
properties.push(this._getAtomFor("livemark"));
846+
let properties = this._cellProperties.get(aNode);
847+
this._cellProperties.set(aNode, properties += " livemark ");
863848

864849
// The livemark attribute is set as a cell property on the title cell.
865850
this._invalidateCellValue(aNode, this.COLUMN_TYPE_TITLE);
@@ -1134,57 +1119,58 @@ PlacesTreeView.prototype = {
11341119
get selection() this._selection,
11351120
set selection(val) this._selection = val,
11361121

1137-
getRowProperties: function() { },
1122+
getRowProperties: function() { return ""; },
11381123

11391124
getCellProperties:
1140-
function PTV_getCellProperties(aRow, aColumn, aProperties) {
1125+
function PTV_getCellProperties(aRow, aColumn) {
11411126
// for anonid-trees, we need to add the column-type manually
1127+
var props = "";
11421128
let columnType = aColumn.element.getAttribute("anonid");
11431129
if (columnType)
1144-
aProperties.AppendElement(this._getAtomFor(columnType));
1130+
props += columnType;
11451131
else
11461132
columnType = aColumn.id;
11471133

11481134
// Set the "ltr" property on url cells
11491135
if (columnType == "url")
1150-
aProperties.AppendElement(this._getAtomFor("ltr"));
1136+
props += " ltr";
11511137

11521138
if (columnType != "title")
1153-
return;
1139+
return props;
11541140

11551141
let node = this._getNodeForRow(aRow);
11561142

11571143
if (this._cuttingNodes.has(node)) {
1158-
aProperties.AppendElement(this._getAtomFor("cutting"));
1144+
props += " cutting";
11591145
}
11601146

1161-
let properties = this._cellProperties.get(node, null);
1162-
if (!properties) {
1163-
properties = [];
1147+
let properties = this._cellProperties.get(node);
1148+
if (properties === undefined) {
1149+
properties = "";
11641150
let itemId = node.itemId;
11651151
let nodeType = node.type;
11661152
if (PlacesUtils.containerTypes.indexOf(nodeType) != -1) {
11671153
if (nodeType == Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY) {
1168-
properties.push(this._getAtomFor("query"));
1154+
properties += " query";
11691155
if (PlacesUtils.nodeIsTagQuery(node))
1170-
properties.push(this._getAtomFor("tagContainer"));
1156+
properties += " tagContainer";
11711157
else if (PlacesUtils.nodeIsDay(node))
1172-
properties.push(this._getAtomFor("dayContainer"));
1158+
properties += " dayContainer";
11731159
else if (PlacesUtils.nodeIsHost(node))
1174-
properties.push(this._getAtomFor("hostContainer"));
1160+
properties += " hostContainer";
11751161
}
11761162
else if (nodeType == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER ||
11771163
nodeType == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT) {
11781164
if (this._controller.hasCachedLivemarkInfo(node)) {
1179-
properties.push(this._getAtomFor("livemark"));
1165+
properties += " livemark";
11801166
}
11811167
else {
11821168
PlacesUtils.livemarks.getLivemark(
11831169
{ id: node.itemId },
11841170
function (aStatus, aLivemark) {
11851171
if (Components.isSuccessCode(aStatus)) {
11861172
this._controller.cacheLivemarkInfo(node, aLivemark);
1187-
properties.push(this._getAtomFor("livemark"));
1173+
properties += " livemark";
11881174
// The livemark attribute is set as a cell property on the title cell.
11891175
this._invalidateCellValue(node, this.COLUMN_TYPE_TITLE);
11901176
}
@@ -1196,30 +1182,29 @@ PlacesTreeView.prototype = {
11961182
if (itemId != -1) {
11971183
let queryName = PlacesUIUtils.getLeftPaneQueryNameFromId(itemId);
11981184
if (queryName)
1199-
properties.push(this._getAtomFor("OrganizerQuery_" + queryName));
1185+
properties += " OrganizerQuery_" + queryName;
12001186
}
12011187
}
12021188
else if (nodeType == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR)
1203-
properties.push(this._getAtomFor("separator"));
1189+
properties += " separator";
12041190
else if (PlacesUtils.nodeIsURI(node)) {
1205-
properties.push(this._getAtomFor(PlacesUIUtils.guessUrlSchemeForUI(node.uri)));
1191+
properties += " " + PlacesUIUtils.guessUrlSchemeForUI(node.uri);
12061192

12071193
if (this._controller.hasCachedLivemarkInfo(node.parent)) {
1208-
properties.push(this._getAtomFor("livemarkItem"));
1194+
properties += " livemarkItem";
12091195
if (node.accessCount) {
1210-
properties.push(this._getAtomFor("visited"));
1196+
properties += " visited";
12111197
}
12121198
}
12131199
}
12141200

12151201
this._cellProperties.set(node, properties);
12161202
}
1217-
for (let property of properties) {
1218-
aProperties.AppendElement(property);
1219-
}
1203+
1204+
return props + " " + properties;
12201205
},
12211206

1222-
getColumnProperties: function(aColumn, aProperties) { },
1207+
getColumnProperties: function(aColumn) { return ""; },
12231208

12241209
isContainer: function PTV_isContainer(aRow) {
12251210
// Only leaf nodes aren't listed in the rows array.

browser/components/places/tests/chrome/test_0_bug510634.xul

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,7 @@
4343
4444
SimpleTest.waitForExplicitFinish();
4545
46-
function createSupportsArray() {
47-
return Cc["@mozilla.org/supports-array;1"].
48-
createInstance(Ci.nsISupportsArray);
49-
}
50-
5146
// converts nsISupportsArray of atoms to a simple JS-strings array
52-
function convertPropertiesToJSArray(aSupportsArray) {
53-
var results = [];
54-
var count = aSupportsArray.Count();
55-
for (var i = 0; i < count; i++)
56-
results.push(aSupportsArray.QueryElementAt(i, Ci.nsIAtom).toString());
57-
58-
return results;
59-
}
60-
6147
function runTest() {
6248
// We need to cache and restore this getter in order to simulate
6349
// Bug 510634
@@ -91,9 +77,7 @@
9177
function(aQueryName, aRow) {
9278
let found = false;
9379
for (let i = 0; i < tree.view.rowCount && !found; i++) {
94-
let rowProperties = createSupportsArray();
95-
tree.view.getCellProperties(i, titleColumn, rowProperties);
96-
rowProperties = convertPropertiesToJSArray(rowProperties);
80+
rowProperties = tree.view.getCellProperties(i, titleColumn).split(" ");
9781
found = rowProperties.indexOf("OrganizerQuery_" + aQueryName) != -1;
9882
}
9983
ok(found, "OrganizerQuery_" + aQueryName + " is set");

browser/components/preferences/cookies.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ var gCookiesWindow = {
307307
_selection: null,
308308
get selection () { return this._selection; },
309309
set selection (val) { this._selection = val; return val; },
310-
getRowProperties: function (aIndex, aProperties) {},
311-
getCellProperties: function (aIndex, aColumn, aProperties) {},
312-
getColumnProperties: function (aColumn, aProperties) {},
310+
getRowProperties: function (aIndex) { return ""; },
311+
getCellProperties: function (aIndex, aColumn) { return ""; },
312+
getColumnProperties: function (aColumn) { return ""; },
313313
isContainer: function (aIndex) {
314314
if (!this._filtered) {
315315
var item = this._getItemAtIndex(aIndex);

browser/components/preferences/permissions.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ var gPermissionManager = {
4646
getProgressMode: function(aRow, aColumn) {},
4747
getCellValue: function(aRow, aColumn) {},
4848
cycleHeader: function(column) {},
49-
getRowProperties: function(row,prop){},
50-
getColumnProperties: function(column,prop){},
51-
getCellProperties: function(row,column,prop){
49+
getRowProperties: function(row){ return ""; },
50+
getColumnProperties: function(column){ return ""; },
51+
getCellProperties: function(row,column){
5252
if (column.element.getAttribute("id") == "siteCol")
53-
prop.AppendElement(this._ltrAtom);
53+
return "ltr";
54+
55+
return "";
5456
}
5557
},
5658
@@ -183,10 +185,6 @@ var gPermissionManager = {
183185
this._loadPermissions();
184186

185187
urlField.focus();
186-
187-
this._ltrAtom = Components.classes["@mozilla.org/atom-service;1"]
188-
.getService(Components.interfaces.nsIAtomService)
189-
.getAtom("ltr");
190188
},
191189

192190
uninit: function ()

browser/components/search/content/engineManager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,9 @@ EngineView.prototype = {
463463
},
464464

465465
selection: null,
466-
getRowProperties: function(index, properties) { },
467-
getCellProperties: function(index, column, properties) { },
468-
getColumnProperties: function(column, properties) { },
466+
getRowProperties: function(index) { return ""; },
467+
getCellProperties: function(index, column) { return ""; },
468+
getColumnProperties: function(column) { return ""; },
469469
isContainer: function(index) { return false; },
470470
isContainerOpen: function(index) { return false; },
471471
isContainerEmpty: function(index) { return false; },

0 commit comments

Comments
 (0)