From 3cdcb62c97e6d02f6b4e8a43273bf6ca09fe4e73 Mon Sep 17 00:00:00 2001 From: "pollmann%netscape.com" Date: Tue, 16 May 2000 22:09:04 +0000 Subject: [PATCH] Bug 18501: Send onChange before submitting on enter press in text input if the text was changed. This fixes http://maps.mcom.com r=harishd --- .../html/forms/src/nsGfxTextControlFrame.cpp | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/layout/html/forms/src/nsGfxTextControlFrame.cpp b/layout/html/forms/src/nsGfxTextControlFrame.cpp index ac0967b2c9d9..088e96b1d962 100644 --- a/layout/html/forms/src/nsGfxTextControlFrame.cpp +++ b/layout/html/forms/src/nsGfxTextControlFrame.cpp @@ -1072,6 +1072,13 @@ nsGfxTextControlFrame::RedispatchMouseEventToSubDoc(nsIPresContext* aPresContext void nsGfxTextControlFrame::EnterPressed(nsIPresContext* aPresContext) { + // Send out onChange event here to get http://maps working (bug 18501) + nsCOMPtr fListener = do_QueryInterface(mEventListener); + if (fListener) { + fListener->Blur(nsnull); + } + + // Submit the form if (mFormFrame && mFormFrame->CanSubmit(*this)) { nsIContent *formContent = nsnull; @@ -4296,7 +4303,7 @@ nsEnderEventListener::MouseUp(nsIDOMEvent* aEvent) { nsCOMPtrmouseEvent; mouseEvent = do_QueryInterface(aEvent); - if (!mouseEvent) { //non-key event passed in. bad things. + if (!mouseEvent) { //non-mouse event passed in. bad things. return NS_OK; } @@ -4332,7 +4339,7 @@ nsEnderEventListener::MouseClick(nsIDOMEvent* aEvent) { nsCOMPtrmouseEvent; mouseEvent = do_QueryInterface(aEvent); - if (!mouseEvent) { //non-key event passed in. bad things. + if (!mouseEvent) { //non-mouse event passed in. bad things. return NS_OK; } @@ -4369,7 +4376,7 @@ nsEnderEventListener::MouseDblClick(nsIDOMEvent* aEvent) { nsCOMPtrmouseEvent; mouseEvent = do_QueryInterface(aEvent); - if (!mouseEvent) { //non-key event passed in. bad things. + if (!mouseEvent) { //non-mouse event passed in. bad things. return NS_OK; } @@ -4408,7 +4415,7 @@ nsEnderEventListener::MouseOver(nsIDOMEvent* aEvent) /* nsCOMPtrmouseEvent; mouseEvent = do_QueryInterface(aEvent); - if (!mouseEvent) { //non-key event passed in. bad things. + if (!mouseEvent) { //non-mouse event passed in. bad things. return NS_OK; } @@ -4430,7 +4437,7 @@ nsEnderEventListener::MouseOut(nsIDOMEvent* aEvent) { nsCOMPtrmouseEvent; mouseEvent = do_QueryInterface(aEvent); - if (!mouseEvent) { //non-key event passed in. bad things. + if (!mouseEvent) { //non-mouse event passed in. bad things. return NS_OK; } @@ -4528,11 +4535,15 @@ nsEnderEventListener::Focus(nsIDOMEvent* aEvent) nsresult nsEnderEventListener::Blur(nsIDOMEvent* aEvent) { - - nsCOMPtruiEvent; - uiEvent = do_QueryInterface(aEvent); - if (!uiEvent) { - return NS_OK; + // XXX We don't use aEvent, shouldn't matter what it is. + // In addition, EnterPressed calls Blur and passes null (Bug 18501) + // So, if we get a null, skip the QI for the time being. + if (aEvent) { + nsCOMPtruiEvent; + uiEvent = do_QueryInterface(aEvent); + if (!uiEvent) { + return NS_OK; + } } nsGfxTextControlFrame *gfxFrame = mFrame.Reference();