diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 0441e3a2a35c..7dec926d5072 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -349,6 +349,7 @@ nsComboboxControlFrame::nsComboboxControlFrame() mGoodToGo = PR_FALSE; mInRedisplayText = PR_FALSE; + mRedisplayTextEventPosted = PR_FALSE; mRecentSelectedIndex = -1; @@ -1819,8 +1820,18 @@ nsComboboxControlFrame::RedisplayText(PRInt32 aIndex) if (eventQueue) { RedisplayTextEvent* event = new RedisplayTextEvent(this, textToDisplay); if (event) { + // Revoke outstanding events to avoid out-of-order events which could mean + // displaying the wrong text. + if (mRedisplayTextEventPosted) { + eventQueue->RevokeEvents(this); + mRedisplayTextEventPosted = PR_FALSE; + } + rv = eventQueue->PostEvent(event); - if (NS_FAILED(rv)) { + + if (NS_SUCCEEDED(rv)) { + mRedisplayTextEventPosted = PR_TRUE; + } else { PL_DestroyEvent(event); } } else { @@ -1839,6 +1850,7 @@ nsComboboxControlFrame::HandleRedisplayTextEvent(const nsAString& aText) // into the correct parent (mDisplayFrame). See bug 282607. NS_PRECONDITION(!mInRedisplayText, "Nested RedisplayText"); mInRedisplayText = PR_TRUE; + mRedisplayTextEventPosted = PR_FALSE; ActuallyDisplayText(aText, PR_TRUE); mDisplayFrame->AddStateBits(NS_FRAME_IS_DIRTY); diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index c1a847c16a4e..f9fc2f9fc8e2 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -290,6 +290,7 @@ protected: PRPackedBool mDroppedDown; // Current state of the dropdown list, PR_TRUE is dropped down PRPackedBool mGoodToGo; PRPackedBool mInRedisplayText; + PRPackedBool mRedisplayTextEventPosted; PRInt32 mRecentSelectedIndex; PRInt32 mDisplayedIndex;