From 9b3d301a9103c1eaf182e5eee7af006f30dc9507 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 git-svn-id: svn://10.0.0.236/trunk@44496 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/html/content/src/nsHTMLSelectElement.cpp | 4 +++- mozilla/layout/html/content/src/nsHTMLSelectElement.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 4d499f6751f..f6e45524b88 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/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/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp b/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp index 4d499f6751f..f6e45524b88 100644 --- a/mozilla/layout/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/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); } }