From e958546d804e88b98b76e305cb983c73ff5ce9c2 Mon Sep 17 00:00:00 2001 From: "timeless%mac.com" Date: Wed, 10 Apr 2002 13:56:30 +0000 Subject: [PATCH] Bug 135679 Form submit doesn't work if target is same page and current url has anchor patch by ere@atp.fi r=jkeiser sr=attinasi a=rjesup --- content/html/content/src/nsHTMLFormElement.cpp | 5 +++++ docshell/base/nsDocShell.cpp | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index e3602495db88..4f2d61d69576 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -755,6 +755,11 @@ nsHTMLFormElement::DoSubmit(nsIPresContext* aPresContext, nsEvent* aEvent) nsCOMPtr webProgress = do_GetInterface(docShell); NS_ASSERTION(webProgress, "nsIDocShell not converted to nsIWebProgress!"); rv = webProgress->AddProgressListener(this); + NS_ENSURE_SUBMIT_SUCCESS(rv); + } + else { + // in case we didn't do anything, reset mIsSubmitting + mIsSubmitting = PR_FALSE; } return rv; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index de48e2d1c6e4..a53828896a7c 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -5132,12 +5132,17 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor, PRUint32 aLoadTyp newSpec.BeginReading(urlStart); newSpec.EndReading(refEnd); + // hasAnchor is used to check if the new URI really has anchor + // We can't always scroll, it would break submitting a form that has + // same target page. + PRBool hasAnchor = PR_FALSE; PRInt32 hashNew = newSpec.FindChar(kHash); if (hashNew == 0) { return NS_OK; // Strange URI } else if (hashNew > 0) { // found it + hasAnchor = PR_TRUE; urlEnd = urlStart; urlEnd.advance(hashNew); @@ -5254,7 +5259,8 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor, PRUint32 aLoadTyp } } else { - *aWasAnchor = PR_TRUE; + // Tell there was an anchor only if there really was one (bug 135679) + *aWasAnchor = hasAnchor; } return NS_OK;