Bug 1693969 - Remove <form novalidate> handling from :-moz-ui-{valid,invalid} pseudo-classes. r=smaug

There's no way to know whether the submission will actually be
validated, because formnovalidate on submit buttons is a thing (and even
if all the submit controls had formnovalidate, you could still submit
the form and validate it via form.submit()), so it seems better to make
these pseudo-classes not depend on this.

Differential Revision: https://phabricator.services.mozilla.com/D105968
This commit is contained in:
Emilio Cobos Álvarez
2021-02-23 11:26:17 +00:00
parent 1f69a3b842
commit c1b452ece1
26 changed files with 22 additions and 180 deletions

View File

@@ -774,11 +774,9 @@ EventStates HTMLTextAreaElement::IntrinsicState() const {
} else {
state |= NS_EVENT_STATE_INVALID;
// :-moz-ui-invalid always apply if the element suffers from a custom
// error and never applies if novalidate is set on the form owner.
if ((!mForm ||
!mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) &&
(GetValidityState(VALIDITY_STATE_CUSTOM_ERROR) ||
(mCanShowInvalidUI && ShouldShowValidityUI()))) {
// error.
if (GetValidityState(VALIDITY_STATE_CUSTOM_ERROR) ||
(mCanShowInvalidUI && ShouldShowValidityUI())) {
state |= NS_EVENT_STATE_MOZ_UI_INVALID;
}
}
@@ -788,14 +786,11 @@ EventStates HTMLTextAreaElement::IntrinsicState() const {
// :-moz-ui-invalid applying before it was focused ;
// 2. The element is either valid or isn't allowed to have
// :-moz-ui-invalid applying ;
// 3. The element has no form owner or its form owner doesn't have the
// novalidate attribute set ;
// 4. The element has already been modified or the user tried to submit the
// 3. The element has already been modified or the user tried to submit the
// form owner while invalid.
if ((!mForm || !mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) &&
(mCanShowValidUI && ShouldShowValidityUI() &&
(IsValid() || (state.HasState(NS_EVENT_STATE_MOZ_UI_INVALID) &&
!mCanShowInvalidUI)))) {
if (mCanShowValidUI && ShouldShowValidityUI() &&
(IsValid() || (state.HasState(NS_EVENT_STATE_MOZ_UI_INVALID) &&
!mCanShowInvalidUI))) {
state |= NS_EVENT_STATE_MOZ_UI_VALID;
}
}