Bug 760940 - Bookmarks and history menus behave incorrectly due to non-node weak map keys. r=mak

This commit is contained in:
Asaf Romano
2012-07-24 17:20:57 +03:00
parent ced69e0e89
commit 087345b066
4 changed files with 20 additions and 11 deletions

View File

@@ -68,7 +68,7 @@ PlacesViewBase.prototype = {
if (val) {
this._resultNode = val.root;
this._rootElt._placesNode = this._resultNode;
this._domNodes = new WeakMap();
this._domNodes = new Map();
this._domNodes.set(this._resultNode, this._rootElt);
// This calls _rebuild through invalidateContainer.

View File

@@ -80,7 +80,7 @@ function PlacesController(aView) {
return Services.dirsvc.get("ProfD", Ci.nsIFile).leafName;
});
this._cachedLivemarkInfoObjects = new WeakMap();
this._cachedLivemarkInfoObjects = new Map();
}
PlacesController.prototype = {

View File

@@ -51,7 +51,7 @@ PlacesTreeView.prototype = {
// Bug 761494:
// ----------
// Some addons use methods from nsINavHistoryResultObserver and
// nsINavHistoryResultTreeViewer, without QIing to these intefaces first.
// nsINavHistoryResultTreeViewer, without QIing to these interfaces first.
// That's not a problem when the view is retrieved through the
// <tree>.view getter (which returns the wrappedJSObject of this object),
// it raises an issue when the view retrieved through the treeBoxObject.view
@@ -153,12 +153,21 @@ PlacesTreeView.prototype = {
_getRowForNode:
function PTV__getRowForNode(aNode, aForceBuild, aParentRow, aNodeIndex) {
if (aNode == this._rootNode)
throw "The root node is never visible";
throw new Error("The root node is never visible");
let ancestors = PlacesUtils.nodeAncestors(aNode);
for (let ancestor in ancestors) {
// A node is removed form the view either if it has no parent or if its
// root-ancestor is not the root node (in which case that's the node
// for which nodeRemoved was called).
let ancestors = [x for each (x in PlacesUtils.nodeAncestors(aNode))];
if (ancestors.length == 0 ||
ancestors[ancestors.length - 1] != this._rootNode) {
throw new Error("Removed node passed to _getRowForNode");
}
// Ensure that the entire chain is open, otherwise that node is invisible.
for (let ancestor of ancestors) {
if (!ancestor.containerOpen)
throw "Invisible node passed to _getRowForNode";
throw new Error("Invisible node passed to _getRowForNode");
}
// Non-plain containers are initially built with their contents.
@@ -1097,7 +1106,7 @@ PlacesTreeView.prototype = {
if (val) {
this._result = val;
this._rootNode = this._result.root;
this._cellProperties = new WeakMap();
this._cellProperties = new Map();
this._cuttingNodes = new Set();
}
else if (this._result) {

View File

@@ -663,8 +663,8 @@ function Livemark(aLivemarkInfo)
this._status = Ci.mozILivemark.STATUS_READY;
// Hash of resultObservers, hashed by container.
this._resultObservers = new WeakMap();
// This keeps a list of the containers used as keys in the weakmap, since
this._resultObservers = new Map();
// This keeps a list of the containers used as keys in the map, since
// it's not iterable. In future may use an iterable Map.
this._resultObserversList = [];
@@ -674,7 +674,7 @@ function Livemark(aLivemarkInfo)
// Keeps a separate array of nodes for each requesting container, hashed by
// the container itself.
this._nodes = new WeakMap();
this._nodes = new Map();
this._guid = "";
this._lastModified = 0;