Bug 828111 - Workaround multiple reflows issue and slow xbl attachment in the downloads view. r=mak

This commit is contained in:
Asaf Romano 2013-01-09 16:03:41 +02:00
parent 6b5dcd125c
commit f0b59062c0
2 changed files with 26 additions and 1 deletions

View File

@ -2,6 +2,21 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* The downloads richlistbox may list thousands of items, and it turns out
* XBL binding attachment, and even more so detachment, is a performance hog.
* This hack makes sure we don't apply any binding to inactive items (inactive
* items are history downloads that haven't been in the visible area).
* We can do this because the richlistbox implementation does not interact
* much with the richlistitem binding. However, this may turn out to have
* some side effects (see bug 828111 for the details).
*
* We might be able to do away with this workaround once bug 653881 is fixed.
*/
richlistitem.download {
-moz-binding: none;
}
richlistitem.download[active] {
-moz-binding: url('chrome://browser/content/downloads/download.xml#download-full-ui');
}

View File

@ -1047,10 +1047,20 @@ DownloadsPlacesView.prototype = {
}
}
this._richlistbox.appendChild(elementsToAppendFragment);
this._appendDownloadsFragment(elementsToAppendFragment);
this._ensureVisibleElementsAreActive();
},
_appendDownloadsFragment: function DPV__appendDownloadsFragment(aDOMFragment) {
// Workaround multiple reflows hang by removing the richlistbox
// and adding it back when we're done.
let parentNode = this._richlistbox.parentNode;
let nextSibling = this._richlistbox.nextSibling;
parentNode.removeChild(this._richlistbox);
this._richlistbox.appendChild(aDOMFragment);
parentNode.insertBefore(this._richlistbox, nextSibling);
},
nodeInserted: function DPV_nodeInserted(aParent, aPlacesNode) {
this._addDownloadData(null, aPlacesNode);
},