mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 490665 - Implement HTML5-compliant isindex form submission. r=jonas.
--HG-- extra : rebase_source : 2075bc59ce711e29718eac8bb0e1b8867e291a53
This commit is contained in:
parent
2c15d29366
commit
789bbf8cb8
@ -83,6 +83,27 @@ public:
|
||||
virtual nsresult AddNameFilePair(const nsAString& aName,
|
||||
nsIFile* aFile) = 0;
|
||||
|
||||
/**
|
||||
* Reports whether the instance supports AddIsindex().
|
||||
*
|
||||
* @return true if supported.
|
||||
*/
|
||||
virtual PRBool SupportsIsindexSubmission()
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an isindex value to the submission.
|
||||
*
|
||||
* @param aValue the field value
|
||||
*/
|
||||
virtual nsresult AddIsindex(const nsAString& aValue)
|
||||
{
|
||||
NS_NOTREACHED("AddIsindex called when not supported");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a URI and the current submission, create the final URI and data
|
||||
* stream that will be submitted. Subclasses *must* implement this.
|
||||
|
@ -114,6 +114,13 @@ public:
|
||||
virtual nsresult GetEncodedSubmission(nsIURI* aURI,
|
||||
nsIInputStream** aPostDataStream);
|
||||
|
||||
virtual PRBool SupportsIsindexSubmission()
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
virtual nsresult AddIsindex(const nsAString& aValue);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@ -169,6 +176,24 @@ nsFSURLEncoded::AddNameValuePair(const nsAString& aName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFSURLEncoded::AddIsindex(const nsAString& aValue)
|
||||
{
|
||||
// Encode value
|
||||
nsCString convValue;
|
||||
nsresult rv = URLEncode(aValue, convValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Append data to string
|
||||
if (mQueryString.IsEmpty()) {
|
||||
mQueryString.Assign(convValue);
|
||||
} else {
|
||||
mQueryString += NS_LITERAL_CSTRING("&isindex=") + convValue;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFSURLEncoded::AddNameFilePair(const nsAString& aName,
|
||||
nsIFile* aFile)
|
||||
|
@ -2659,15 +2659,18 @@ nsHTMLInputElement::SubmitNamesValues(nsFormSubmission* aFormSubmission,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Submit
|
||||
// (for type=image, only submit if value is non-null)
|
||||
if (mType == NS_FORM_INPUT_HIDDEN && name.EqualsLiteral("_charset_")) {
|
||||
nsCString charset;
|
||||
aFormSubmission->GetCharset(charset);
|
||||
rv = aFormSubmission->AddNameValuePair(name,
|
||||
NS_ConvertASCIItoUTF16(charset));
|
||||
}
|
||||
else if (mType != NS_FORM_INPUT_IMAGE || !value.IsEmpty()) {
|
||||
else if (mType == NS_FORM_INPUT_TEXT &&
|
||||
name.EqualsLiteral("isindex") &&
|
||||
aFormSubmission->SupportsIsindexSubmission()) {
|
||||
rv = aFormSubmission->AddIsindex(value);
|
||||
}
|
||||
else {
|
||||
rv = aFormSubmission->AddNameValuePair(name, value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user