From 5766dc7f4c5890f884910e2e7dc4409123792527 Mon Sep 17 00:00:00 2001 From: "mozilla.mano@sent.com" Date: Thu, 28 Jun 2007 13:33:21 -0700 Subject: [PATCH] Bug 386159 - Menu-view performance improvements. r=dietrich, a=mconnor. --- browser/components/places/content/menu.xml | 34 ++++++++++++++++--- browser/components/places/content/toolbar.xml | 4 +-- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/browser/components/places/content/menu.xml b/browser/components/places/content/menu.xml index 89335034e7e..f306861e240 100755 --- a/browser/components/places/content/menu.xml +++ b/browser/components/places/content/menu.xml @@ -87,6 +87,8 @@ readonly="true" onget="return this._controller;"/> + false + @@ -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 diff --git a/browser/components/places/content/toolbar.xml b/browser/components/places/content/toolbar.xml index 1f30cd1d5d9..bcc3bbe977e 100755 --- a/browser/components/places/content/toolbar.xml +++ b/browser/components/places/content/toolbar.xml @@ -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(); }