LibWeb: Unify report_validity for form associated elements

This function was implemented in a few classes but is a common element
in all form associated elements and the functionality should be there.

With these minimal changes we get to implement 4 idl functions for free.
This commit is contained in:
Tete17 2025-08-29 17:52:55 +02:00 committed by Tim Ledbetter
commit 44053ed3c2
Notes: github-actions[bot] 2025-08-29 18:29:11 +00:00
12 changed files with 14 additions and 25 deletions

View file

@ -237,6 +237,13 @@ WebIDL::ExceptionOr<void> FormAssociatedElement::set_form_action(String const& v
return html_element.set_attribute(HTML::AttributeNames::formaction, value);
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-reportvalidity
bool FormAssociatedElement::report_validity()
{
// The reportValidity() method, when invoked, must run the report validity steps on this element.
return report_validity_steps();
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#check-validity-steps
bool FormAssociatedElement::check_validity_steps()
{

View file

@ -140,6 +140,9 @@ public:
String form_action() const;
WebIDL::ExceptionOr<void> set_form_action(String const&);
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-reportvalidity
bool report_validity();
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validity
GC::Ref<ValidityState const> validity() const;

View file

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

View file

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

View file

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

View file

@ -161,7 +161,6 @@ public:
bool will_validate();
WebIDL::ExceptionOr<bool> check_validity();
WebIDL::ExceptionOr<bool> report_validity();
WebIDL::ExceptionOr<void> show_picker();

View file

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

View file

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

View file

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

View file

@ -64,7 +64,6 @@ public:
bool will_validate();
bool check_validity();
bool report_validity();
// ^EventTarget
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-select-element

View file

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

View file

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