mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1366361 - Part 1: .action/formAction should return the document's URL if @action/formaction is missing or empty. r=smaug
MozReview-Commit-ID: H4CK0SVpaCv
This commit is contained in:
parent
4c033a0b2c
commit
b52a4e5094
@ -23,6 +23,7 @@ class HTMLButtonElement final : public nsGenericHTMLFormElementWithState,
|
||||
{
|
||||
public:
|
||||
using nsIConstraintValidation::GetValidationMessage;
|
||||
using nsGenericHTMLFormElementWithState::GetFormAction;
|
||||
|
||||
explicit HTMLButtonElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
||||
FromParser aFromParser = NOT_FROM_PARSER);
|
||||
|
@ -1585,6 +1585,27 @@ HTMLFormElement::FlushPendingSubmission()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLFormElement::GetAction(nsString& aValue)
|
||||
{
|
||||
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::action, aValue) ||
|
||||
aValue.IsEmpty()) {
|
||||
nsIDocument* document = OwnerDoc();
|
||||
nsIURI* docURI = document->GetDocumentURI();
|
||||
if (docURI) {
|
||||
nsAutoCString spec;
|
||||
nsresult rv = docURI->GetSpec(spec);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CopyUTF8toUTF16(spec, aValue);
|
||||
}
|
||||
} else {
|
||||
GetURIAttr(nsGkAtoms::action, nullptr, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
HTMLFormElement::GetActionURL(nsIURI** aActionURL,
|
||||
nsIContent* aOriginatingElement)
|
||||
|
@ -314,7 +314,8 @@ public:
|
||||
SetHTMLAttr(nsGkAtoms::acceptcharset, aValue, aRv);
|
||||
}
|
||||
|
||||
// XPCOM GetAction() is OK
|
||||
void GetAction(nsString& aValue);
|
||||
|
||||
void SetAction(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::action, aValue, aRv);
|
||||
|
@ -137,6 +137,7 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
|
||||
public:
|
||||
using nsIConstraintValidation::GetValidationMessage;
|
||||
using nsGenericHTMLFormElementWithState::GetForm;
|
||||
using nsGenericHTMLFormElementWithState::GetFormAction;
|
||||
|
||||
enum class FromClone { no, yes };
|
||||
|
||||
|
@ -2428,6 +2428,32 @@ nsGenericHTMLFormElement::IsLabelable() const
|
||||
type == NS_FORM_TEXTAREA;
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericHTMLFormElement::GetFormAction(nsString& aValue)
|
||||
{
|
||||
uint32_t type = ControlType();
|
||||
if (!(type & NS_FORM_INPUT_ELEMENT) && !(type & NS_FORM_BUTTON_ELEMENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::formaction, aValue) ||
|
||||
aValue.IsEmpty()) {
|
||||
nsIDocument* document = OwnerDoc();
|
||||
nsIURI* docURI = document->GetDocumentURI();
|
||||
if (docURI) {
|
||||
nsAutoCString spec;
|
||||
nsresult rv = docURI->GetSpec(spec);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CopyUTF8toUTF16(spec, aValue);
|
||||
}
|
||||
} else {
|
||||
GetURIAttr(nsGkAtoms::formaction, nullptr, aValue);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void
|
||||
|
@ -1120,6 +1120,8 @@ public:
|
||||
|
||||
virtual bool IsLabelable() const override;
|
||||
|
||||
void GetFormAction(nsString& aValue);
|
||||
|
||||
protected:
|
||||
virtual ~nsGenericHTMLFormElement();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user