Bug 832471 - Make Library Downloads view actually remove all downloads on Clear Downloads

r=Mano
This commit is contained in:
Marco Bonardo 2013-01-19 11:21:33 +01:00
parent c2a58f344c
commit 858fb04683

View File

@ -748,6 +748,8 @@ DownloadElementShell.prototype = {
* appropriately (_fetchTargetFileInfo() calls goUpdateDownloadCommands).
*/
onSelect: function DES_onSelect() {
if (!this.active)
return;
if (!this._targetFileInfoFetched)
this._fetchTargetFileInfo();
}
@ -884,7 +886,7 @@ DownloadsPlacesView.prototype = {
function DPV_addDownloadData(aDataItem, aPlacesNode, aNewest = false,
aDocumentFragment = null) {
let downloadURI = aPlacesNode ? aPlacesNode.uri : aDataItem.uri;
let shellsForURI = this._downloadElementsShellsForURI.get(downloadURI, null);
let shellsForURI = this._downloadElementsShellsForURI.get(downloadURI);
if (!shellsForURI) {
shellsForURI = new Set();
this._downloadElementsShellsForURI.set(downloadURI, shellsForURI);
@ -996,7 +998,7 @@ DownloadsPlacesView.prototype = {
_removeHistoryDownloadFromView:
function DPV__removeHistoryDownloadFromView(aPlacesNode) {
let downloadURI = aPlacesNode.uri;
let shellsForURI = this._downloadElementsShellsForURI.get(downloadURI, null);
let shellsForURI = this._downloadElementsShellsForURI.get(downloadURI);
if (shellsForURI) {
for (let shell of shellsForURI) {
if (shell.dataItem) {
@ -1014,7 +1016,7 @@ DownloadsPlacesView.prototype = {
_removeSessionDownloadFromView:
function DPV__removeSessionDownloadFromView(aDataItem) {
let shells = this._downloadElementsShellsForURI.get(aDataItem.uri, null);
let shells = this._downloadElementsShellsForURI.get(aDataItem.uri);
if (shells.size == 0)
throw new Error("Should have had at leaat one shell for this uri");
@ -1169,9 +1171,14 @@ DownloadsPlacesView.prototype = {
if (!aContainer.containerOpen)
throw new Error("Root container for the downloads query cannot be closed");
let suppressOnSelect = this._richlistbox.suppressOnSelect;
this._richlistbox.suppressOnSelect = true;
// Remove the invalidated history downloads from the list and unset the
// places node for data downloads.
for (let element of this._richlistbox.childNodes) {
// Loop backwards since _removeHistoryDownloadFromView may removeChild().
for (let i = this._richlistbox.childNodes.length - 1; i >= 0; --i) {
let element = this._richlistbox.childNodes[i];
if (element._shell.placesNode)
this._removeHistoryDownloadFromView(element._shell.placesNode);
}
@ -1189,6 +1196,8 @@ DownloadsPlacesView.prototype = {
this._appendDownloadsFragment(elementsToAppendFragment);
this._ensureVisibleElementsAreActive();
this._richlistbox.suppressOnSelect = suppressOnSelect;
goUpdateDownloadCommands();
},