Bug 1729358 - Part 3: Move GetFormAction to nsGenericHTMLFormElementWithState; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D124695
This commit is contained in:
Edgar Chen 2021-09-07 09:47:10 +00:00
Родитель 9bc7d719fe
Коммит bc58abc210
2 изменённых файлов: 26 добавлений и 26 удалений

Просмотреть файл

@ -2314,30 +2314,6 @@ bool nsGenericHTMLFormElement::IsLabelable() const {
type == FormControlType::Select || type == FormControlType::Textarea;
}
void nsGenericHTMLFormElement::GetFormAction(nsString& aValue) {
auto type = ControlType();
if (!IsInputElement(type) && !IsButtonElement(type)) {
return;
}
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::formaction, aValue) ||
aValue.IsEmpty()) {
Document* 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 nsGenericHTMLElement::Click(CallerType aCallerType) {
@ -2748,6 +2724,30 @@ void nsGenericHTMLFormElementWithState::NodeInfoChanged(Document* aOldDoc) {
mStateKey.SetIsVoid(true);
}
void nsGenericHTMLFormElementWithState::GetFormAction(nsString& aValue) {
auto type = ControlType();
if (!IsInputElement(type) && !IsButtonElement(type)) {
return;
}
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::formaction, aValue) ||
aValue.IsEmpty()) {
Document* 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);
}
}
bool nsGenericHTMLElement::IsEventAttributeNameInternal(nsAtom* aName) {
return nsContentUtils::IsEventAttributeName(aName, EventNameType_HTML);
}

Просмотреть файл

@ -1047,8 +1047,6 @@ class nsGenericHTMLFormElement : public nsGenericHTMLElement,
virtual bool IsLabelable() const override;
void GetFormAction(nsString& aValue);
// autocapitalize attribute support
virtual void GetAutocapitalize(nsAString& aValue) override;
bool IsAutocapitalizeInheriting() const;
@ -1149,6 +1147,8 @@ class nsGenericHTMLFormElementWithState : public nsGenericHTMLFormElement {
*/
virtual void NodeInfoChanged(Document* aOldDoc) override;
void GetFormAction(nsString& aValue);
protected:
/**
* Restore from presentation state. You pass in the presentation state for