Bug 386159 - Menu-view performance improvements. r=dietrich, a=mconnor.

This commit is contained in:
mozilla.mano@sent.com 2007-06-28 13:33:21 -07:00
Родитель 99ff7f1a79
Коммит 5766dc7f4c
2 изменённых файлов: 31 добавлений и 7 удалений

Просмотреть файл

@ -87,6 +87,8 @@
readonly="true"
onget="return this._controller;"/>
<field name="_built">false</field>
<method name="onPopupShowing">
<body><![CDATA[
if (!this._resultNode)
@ -94,6 +96,8 @@
if (!this._resultNode.containerOpen)
this._resultNode.containerOpen = true;
if (!this._built)
this._rebuild();
if (this.popupShowingCallback)
this.popupShowingCallback();
@ -324,6 +328,7 @@
this.appendChild(element);
}
}
this._built = true;
]]></body>
</method>
@ -344,6 +349,9 @@
},
itemInserted: function PMV_itemInserted(aParentNode, aNode, aIndex) {
if (!this._self._built)
return;
if (aParentNode == this._self.getResultNode()) {
var index = this._self._startMarker + 1 + aIndex;
var before = this._self.childNodes[index] || null;
@ -354,6 +362,9 @@
},
itemRemoved: function PMV_itemRemoved(aParentNode, aNode, aIndex) {
if (!this._self._built)
return;
if (aParentNode == this._self.getResultNode()) {
var children = this._self.childNodes;
@ -369,6 +380,9 @@
},
itemChanged: function PMV_itemChanged(aNode) {
if (!this._self._built)
return;
// this check can be removed once we fix bug #382397
var parentNode = aNode.parent;
if (!parentNode)
@ -425,6 +439,9 @@
itemReplaced:
function PMV_itemReplaced(aParentNode, aOldNode, aNewNode, aIndex) {
if (!this._self._built)
return;
if (aParentNode == this._self.getResultNode()) {
var children = this._self.childNodes;
for (var i = 0; i < children.length; i++) {
@ -449,6 +466,9 @@
},
invalidateContainer: function PMV_invalidateContainer(aContainer) {
if (!this._self._built)
return;
function isChildOf(node, container) {
var parent = node.parent;
while (parent) {
@ -471,15 +491,15 @@
if (aContainer.containerOpen) {
if (viewerToRebuild)
viewerToRebuild._self._rebuild();
viewerToRebuild._built = false;
else
this._self._rebuild();
this._self._built = false;
}
},
invalidateAll: function PMV_invalidateAll() {
this._self._containerNodesMap.splice(0);
this._self._rebuild();
this._self._built = false;
},
sortingChanged: function PMV_sortingChanged(aSortingMode) {
@ -897,8 +917,12 @@
if (event.target != this)
return;
// UI performance: keep the resultnode open so we don't rebuild its
// contents whenever the popup is reopened.
// UI performance: folder queries are cheap, keep the resultnode open
// so we don't rebuild its contents whenever the popup is reopened.
if (!PlacesUtils.nodeIsFolder(this._resultNode)) {
this._resultNode.containerOpen = false;
this._built = false;
}
// The autoopened attribute is set for folders which have been
// automatically opened when dragged over. Turn off this attribute

Просмотреть файл

@ -638,10 +638,10 @@
if (isChildOf(node, aContainer))
this._self._containerNodesMap.splice(i,1);
}
if (aContainer.containerOpen) {
if (viewerToRebuild)
viewerToRebuild._self._rebuild();
viewerToRebuild._self._built = false;
else
this._self._rebuild();
}