From af88a43e9a99ea3181eee76993c7e3e37406a3c2 Mon Sep 17 00:00:00 2001 From: Tete17 Date: Fri, 29 Aug 2025 17:56:20 +0200 Subject: [PATCH] LibWeb: Unify check_validity for form associated elements --- Libraries/LibWeb/HTML/FormAssociatedElement.cpp | 7 +++++++ Libraries/LibWeb/HTML/FormAssociatedElement.h | 3 +++ Libraries/LibWeb/HTML/HTMLButtonElement.idl | 2 +- Libraries/LibWeb/HTML/HTMLFieldSetElement.idl | 2 +- Libraries/LibWeb/HTML/HTMLInputElement.cpp | 6 ------ Libraries/LibWeb/HTML/HTMLInputElement.h | 1 - Libraries/LibWeb/HTML/HTMLObjectElement.idl | 2 +- Libraries/LibWeb/HTML/HTMLOutputElement.idl | 2 +- Libraries/LibWeb/HTML/HTMLSelectElement.cpp | 6 ------ Libraries/LibWeb/HTML/HTMLSelectElement.h | 1 - Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp | 6 ------ Libraries/LibWeb/HTML/HTMLTextAreaElement.h | 1 - 12 files changed, 14 insertions(+), 25 deletions(-) diff --git a/Libraries/LibWeb/HTML/FormAssociatedElement.cpp b/Libraries/LibWeb/HTML/FormAssociatedElement.cpp index 816367937a2..b09c8c9ab58 100644 --- a/Libraries/LibWeb/HTML/FormAssociatedElement.cpp +++ b/Libraries/LibWeb/HTML/FormAssociatedElement.cpp @@ -244,6 +244,13 @@ bool FormAssociatedElement::report_validity() 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 bool FormAssociatedElement::check_validity_steps() { diff --git a/Libraries/LibWeb/HTML/FormAssociatedElement.h b/Libraries/LibWeb/HTML/FormAssociatedElement.h index 1e8c647d425..17e70cf8beb 100644 --- a/Libraries/LibWeb/HTML/FormAssociatedElement.h +++ b/Libraries/LibWeb/HTML/FormAssociatedElement.h @@ -143,6 +143,9 @@ public: // 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-checkvalidity + bool check_validity(); + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validity GC::Ref validity() const; diff --git a/Libraries/LibWeb/HTML/HTMLButtonElement.idl b/Libraries/LibWeb/HTML/HTMLButtonElement.idl index c23b4152f58..b03dd132da5 100644 --- a/Libraries/LibWeb/HTML/HTMLButtonElement.idl +++ b/Libraries/LibWeb/HTML/HTMLButtonElement.idl @@ -31,7 +31,7 @@ interface HTMLButtonElement : HTMLElement { readonly attribute boolean willValidate; readonly attribute ValidityState validity; [FIXME] readonly attribute DOMString validationMessage; - [FIXME] boolean checkValidity(); + boolean checkValidity(); boolean reportValidity(); undefined setCustomValidity(DOMString error); diff --git a/Libraries/LibWeb/HTML/HTMLFieldSetElement.idl b/Libraries/LibWeb/HTML/HTMLFieldSetElement.idl index 1e9575112ac..594f07e1fbc 100644 --- a/Libraries/LibWeb/HTML/HTMLFieldSetElement.idl +++ b/Libraries/LibWeb/HTML/HTMLFieldSetElement.idl @@ -17,7 +17,7 @@ interface HTMLFieldSetElement : HTMLElement { readonly attribute boolean willValidate; [FIXME, SameObject] readonly attribute ValidityState validity; [FIXME] readonly attribute DOMString validationMessage; - [FIXME] boolean checkValidity(); + boolean checkValidity(); boolean reportValidity(); undefined setCustomValidity(DOMString error); }; diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 4827c284430..844db532acc 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -2920,12 +2920,6 @@ bool HTMLInputElement::will_validate() return is_candidate_for_constraint_validation(); } -// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity -WebIDL::ExceptionOr HTMLInputElement::check_validity() -{ - return check_validity_steps(); -} - Optional HTMLInputElement::default_role() const { // http://wpt.live/html-aam/roles-dynamic-switch.tentative.window.html "Disconnected " diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.h b/Libraries/LibWeb/HTML/HTMLInputElement.h index 39e3cd0e4a4..8f05b911e6f 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -160,7 +160,6 @@ public: WebIDL::ExceptionOr step_down(WebIDL::Long n = 1); bool will_validate(); - WebIDL::ExceptionOr check_validity(); WebIDL::ExceptionOr show_picker(); diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.idl b/Libraries/LibWeb/HTML/HTMLObjectElement.idl index 894575a88d3..1ce1876a4d3 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.idl +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.idl @@ -21,7 +21,7 @@ interface HTMLObjectElement : HTMLElement { readonly attribute boolean willValidate; readonly attribute ValidityState validity; [FIXME] readonly attribute DOMString validationMessage; - [FIXME] boolean checkValidity(); + boolean checkValidity(); boolean reportValidity(); undefined setCustomValidity(DOMString error); diff --git a/Libraries/LibWeb/HTML/HTMLOutputElement.idl b/Libraries/LibWeb/HTML/HTMLOutputElement.idl index e23a774a579..1d49e96192d 100644 --- a/Libraries/LibWeb/HTML/HTMLOutputElement.idl +++ b/Libraries/LibWeb/HTML/HTMLOutputElement.idl @@ -18,7 +18,7 @@ interface HTMLOutputElement : HTMLElement { readonly attribute boolean willValidate; readonly attribute ValidityState validity; [FIXME] readonly attribute DOMString validationMessage; - [FIXME] boolean checkValidity(); + boolean checkValidity(); boolean reportValidity(); undefined setCustomValidity(DOMString error); diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp index 1179839a7bd..b99c49009d1 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.cpp @@ -698,12 +698,6 @@ bool HTMLSelectElement::will_validate() 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 { return enabled(); diff --git a/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Libraries/LibWeb/HTML/HTMLSelectElement.h index d50250788d5..26834c9e84b 100644 --- a/Libraries/LibWeb/HTML/HTMLSelectElement.h +++ b/Libraries/LibWeb/HTML/HTMLSelectElement.h @@ -63,7 +63,6 @@ public: Vector> list_of_options() const; bool will_validate(); - bool check_validity(); // ^EventTarget // https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-select-element diff --git a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index 6e1a7e573b7..53afd620c9f 100644 --- a/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -239,12 +239,6 @@ bool HTMLTextAreaElement::will_validate() 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 WebIDL::Long HTMLTextAreaElement::max_length() const { diff --git a/Libraries/LibWeb/HTML/HTMLTextAreaElement.h b/Libraries/LibWeb/HTML/HTMLTextAreaElement.h index a79cfeb4583..6a8030a14f1 100644 --- a/Libraries/LibWeb/HTML/HTMLTextAreaElement.h +++ b/Libraries/LibWeb/HTML/HTMLTextAreaElement.h @@ -99,7 +99,6 @@ public: u32 text_length() const; bool will_validate(); - bool check_validity(); WebIDL::Long max_length() const; WebIDL::ExceptionOr set_max_length(WebIDL::Long);