From 665455a67b14c09fe2f2f67d8ec7b36d3357691f Mon Sep 17 00:00:00 2001 From: "rods@netscape.com" Date: Wed, 25 Aug 1999 13:44:49 +0000 Subject: [PATCH] The index of the option being deleted needs to be remembered before the it is removed from the list --- content/html/content/src/nsHTMLSelectElement.cpp | 4 +++- layout/html/content/src/nsHTMLSelectElement.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/content/html/content/src/nsHTMLSelectElement.cpp b/content/html/content/src/nsHTMLSelectElement.cpp index 4d499f6751fe..f6e45524b88d 100644 --- a/content/html/content/src/nsHTMLSelectElement.cpp +++ b/content/html/content/src/nsHTMLSelectElement.cpp @@ -676,6 +676,8 @@ nsHTMLSelectElement::RemoveOption(nsIContent* aContent) // as we will manually update the widget at frame construction time. if (!mOptions) return NS_OK; + PRInt32 oldIndex = mOptions->IndexOf(aContent); + // Remove the option from the options list mOptions->RemoveOption(aContent); @@ -689,7 +691,7 @@ nsHTMLSelectElement::RemoveOption(nsIContent* aContent) // We can't get our index if we've already been replaced in the OptionList. // If we couldn't get our index, pass -1, remove all options and recreate // Coincidentally, IndexOf returns -1 if the option isn't found in the list - result = selectFrame->RemoveOption(mOptions->IndexOf(aContent)); + result = selectFrame->RemoveOption(oldIndex); } } diff --git a/layout/html/content/src/nsHTMLSelectElement.cpp b/layout/html/content/src/nsHTMLSelectElement.cpp index 4d499f6751fe..f6e45524b88d 100644 --- a/layout/html/content/src/nsHTMLSelectElement.cpp +++ b/layout/html/content/src/nsHTMLSelectElement.cpp @@ -676,6 +676,8 @@ nsHTMLSelectElement::RemoveOption(nsIContent* aContent) // as we will manually update the widget at frame construction time. if (!mOptions) return NS_OK; + PRInt32 oldIndex = mOptions->IndexOf(aContent); + // Remove the option from the options list mOptions->RemoveOption(aContent); @@ -689,7 +691,7 @@ nsHTMLSelectElement::RemoveOption(nsIContent* aContent) // We can't get our index if we've already been replaced in the OptionList. // If we couldn't get our index, pass -1, remove all options and recreate // Coincidentally, IndexOf returns -1 if the option isn't found in the list - result = selectFrame->RemoveOption(mOptions->IndexOf(aContent)); + result = selectFrame->RemoveOption(oldIndex); } }