mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 21:05:36 +00:00
Bug 836283 - In the Downloads View the Cancel button stops working. r=mak, mconley.
This commit is contained in:
parent
81df8ec694
commit
d084336323
@ -1173,42 +1173,63 @@ DownloadsPlacesView.prototype = {
|
||||
|
||||
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.
|
||||
// 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);
|
||||
try {
|
||||
// Remove the invalidated history downloads from the list and unset the
|
||||
// places node for data downloads.
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
this._richlistbox.suppressOnSelect = suppressOnSelect;
|
||||
}
|
||||
|
||||
let elementsToAppendFragment = document.createDocumentFragment();
|
||||
for (let i = 0; i < aContainer.childCount; i++) {
|
||||
try {
|
||||
this._addDownloadData(null, aContainer.getChild(i), false,
|
||||
elementsToAppendFragment);
|
||||
if (aContainer.childCount > 0) {
|
||||
let elementsToAppendFragment = document.createDocumentFragment();
|
||||
for (let i = 0; i < aContainer.childCount; i++) {
|
||||
try {
|
||||
this._addDownloadData(null, aContainer.getChild(i), false,
|
||||
elementsToAppendFragment);
|
||||
}
|
||||
catch(ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
}
|
||||
catch(ex) {
|
||||
Cu.reportError(ex);
|
||||
|
||||
// _addDownloadData may not add new elements if there were already
|
||||
// data items in place.
|
||||
if (elementsToAppendFragment.firstChild) {
|
||||
this._appendDownloadsFragment(elementsToAppendFragment);
|
||||
this._ensureVisibleElementsAreActive();
|
||||
}
|
||||
}
|
||||
|
||||
this._appendDownloadsFragment(elementsToAppendFragment);
|
||||
this._ensureVisibleElementsAreActive();
|
||||
|
||||
this._richlistbox.suppressOnSelect = suppressOnSelect;
|
||||
goUpdateDownloadCommands();
|
||||
},
|
||||
|
||||
_appendDownloadsFragment: function DPV__appendDownloadsFragment(aDOMFragment) {
|
||||
// Workaround multiple reflows hang by removing the richlistbox
|
||||
// and adding it back when we're done.
|
||||
|
||||
// Hack for bug 836283: reset xbl fields to their old values after the
|
||||
// binding is reattached to avoid breaking the selection state
|
||||
let xblFields = new Map();
|
||||
for (let [key, value] in Iterator(this._richlistbox)) {
|
||||
xblFields.set(key, value);
|
||||
}
|
||||
|
||||
let parentNode = this._richlistbox.parentNode;
|
||||
let nextSibling = this._richlistbox.nextSibling;
|
||||
parentNode.removeChild(this._richlistbox);
|
||||
this._richlistbox.appendChild(aDOMFragment);
|
||||
parentNode.insertBefore(this._richlistbox, nextSibling);
|
||||
|
||||
for (let [key, value] of xblFields) {
|
||||
this._richlistbox[key] = value;
|
||||
}
|
||||
},
|
||||
|
||||
nodeInserted: function DPV_nodeInserted(aParent, aPlacesNode) {
|
||||
|
Loading…
Reference in New Issue
Block a user