diff --git a/toolkit/components/passwordmgr/content/passwordManager.js b/toolkit/components/passwordmgr/content/passwordManager.js index 92bd1c2c128..0d6015959cd 100644 --- a/toolkit/components/passwordmgr/content/passwordManager.js +++ b/toolkit/components/passwordmgr/content/passwordManager.js @@ -209,8 +209,8 @@ function SignonSelected() { function DeleteSignon() { DeleteSelectedItemFromTree(signonsTree, signonsTreeView, - signons, deletedSignons, - "removeSignon", "removeAllSignons"); + signons, deletedSignons, + "removeSignon", "removeAllSignons"); FinalizeSignonDeletions(); } @@ -367,11 +367,14 @@ function DeleteAllFromTree table.length = 0; // clear out selections - tree.treeBoxObject.view.selection.select(-1); + view.selection.select(-1); - // redisplay + // update the tree view and notify the tree view.rowCount = 0; - tree.treeBoxObject.invalidate(); + + var box = tree.treeBoxObject; + box.rowCountChanged(0, -deletedTable.length); + box.invalidate(); // disable buttons @@ -382,52 +385,61 @@ function DeleteAllFromTree function DeleteSelectedItemFromTree (tree, view, table, deletedTable, removeButton, removeAllButton) { - // remove selected items from list (by setting them to null) and place in deleted list - var selections = GetTreeSelections(tree); - for (var s=selections.length-1; s>= 0; s--) { - var i = selections[s]; - deletedTable[deletedTable.length] = table[i]; - table[i] = null; + var box = tree.treeBoxObject; + + // Remove selected items from list (by setting them to null) and place in + // deleted list. At the same time, notify the tree of the row count changes. + + var selection = box.selection; + var oldSelectStart = table.length; + box.beginUpdateBatch(); + + var selCount = selection.getRangeCount(); + var min = new Object(); + var max = new Object(); + + for (var s = 0; s < selCount; ++s) { + selection.getRangeAt(s, min, max); + var minVal = min.value; + var maxVal = max.value; + + oldSelectStart = minVal < oldSelectStart ? minVal : oldSelectStart; + + var rowCount = maxVal - minVal + 1; + view.rowCount -= rowCount; + box.rowCountChanged(minVal, -rowCount); + + for (var i = minVal; i <= maxVal; ++i) { + deletedTable[deletedTable.length] = table[i]; + table[i] = null; + } } // collapse list by removing all the null entries - for (var j=0; j