Bug 1556358 - Part 2: Save and restore custom element form data. r=edgar

Depends on D175542

Differential Revision: https://phabricator.services.mozilla.com/D174115
This commit is contained in:
Adam Vandolder
2023-06-19 13:44:15 +00:00
parent d2921e47d1
commit c1d69f579f
15 changed files with 496 additions and 50 deletions

View File

@@ -1833,6 +1833,9 @@ nsresult nsGenericHTMLFormElement::BindToTree(BindContext& aContext,
}
void nsGenericHTMLFormElement::UnbindFromTree(bool aNullParent) {
// Save state before doing anything else.
SaveState();
if (IsFormAssociatedElement()) {
if (HTMLFormElement* form = GetFormInternal()) {
// Might need to unset form
@@ -2240,6 +2243,12 @@ void nsGenericHTMLFormElement::FieldSetDisabledChanged(bool aNotify) {
UpdateDisabledState(aNotify);
}
void nsGenericHTMLFormElement::SaveSubtreeState() {
SaveState();
nsGenericHTMLElement::SaveSubtreeState();
}
//----------------------------------------------------------------------
void nsGenericHTMLElement::Click(CallerType aCallerType) {
@@ -2573,12 +2582,6 @@ nsINode* nsGenericHTMLFormControlElement::GetScopeChainParent() const {
return mForm ? mForm : nsGenericHTMLElement::GetScopeChainParent();
}
void nsGenericHTMLFormControlElement::SaveSubtreeState() {
SaveState();
nsGenericHTMLFormElement::SaveSubtreeState();
}
nsIContent::IMEState nsGenericHTMLFormControlElement::GetDesiredIMEState() {
TextEditor* textEditor = GetTextEditorInternal();
if (!textEditor) {
@@ -2592,12 +2595,6 @@ nsIContent::IMEState nsGenericHTMLFormControlElement::GetDesiredIMEState() {
return state;
}
void nsGenericHTMLFormControlElement::UnbindFromTree(bool aNullParent) {
// Save state before doing anything
SaveState();
nsGenericHTMLFormElement::UnbindFromTree(aNullParent);
}
void nsGenericHTMLFormControlElement::GetAutocapitalize(
nsAString& aValue) const {
if (nsContentUtils::HasNonEmptyAttr(this, kNameSpaceID_None,
@@ -2962,7 +2959,7 @@ PresState* nsGenericHTMLFormControlElementWithState::GetPrimaryPresState() {
}
already_AddRefed<nsILayoutHistoryState>
nsGenericHTMLFormControlElementWithState::GetLayoutHistory(bool aRead) {
nsGenericHTMLFormElement::GetLayoutHistory(bool aRead) {
nsCOMPtr<Document> doc = GetUncomposedDoc();
if (!doc) {
return nullptr;