From e21cc9e7c847efb1455a351186c33c385b8f87ea Mon Sep 17 00:00:00 2001 From: "Olli.Pettay%helsinki.fi" Date: Fri, 20 Jul 2007 23:19:19 +0000 Subject: [PATCH] Bug 355367, textbox onchange doesn't fire if user tabs out and value changed in onkeydown, r=jst, sr=sicking git-svn-id: svn://10.0.0.236/trunk@230399 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsTextControlFrame.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 395e4385afd..a91fe7867c1 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -2575,6 +2575,16 @@ nsTextControlFrame::SetValue(const nsAString& aValue) // so much easier... if (mEditor && mUseEditor) { + // This method isn't used for user-generated changes, except for calls + // from nsFileControlFrame which sets mFireChangeEventState==true and + // restores it afterwards (ie. we want 'change' events for those changes). + // Focused value must be updated to prevent incorrect 'change' events, + // but only if user hasn't changed the value. + nsString val; + GetText(&val); + PRBool focusValueInit = !mFireChangeEventState && + mFocusedValue.Equals(val); + nsCOMPtr editor = mEditor; nsWeakFrame weakFrame(this); nsAutoString currentValue; @@ -2669,10 +2679,7 @@ nsTextControlFrame::SetValue(const nsAString& aValue) if (outerTransaction) mNotifyOnInput = PR_TRUE; - // This method isn't used for user-generated changes, except for calls - // from nsFileControlFrame which sets mFireChangeEventState==true and - // restores it afterwards (ie. we want onchange events for those changes). - if (!mFireChangeEventState) { + if (focusValueInit) { // Reset mFocusedValue so the onchange event doesn't fire incorrectly. InitFocusedValue(); }