From 44e2c52b7156dbb0a72f3ad557669ef3a698d63e Mon Sep 17 00:00:00 2001 From: "pollmann%netscape.com" Date: Sat, 25 Mar 2000 03:42:40 +0000 Subject: [PATCH] Bug 18728: Forms should submit variables in content order, even through reframe of child elements r=harishd git-svn-id: svn://10.0.0.236/trunk@64101 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/html/forms/src/nsFormFrame.cpp | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/mozilla/layout/html/forms/src/nsFormFrame.cpp b/mozilla/layout/html/forms/src/nsFormFrame.cpp index 717a5d3f460..185be72fcc7 100644 --- a/mozilla/layout/html/forms/src/nsFormFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormFrame.cpp @@ -451,7 +451,38 @@ void nsFormFrame::DoDefaultSelection(nsIPresContext* aPresContext, void nsFormFrame::AddFormControlFrame(nsIPresContext* aPresContext, nsIFormControlFrame& aFrame) { - mFormControls.AppendElement(&aFrame); + // Add this control to the list + // Sort by content ID - this assures we submit in document order (bug 18728) + PRInt32 i = mFormControls.Count(); + + nsCOMPtr newContent; + nsIFrame* newFrame = nsnull; + nsresult rv = aFrame.QueryInterface(kIFrameIID, (void **)&newFrame); + if (NS_SUCCEEDED(rv) && newFrame) { + rv = newFrame->GetContent(getter_AddRefs(newContent)); + if (NS_SUCCEEDED(rv) && newContent) { + PRUint32 newID; + newContent->GetContentID(&newID); + for (; i>0; i--) { + nsIFormControlFrame* thisControl = (nsIFormControlFrame*) mFormControls.ElementAt(i-1); + if (thisControl) { + nsCOMPtr thisContent; + nsIFrame* thisFrame = nsnull; + nsresult rv = thisControl->QueryInterface(kIFrameIID, (void **)&thisFrame); + if (NS_SUCCEEDED(rv) && thisFrame) { + rv = thisFrame->GetContent(getter_AddRefs(thisContent)); + if (NS_SUCCEEDED(rv) && thisContent) { + PRUint32 thisID; + thisContent->GetContentID(&thisID); + if (newID > thisID) + break; + } + } + } + } + } + } + mFormControls.InsertElementAt(&aFrame, i); // determine which radio buttons belong to which radio groups, unnamed radio buttons // don't go into any group since they can't be submitted. Determine which controls