LibWeb: Unify check_validity for form associated elements

This commit is contained in:
Tete17 2025-08-29 17:56:20 +02:00 committed by Tim Ledbetter
commit af88a43e9a
Notes: github-actions[bot] 2025-08-29 18:29:05 +00:00
12 changed files with 14 additions and 25 deletions

View file

@ -244,6 +244,13 @@ bool FormAssociatedElement::report_validity()
return report_validity_steps(); return report_validity_steps();
} }
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity
bool FormAssociatedElement::check_validity()
{
// The checkValidity() method, when invoked, must run the check validity steps on this element.
return check_validity_steps();
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#check-validity-steps // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#check-validity-steps
bool FormAssociatedElement::check_validity_steps() bool FormAssociatedElement::check_validity_steps()
{ {

View file

@ -143,6 +143,9 @@ public:
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-reportvalidity // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-reportvalidity
bool report_validity(); bool report_validity();
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity
bool check_validity();
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validity // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validity
GC::Ref<ValidityState const> validity() const; GC::Ref<ValidityState const> validity() const;

View file

@ -31,7 +31,7 @@ interface HTMLButtonElement : HTMLElement {
readonly attribute boolean willValidate; readonly attribute boolean willValidate;
readonly attribute ValidityState validity; readonly attribute ValidityState validity;
[FIXME] readonly attribute DOMString validationMessage; [FIXME] readonly attribute DOMString validationMessage;
[FIXME] boolean checkValidity(); boolean checkValidity();
boolean reportValidity(); boolean reportValidity();
undefined setCustomValidity(DOMString error); undefined setCustomValidity(DOMString error);

View file

@ -17,7 +17,7 @@ interface HTMLFieldSetElement : HTMLElement {
readonly attribute boolean willValidate; readonly attribute boolean willValidate;
[FIXME, SameObject] readonly attribute ValidityState validity; [FIXME, SameObject] readonly attribute ValidityState validity;
[FIXME] readonly attribute DOMString validationMessage; [FIXME] readonly attribute DOMString validationMessage;
[FIXME] boolean checkValidity(); boolean checkValidity();
boolean reportValidity(); boolean reportValidity();
undefined setCustomValidity(DOMString error); undefined setCustomValidity(DOMString error);
}; };

View file

@ -2920,12 +2920,6 @@ bool HTMLInputElement::will_validate()
return is_candidate_for_constraint_validation(); return is_candidate_for_constraint_validation();
} }
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity
WebIDL::ExceptionOr<bool> HTMLInputElement::check_validity()
{
return check_validity_steps();
}
Optional<ARIA::Role> HTMLInputElement::default_role() const Optional<ARIA::Role> HTMLInputElement::default_role() const
{ {
// http://wpt.live/html-aam/roles-dynamic-switch.tentative.window.html "Disconnected <input type=checkbox switch>" // http://wpt.live/html-aam/roles-dynamic-switch.tentative.window.html "Disconnected <input type=checkbox switch>"

View file

@ -160,7 +160,6 @@ public:
WebIDL::ExceptionOr<void> step_down(WebIDL::Long n = 1); WebIDL::ExceptionOr<void> step_down(WebIDL::Long n = 1);
bool will_validate(); bool will_validate();
WebIDL::ExceptionOr<bool> check_validity();
WebIDL::ExceptionOr<void> show_picker(); WebIDL::ExceptionOr<void> show_picker();

View file

@ -21,7 +21,7 @@ interface HTMLObjectElement : HTMLElement {
readonly attribute boolean willValidate; readonly attribute boolean willValidate;
readonly attribute ValidityState validity; readonly attribute ValidityState validity;
[FIXME] readonly attribute DOMString validationMessage; [FIXME] readonly attribute DOMString validationMessage;
[FIXME] boolean checkValidity(); boolean checkValidity();
boolean reportValidity(); boolean reportValidity();
undefined setCustomValidity(DOMString error); undefined setCustomValidity(DOMString error);

View file

@ -18,7 +18,7 @@ interface HTMLOutputElement : HTMLElement {
readonly attribute boolean willValidate; readonly attribute boolean willValidate;
readonly attribute ValidityState validity; readonly attribute ValidityState validity;
[FIXME] readonly attribute DOMString validationMessage; [FIXME] readonly attribute DOMString validationMessage;
[FIXME] boolean checkValidity(); boolean checkValidity();
boolean reportValidity(); boolean reportValidity();
undefined setCustomValidity(DOMString error); undefined setCustomValidity(DOMString error);

View file

@ -698,12 +698,6 @@ bool HTMLSelectElement::will_validate()
return is_candidate_for_constraint_validation(); return is_candidate_for_constraint_validation();
} }
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity
bool HTMLSelectElement::check_validity()
{
return check_validity_steps();
}
bool HTMLSelectElement::is_focusable() const bool HTMLSelectElement::is_focusable() const
{ {
return enabled(); return enabled();

View file

@ -63,7 +63,6 @@ public:
Vector<GC::Root<HTMLOptionElement>> list_of_options() const; Vector<GC::Root<HTMLOptionElement>> list_of_options() const;
bool will_validate(); bool will_validate();
bool check_validity();
// ^EventTarget // ^EventTarget
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-select-element // https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-select-element

View file

@ -239,12 +239,6 @@ bool HTMLTextAreaElement::will_validate()
return is_candidate_for_constraint_validation(); return is_candidate_for_constraint_validation();
} }
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity
bool HTMLTextAreaElement::check_validity()
{
return check_validity_steps();
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-maxlength // https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-maxlength
WebIDL::Long HTMLTextAreaElement::max_length() const WebIDL::Long HTMLTextAreaElement::max_length() const
{ {

View file

@ -99,7 +99,6 @@ public:
u32 text_length() const; u32 text_length() const;
bool will_validate(); bool will_validate();
bool check_validity();
WebIDL::Long max_length() const; WebIDL::Long max_length() const;
WebIDL::ExceptionOr<void> set_max_length(WebIDL::Long); WebIDL::ExceptionOr<void> set_max_length(WebIDL::Long);