Make sure we fire onchange also after selectedIndex was set to -1 through DOM. Thanks to Pablo Greco for helping fix this. b=317078 r+sr=roc
git-svn-id: svn://10.0.0.236/trunk@212915 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
d243375fb5
commit
b8a8f64bb5
@ -307,7 +307,7 @@ nsComboboxControlFrame::nsComboboxControlFrame(nsStyleContext* aContext)
|
||||
|
||||
mInRedisplayText = PR_FALSE;
|
||||
|
||||
mRecentSelectedIndex = -1;
|
||||
mRecentSelectedIndex = NS_SKIP_NOTIFY_INDEX;
|
||||
|
||||
//Shrink the area around its contents
|
||||
//SetFlags(NS_BLOCK_SHRINK_WRAP);
|
||||
@ -2007,7 +2007,7 @@ PRInt32
|
||||
nsComboboxControlFrame::UpdateRecentIndex(PRInt32 aIndex)
|
||||
{
|
||||
PRInt32 index = mRecentSelectedIndex;
|
||||
if (mRecentSelectedIndex == -1 || aIndex == -1)
|
||||
if (mRecentSelectedIndex == NS_SKIP_NOTIFY_INDEX || aIndex == NS_SKIP_NOTIFY_INDEX)
|
||||
mRecentSelectedIndex = aIndex;
|
||||
return index;
|
||||
}
|
||||
|
||||
@ -52,6 +52,9 @@
|
||||
//#define DO_NEW_REFLOW
|
||||
#endif
|
||||
|
||||
//Mark used to indicate when onchange has been fired for current combobox item
|
||||
#define NS_SKIP_NOTIFY_INDEX -2
|
||||
|
||||
#include "nsAreaFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
|
||||
@ -1977,8 +1977,8 @@ nsListControlFrame::FireOnChange()
|
||||
{
|
||||
if (mComboboxFrame) {
|
||||
// Return hit without changing anything
|
||||
PRInt32 index = mComboboxFrame->UpdateRecentIndex(-1);
|
||||
if (index == -1)
|
||||
PRInt32 index = mComboboxFrame->UpdateRecentIndex(NS_SKIP_NOTIFY_INDEX);
|
||||
if (index == NS_SKIP_NOTIFY_INDEX)
|
||||
return;
|
||||
|
||||
// See if the selection actually changed
|
||||
@ -2009,9 +2009,9 @@ NS_IMETHODIMP
|
||||
nsListControlFrame::OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex)
|
||||
{
|
||||
if (mComboboxFrame) {
|
||||
// UpdateRecentIndex with -1, so that we won't fire an onchange
|
||||
// UpdateRecentIndex with NS_SKIP_NOTIFY_INDEX, so that we won't fire an onchange
|
||||
// event for this setting of selectedIndex.
|
||||
mComboboxFrame->UpdateRecentIndex(-1);
|
||||
mComboboxFrame->UpdateRecentIndex(NS_SKIP_NOTIFY_INDEX);
|
||||
}
|
||||
|
||||
ScrollToIndex(aNewIndex);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user