From 2cecd985e0b69f7cc265b8edfd83bf8c663ca7dc Mon Sep 17 00:00:00 2001 From: "brettw%gmail.com" Date: Tue, 7 Feb 2006 18:48:38 +0000 Subject: [PATCH] Bug 325288 r=annie.sullivan Closing a container should close its children. git-svn-id: svn://10.0.0.236/trunk@189323 18797224-902f-48f8-a5cc-f745e15eee43 --- .../places/src/nsNavHistoryResult.cpp | 24 +++++++++++++++---- .../places/src/nsNavHistoryResult.h | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/mozilla/browser/components/places/src/nsNavHistoryResult.cpp b/mozilla/browser/components/places/src/nsNavHistoryResult.cpp index 8520c4d0c46..2c3d6304e31 100755 --- a/mozilla/browser/components/places/src/nsNavHistoryResult.cpp +++ b/mozilla/browser/components/places/src/nsNavHistoryResult.cpp @@ -361,11 +361,23 @@ nsNavHistoryContainerResultNode::OpenContainer() // nsNavHistoryContainerResultNode::CloseContainer +// +// Set aUpdateVisible to redraw the screen, this is the normal operation. +// This is set to false for the recursive calls since the root container +// that is being closed will handle recomputation of the visible elements +// for its entire subtree. nsresult -nsNavHistoryContainerResultNode::CloseContainer() +nsNavHistoryContainerResultNode::CloseContainer(PRBool aUpdateVisible) { NS_ASSERTION(mExpanded, "Container must be expanded to close it"); + + // recursively close all child containers + for (PRInt32 i = 0; i < mChildren.Count(); i ++) { + if (mChildren[i]->IsContainer() && mChildren[i]->GetAsContainer()->mExpanded) + mChildren[i]->GetAsContainer()->CloseContainer(PR_FALSE); + } + mExpanded = PR_FALSE; nsresult rv; @@ -376,10 +388,12 @@ nsNavHistoryContainerResultNode::CloseContainer() remote->OnContainerClosed(this); } - nsNavHistoryResult* result = GetResult(); - NS_ENSURE_TRUE(result, NS_ERROR_FAILURE); - rv = result->RefreshVisibleSection(this); - NS_ENSURE_SUCCESS(rv, rv); + if (aUpdateVisible) { + nsNavHistoryResult* result = GetResult(); + NS_ENSURE_TRUE(result, NS_ERROR_FAILURE); + rv = result->RefreshVisibleSection(this); + NS_ENSURE_SUCCESS(rv, rv); + } return NS_OK; } diff --git a/mozilla/browser/components/places/src/nsNavHistoryResult.h b/mozilla/browser/components/places/src/nsNavHistoryResult.h index 4fdd7dcb2f9..3cb35f50914 100644 --- a/mozilla/browser/components/places/src/nsNavHistoryResult.h +++ b/mozilla/browser/components/places/src/nsNavHistoryResult.h @@ -398,7 +398,7 @@ public: // overridded by descendents to populate virtual nsresult OpenContainer(); - nsresult CloseContainer(); + nsresult CloseContainer(PRBool aUpdateVisible = PR_TRUE); // this points to the result that owns this container. All containers have // their result pointer set so we can quickly get to the result without having