From e49b147dcece758a87b1f0b97913cf539f36b3d6 Mon Sep 17 00:00:00 2001 From: "neil%parkwaycc.co.uk" Date: Fri, 10 Oct 2003 08:39:35 +0000 Subject: [PATCH] Bug 161452 Tree content and builder views may need to recheck empty status after children are removed based on patch by kyle yuan r=varga sr=bryner --- content/xul/templates/src/nsTreeRows.h | 7 ++++--- content/xul/templates/src/nsXULContentBuilder.cpp | 2 +- content/xul/templates/src/nsXULTreeBuilder.cpp | 11 ++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/content/xul/templates/src/nsTreeRows.h b/content/xul/templates/src/nsTreeRows.h index 86adb0075b1..c30fa25cd48 100644 --- a/content/xul/templates/src/nsTreeRows.h +++ b/content/xul/templates/src/nsTreeRows.h @@ -388,12 +388,13 @@ public: /** * Remove the specified row from the view */ - void + PRInt32 RemoveRowAt(iterator& aIterator) { - iterator temp = aIterator++; + iterator temp = aIterator--; Subtree* parent = temp.GetParent(); parent->RemoveRowAt(temp.GetChildIndex()); - InvalidateCachedRow(); } + InvalidateCachedRow(); + return parent->Count(); } /** * Insert a new match into the view diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp index 1260cbeb5ee..899dd3ab2a9 100644 --- a/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/content/xul/templates/src/nsXULContentBuilder.cpp @@ -1705,7 +1705,7 @@ nsXULContentBuilder::ReplaceMatch(nsIRDFResource* aMember, RemoveMember(content, member, PR_TRUE); - if (aNewMatch) { + if (!aNewMatch) { // If there's no new match, then go ahead an update the // container attributes now. SetContainerAttrs(content, aOldMatch); diff --git a/content/xul/templates/src/nsXULTreeBuilder.cpp b/content/xul/templates/src/nsXULTreeBuilder.cpp index 69430afdd2c..4e8c693c7f1 100644 --- a/content/xul/templates/src/nsXULTreeBuilder.cpp +++ b/content/xul/templates/src/nsXULTreeBuilder.cpp @@ -1113,11 +1113,12 @@ nsXULTreeBuilder::ReplaceMatch(nsIRDFResource* aMember, // Remove the rows from the view PRInt32 row = iter.GetRowIndex(); PRInt32 delta = mRows.GetSubtreeSizeFor(iter); - mRows.RemoveRowAt(iter); - - // XXX Could potentially invalidate the iterator's - // mContainer[Type|State] caching here, but it'll work - // itself out. + if (mRows.RemoveRowAt(iter) == 0) { + // In this case iter now points to its parent + // Invalidate the row's cached fill state + iter->mContainerFill = nsTreeRows::eContainerFill_Unknown; + mBoxObject->InvalidatePrimaryCell(iter.GetRowIndex()); + } // Notify the box object mBoxObject->RowCountChanged(row, -delta - 1);