Backed out 3 changesets (bug 1551758) for causing wpt failures on form-submission-algorithm.html. CLOSED TREE

Backed out changeset 7f73f8d6d3b1 (bug 1551758)
Backed out changeset 295015e6e79b (bug 1551758)
Backed out changeset 6ffaf0da08d9 (bug 1551758)
This commit is contained in:
Arthur Iakab
2019-11-20 18:05:34 +02:00
parent 57f00ebc7f
commit b3340c2de9
7 changed files with 113 additions and 113 deletions

View File

@@ -119,8 +119,7 @@ HTMLFormElement::HTMLFormElement(
mNotifiedObservers(false),
mNotifiedObserversResult(false),
mEverTriedInvalidSubmit(false),
mIsConstructingEntryList(false),
mIsFiringSubmissionEvents(false) {
mIsConstructingEntryList(false) {
// We start out valid.
AddStatesSilently(NS_EVENT_STATE_VALID);
}
@@ -219,70 +218,6 @@ void HTMLFormElement::GetMethod(nsAString& aValue) {
GetEnumAttr(nsGkAtoms::method, kFormDefaultMethod->tag, aValue);
}
// https://html.spec.whatwg.org/multipage/forms.html#concept-form-submit
void HTMLFormElement::MaybeSubmit(Element* aSubmitter) {
#ifdef DEBUG
if (aSubmitter) {
nsCOMPtr<nsIFormControl> fc = do_QueryInterface(aSubmitter);
MOZ_ASSERT(fc);
MOZ_ASSERT(fc->IsSubmitControl(), "aSubmitter is not a submit control?");
}
#endif
// 1-4 of
// https://html.spec.whatwg.org/multipage/forms.html#concept-form-submit
Document* doc = GetComposedDoc();
if (mIsConstructingEntryList || !doc ||
(doc->GetSandboxFlags() & SANDBOXED_FORMS)) {
return;
}
// 6.1. If form's firing submission events is true, then return.
if (mIsFiringSubmissionEvents) {
return;
}
// 6.2. Set form's firing submission events to true.
AutoRestore<bool> resetFiringSubmissionEventsFlag(mIsFiringSubmissionEvents);
mIsFiringSubmissionEvents = true;
// 6.3. If the submitter element's no-validate state is false, then
// interactively validate the constraints of form and examine the result.
// If the result is negative (i.e., the constraint validation concluded
// that there were invalid fields and probably informed the user of this)
bool noValidateState =
HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate) ||
(aSubmitter &&
aSubmitter->HasAttr(kNameSpaceID_None, nsGkAtoms::formnovalidate));
if (!noValidateState && !CheckValidFormSubmission()) {
return;
}
// If |PresShell::Destroy| has been called due to handling the event the pres
// context will return a null pres shell. See bug 125624. Using presShell to
// dispatch the event. It makes sure that event is not handled if the window
// is being destroyed.
if (RefPtr<PresShell> presShell = doc->GetPresShell()) {
InternalFormEvent event(true, eFormSubmit);
event.mOriginator = aSubmitter;
nsEventStatus status = nsEventStatus_eIgnore;
presShell->HandleDOMEventWithTarget(this, &event, &status);
}
}
void HTMLFormElement::MaybeReset(Element* aSubmitter) {
// If |PresShell::Destroy| has been called due to handling the event the pres
// context will return a null pres shell. See bug 125624. Using presShell to
// dispatch the event. It makes sure that event is not handled if the window
// is being destroyed.
if (RefPtr<PresShell> presShell = OwnerDoc()->GetPresShell()) {
InternalFormEvent event(true, eFormReset);
event.mOriginator = aSubmitter;
nsEventStatus status = nsEventStatus_eIgnore;
presShell->HandleDOMEventWithTarget(this, &event, &status);
}
}
void HTMLFormElement::Submit(ErrorResult& aRv) {
// Send the submit event
if (mPendingSubmission) {
@@ -1928,6 +1863,38 @@ One should be implemented!");
return result;
}
bool HTMLFormElement::SubmissionCanProceed(Element* aSubmitter) {
#ifdef DEBUG
if (aSubmitter) {
nsCOMPtr<nsIFormControl> fc = do_QueryInterface(aSubmitter);
MOZ_ASSERT(fc);
uint32_t type = fc->ControlType();
MOZ_ASSERT(type == NS_FORM_INPUT_SUBMIT || type == NS_FORM_INPUT_IMAGE ||
type == NS_FORM_BUTTON_SUBMIT,
"aSubmitter is not a submit control?");
}
#endif
// Modified step 2 of
// https://html.spec.whatwg.org/multipage/forms.html#concept-form-submit --
// we're not checking whether the node document is disconnected yet...
if (OwnerDoc()->GetSandboxFlags() & SANDBOXED_FORMS) {
return false;
}
if (HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) {
return true;
}
if (aSubmitter &&
aSubmitter->HasAttr(kNameSpaceID_None, nsGkAtoms::formnovalidate)) {
return true;
}
return CheckValidFormSubmission();
}
void HTMLFormElement::UpdateValidity(bool aElementValidity) {
if (aElementValidity) {
--mInvalidElementsCount;