From 878b456f055dbc117f992ca6fb7e36ec39dff9d9 Mon Sep 17 00:00:00 2001 From: "pollmann%netscape.com" Date: Fri, 20 Oct 2000 01:02:47 +0000 Subject: [PATCH] Bug 52670: Grow session history frame list if needed when frames load out of order. r=radha@netscape.com, sr=rpotts@netscape.com --- xpfe/components/shistory/src/nsSHEntry.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/xpfe/components/shistory/src/nsSHEntry.cpp b/xpfe/components/shistory/src/nsSHEntry.cpp index 4f4c066a5498..d0c2c3c967ab 100644 --- a/xpfe/components/shistory/src/nsSHEntry.cpp +++ b/xpfe/components/shistory/src/nsSHEntry.cpp @@ -214,9 +214,23 @@ nsSHEntry::AddChild(nsISHEntry * aChild, PRInt32 aOffset) NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE); PRInt32 childCount = mChildren.Count(); if (aOffset < childCount) - mChildren.InsertElementAt((void *) aChild, aOffset); + mChildren.ReplaceElementAt((void *) aChild, aOffset); else + { + // + // Bug 52670: Ensure children are added in order. + // + // Later frames in the child list may load faster and get appended + // before earlier frames, causing session history to be scrambled. + // By growing the list here, they are added to the right position. + // + // Assert that aOffset will not be so high as to grow us a lot. + // + NS_ASSERTION(aOffset < (childCount + 1023), "Large frames array!\n"); + while (aOffset > childCount++) + mChildren.AppendElement(nsnull); mChildren.AppendElement((void *)aChild); + } NS_ADDREF(aChild); return NS_OK;