diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 203c9ec9b9..1dbecef2eb 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -258,6 +258,20 @@ unsigned HTMLFormElement::length() const return elements()->length(); } +// https://html.spec.whatwg.org/multipage/forms.html#dom-form-checkvalidity +WebIDL::ExceptionOr HTMLFormElement::check_validity() +{ + dbgln("(STUBBED) HTMLFormElement::check_validity(). Called on: {}", debug_description()); + return true; +} + +// https://html.spec.whatwg.org/multipage/forms.html#dom-form-reportvalidity +WebIDL::ExceptionOr HTMLFormElement::report_validity() +{ + dbgln("(STUBBED) HTMLFormElement::report_validity(). Called on: {}", debug_description()); + return true; +} + // https://html.spec.whatwg.org/multipage/forms.html#category-submit ErrorOr>> HTMLFormElement::get_submittable_elements() { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h index fec8369c0e..a2ca9f1985 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -40,6 +40,9 @@ public: JS::NonnullGCPtr elements() const; unsigned length() const; + WebIDL::ExceptionOr check_validity(); + WebIDL::ExceptionOr report_validity(); + // https://www.w3.org/TR/html-aria/#el-form virtual Optional default_role() const override { return ARIA::Role::form; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl index 1e4cb3a2f3..4f23124d1a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.idl @@ -12,6 +12,8 @@ interface HTMLFormElement : HTMLElement { undefined submit(); [CEReactions] undefined reset(); + boolean checkValidity(); + boolean reportValidity(); // FIXME: Should be a HTMLFormControlsCollection [SameObject] readonly attribute HTMLCollection elements; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 62a2101d40..4ac1c0e4da 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -874,6 +874,34 @@ i32 HTMLInputElement::default_tab_index_value() const return 0; } +// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity +WebIDL::ExceptionOr HTMLInputElement::check_validity() +{ + dbgln("(STUBBED) HTMLInputElement::check_validity(). Called on: {}", debug_description()); + return true; +} + +// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-reportvalidity +WebIDL::ExceptionOr HTMLInputElement::report_validity() +{ + dbgln("(STUBBED) HTMLInputElement::report_validity(). Called on: {}", debug_description()); + return true; +} + +// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-setcustomvalidity +void HTMLInputElement::set_custom_validity(DeprecatedString const& error) +{ + dbgln("(STUBBED) HTMLInputElement::set_custom_validity(error={}). Called on: {}", error, debug_description()); + return; +} + +// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-select +WebIDL::ExceptionOr HTMLInputElement::select() +{ + dbgln("(STUBBED) HTMLInputElement::select(). Called on: {}", debug_description()); + return {}; +} + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-setselectionrange WebIDL::ExceptionOr HTMLInputElement::set_selection_range(u32 start, u32 end, DeprecatedString const& direction) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 2d85ed6409..582e16434a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -87,6 +87,11 @@ public: // https://html.spec.whatwg.org/multipage/input.html#update-the-file-selection void update_the_file_selection(JS::NonnullGCPtr); + WebIDL::ExceptionOr check_validity(); + WebIDL::ExceptionOr report_validity(); + void set_custom_validity(DeprecatedString const&); + + WebIDL::ExceptionOr select(); WebIDL::ExceptionOr set_selection_range(u32 start, u32 end, DeprecatedString const& direction); WebIDL::ExceptionOr show_picker(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl index def33de5af..04f49cf7ba 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl @@ -38,6 +38,11 @@ interface HTMLInputElement : HTMLElement { [Reflect] attribute DOMString align; [Reflect=usemap] attribute DOMString useMap; + boolean checkValidity(); + boolean reportValidity(); + undefined setCustomValidity(DOMString error); + + undefined select(); undefined setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction); undefined showPicker();