mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Unify will_validate for form associated elements
We had the same implementation in quiet a few places. With this change we unify them in a single place
This commit is contained in:
parent
af88a43e9a
commit
8ab568bc76
Notes:
github-actions[bot]
2025-08-29 18:28:58 +00:00
Author: https://github.com/tete17
Commit: 8ab568bc76
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6024
Reviewed-by: https://github.com/tcl3 ✅
16 changed files with 11 additions and 75 deletions
|
@ -251,6 +251,14 @@ bool FormAssociatedElement::check_validity()
|
||||||
return check_validity_steps();
|
return check_validity_steps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
||||||
|
bool FormAssociatedElement::will_validate() const
|
||||||
|
{
|
||||||
|
// The willValidate attribute's getter must return true, if this element is a candidate for constraint validation,
|
||||||
|
// and false otherwise (i.e., false if any conditions are barring it from constraint validation).
|
||||||
|
return is_candidate_for_constraint_validation();
|
||||||
|
}
|
||||||
|
|
||||||
// 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()
|
||||||
{
|
{
|
||||||
|
|
|
@ -146,6 +146,9 @@ public:
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity
|
||||||
bool check_validity();
|
bool check_validity();
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
||||||
|
bool will_validate() const;
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
||||||
|
|
|
@ -273,13 +273,6 @@ void HTMLButtonElement::activation_behavior(DOM::Event const& event)
|
||||||
PopoverInvokerElement::popover_target_activation_behaviour(*this, as<DOM::Node>(*event.target()));
|
PopoverInvokerElement::popover_target_activation_behaviour(*this, as<DOM::Node>(*event.target()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
|
||||||
bool HTMLButtonElement::will_validate()
|
|
||||||
{
|
|
||||||
// The willValidate attribute's getter must return true, if this element is a candidate for constraint validation
|
|
||||||
return is_candidate_for_constraint_validation();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HTMLButtonElement::is_focusable() const
|
bool HTMLButtonElement::is_focusable() const
|
||||||
{
|
{
|
||||||
return enabled();
|
return enabled();
|
||||||
|
|
|
@ -44,8 +44,6 @@ public:
|
||||||
|
|
||||||
virtual void form_associated_element_attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
virtual void form_associated_element_attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
||||||
|
|
||||||
bool will_validate();
|
|
||||||
|
|
||||||
// ^EventTarget
|
// ^EventTarget
|
||||||
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-button-element
|
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-button-element
|
||||||
// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
|
// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
|
||||||
|
|
|
@ -88,15 +88,4 @@ GC::Ptr<Layout::Node> HTMLFieldSetElement::create_layout_node(GC::Ref<CSS::Compu
|
||||||
return heap().allocate<Layout::FieldSetBox>(document(), *this, style);
|
return heap().allocate<Layout::FieldSetBox>(document(), *this, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
|
||||||
bool HTMLFieldSetElement::will_validate()
|
|
||||||
{
|
|
||||||
// The willValidate attribute's getter must return true, if this element is a candidate for constraint validation,
|
|
||||||
// and false otherwise (i.e., false if any conditions are barring it from constraint validation).
|
|
||||||
// A submittable element is a candidate for constraint validation
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
|
|
||||||
// Submittable elements: button, input, select, textarea, form-associated custom elements [but not fieldset]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,6 @@ public:
|
||||||
|
|
||||||
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::group; }
|
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::group; }
|
||||||
|
|
||||||
static bool will_validate();
|
|
||||||
|
|
||||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||||
Layout::FieldSetBox* layout_node();
|
Layout::FieldSetBox* layout_node();
|
||||||
Layout::FieldSetBox const* layout_node() const;
|
Layout::FieldSetBox const* layout_node() const;
|
||||||
|
|
|
@ -2913,13 +2913,6 @@ WebIDL::ExceptionOr<void> HTMLInputElement::step_up_or_down(bool is_down, WebIDL
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
|
||||||
bool HTMLInputElement::will_validate()
|
|
||||||
{
|
|
||||||
// The willValidate attribute's getter must return true, if this element is a candidate for constraint validation
|
|
||||||
return is_candidate_for_constraint_validation();
|
|
||||||
}
|
|
||||||
|
|
||||||
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>"
|
||||||
|
|
|
@ -159,8 +159,6 @@ public:
|
||||||
WebIDL::ExceptionOr<void> step_up(WebIDL::Long n = 1);
|
WebIDL::ExceptionOr<void> step_up(WebIDL::Long n = 1);
|
||||||
WebIDL::ExceptionOr<void> step_down(WebIDL::Long n = 1);
|
WebIDL::ExceptionOr<void> step_down(WebIDL::Long n = 1);
|
||||||
|
|
||||||
bool will_validate();
|
|
||||||
|
|
||||||
WebIDL::ExceptionOr<void> show_picker();
|
WebIDL::ExceptionOr<void> show_picker();
|
||||||
|
|
||||||
// ^EventTarget
|
// ^EventTarget
|
||||||
|
|
|
@ -81,17 +81,6 @@ void HTMLObjectElement::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(m_document_observer);
|
visitor.visit(m_document_observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
|
||||||
bool HTMLObjectElement::will_validate()
|
|
||||||
{
|
|
||||||
// The willValidate attribute's getter must return true, if this element is a candidate for constraint validation,
|
|
||||||
// and false otherwise (i.e., false if any conditions are barring it from constraint validation).
|
|
||||||
// A submittable element is a candidate for constraint validation
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
|
|
||||||
// Submittable elements: button, input, select, textarea, form-associated custom elements [but not object]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HTMLObjectElement::form_associated_element_attribute_changed(FlyString const& name, Optional<String> const&, Optional<String> const&, Optional<FlyString> const&)
|
void HTMLObjectElement::form_associated_element_attribute_changed(FlyString const& name, Optional<String> const&, Optional<String> const&, Optional<FlyString> const&)
|
||||||
{
|
{
|
||||||
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element
|
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element
|
||||||
|
|
|
@ -47,8 +47,6 @@ public:
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
static bool will_validate();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLObjectElement(DOM::Document&, DOM::QualifiedName);
|
HTMLObjectElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
|
|
@ -110,15 +110,4 @@ void HTMLOutputElement::clear_algorithm()
|
||||||
string_replace_all({});
|
string_replace_all({});
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
|
||||||
bool HTMLOutputElement::will_validate()
|
|
||||||
{
|
|
||||||
// The willValidate attribute's getter must return true, if this element is a candidate for constraint validation,
|
|
||||||
// and false otherwise (i.e., false if any conditions are barring it from constraint validation).
|
|
||||||
// A submittable element is a candidate for constraint validation
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
|
|
||||||
// Submittable elements: button, input, select, textarea, form-associated custom elements [but not output]
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,8 +57,6 @@ public:
|
||||||
// https://www.w3.org/TR/html-aria/#el-output
|
// https://www.w3.org/TR/html-aria/#el-output
|
||||||
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::status; }
|
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::status; }
|
||||||
|
|
||||||
static bool will_validate();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLOutputElement(DOM::Document&, DOM::QualifiedName);
|
HTMLOutputElement(DOM::Document&, DOM::QualifiedName);
|
||||||
|
|
||||||
|
|
|
@ -691,13 +691,6 @@ void HTMLSelectElement::update_selectedness()
|
||||||
update_inner_text_element();
|
update_inner_text_element();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
|
||||||
bool HTMLSelectElement::will_validate()
|
|
||||||
{
|
|
||||||
// The willValidate attribute's getter must return true, if this element is a candidate for constraint validation
|
|
||||||
return is_candidate_for_constraint_validation();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HTMLSelectElement::is_focusable() const
|
bool HTMLSelectElement::is_focusable() const
|
||||||
{
|
{
|
||||||
return enabled();
|
return enabled();
|
||||||
|
|
|
@ -62,8 +62,6 @@ public:
|
||||||
|
|
||||||
Vector<GC::Root<HTMLOptionElement>> list_of_options() const;
|
Vector<GC::Root<HTMLOptionElement>> list_of_options() const;
|
||||||
|
|
||||||
bool will_validate();
|
|
||||||
|
|
||||||
// ^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
|
||||||
// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
|
// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
|
||||||
|
|
|
@ -232,13 +232,6 @@ u32 HTMLTextAreaElement::text_length() const
|
||||||
return api_value().length_in_code_units();
|
return api_value().length_in_code_units();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
|
|
||||||
bool HTMLTextAreaElement::will_validate()
|
|
||||||
{
|
|
||||||
// The willValidate attribute's getter must return true, if this element is a candidate for constraint validation
|
|
||||||
return is_candidate_for_constraint_validation();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,8 +98,6 @@ public:
|
||||||
|
|
||||||
u32 text_length() const;
|
u32 text_length() const;
|
||||||
|
|
||||||
bool will_validate();
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue