Bug 730340 - Bug 730340 - Don't use expando properties for storing data on places nodes. Don't use an expando to mark cut nodes. r=mak.

This commit is contained in:
Asaf Romano 2012-06-03 15:01:15 +03:00
parent 18b6bfc148
commit 7ba8f62ee7
2 changed files with 19 additions and 6 deletions

View File

@ -45,7 +45,7 @@
<property name="view">
<getter><![CDATA[
try {
return this.treeBoxObject.view.QueryInterface(Ci.nsINavHistoryResultTreeViewer);
return this.treeBoxObject.view.wrappedJSObject;
}
catch(e) {
return null;
@ -312,10 +312,7 @@
<parameter name="aNode"/>
<parameter name="aValue"/>
<body><![CDATA[
aNode._cutting = aValue;
try {
this.view.nodeIconChanged(aNode);
} catch(ex) { /* ignore no more valid nodes */ }
this.view.toggleCutNode(aNode, aValue);
]]></body>
</method>

View File

@ -14,6 +14,8 @@ function PlacesTreeView(aFlatList, aOnOpenFlatContainer, aController) {
}
PlacesTreeView.prototype = {
get wrappedJSObject() this,
_makeAtom: function PTV__makeAtom(aString) {
return Cc["@mozilla.org/atom-service;1"].
getService(Ci.nsIAtomService).
@ -1087,11 +1089,13 @@ PlacesTreeView.prototype = {
this._result = val;
this._rootNode = this._result.root;
this._cellProperties = new WeakMap();
this._cuttingNodes = new Set();
}
else if (this._result) {
delete this._result;
delete this._rootNode;
delete this._cellProperties;
delete this._cuttingNodes;
}
// If the tree is not set yet, setTree will call finishInit.
@ -1150,7 +1154,7 @@ PlacesTreeView.prototype = {
let node = this._getNodeForRow(aRow);
if (node._cutting) {
if (this._cuttingNodes.has(node)) {
aProperties.AppendElement(this._getAtomFor("cutting"));
}
@ -1681,6 +1685,18 @@ PlacesTreeView.prototype = {
}
},
toggleCutNode: function PTV_toggleCutNode(aNode, aValue) {
let currentVal = this._cuttingNodes.has(aNode);
if (currentVal != aValue) {
if (aValue)
this._cuttingNodes.add(aNode);
else
this._cuttingNodes.delete(aNode);
this._invalidateCellValue(aNode, this.COLUMN_TYPE_TITLE);
}
},
selectionChanged: function() { },
cycleCell: function(aRow, aColumn) { },
isSelectable: function(aRow, aColumn) { return false; },