HTML: Add const qualified form_associated_element_to_html_element

Put the const cast in a common location to make the helper more
convenient to use.
This commit is contained in:
Shannon Booth 2024-07-28 15:52:59 +12:00 committed by Andreas Kling
parent ad32227c83
commit 28ed8e5d0f
Notes: github-actions[bot] 2024-08-01 10:18:02 +00:00
2 changed files with 2 additions and 1 deletions

View file

@ -29,7 +29,7 @@ void FormAssociatedElement::set_form(HTMLFormElement* form)
bool FormAssociatedElement::enabled() const bool FormAssociatedElement::enabled() const
{ {
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-disabled // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-disabled
auto const& html_element = const_cast<FormAssociatedElement&>(*this).form_associated_element_to_html_element(); auto const& html_element = form_associated_element_to_html_element();
// A form control is disabled if any of the following conditions are met: // A form control is disabled if any of the following conditions are met:
// 1. The element is a button, input, select, textarea, or form-associated custom element, and the disabled attribute is specified on this element (regardless of its value). // 1. The element is a button, input, select, textarea, or form-associated custom element, and the disabled attribute is specified on this element (regardless of its value).

View file

@ -83,6 +83,7 @@ public:
virtual String value() const { return String {}; } virtual String value() const { return String {}; }
virtual HTMLElement& form_associated_element_to_html_element() = 0; virtual HTMLElement& form_associated_element_to_html_element() = 0;
HTMLElement const& form_associated_element_to_html_element() const { return const_cast<FormAssociatedElement&>(*this).form_associated_element_to_html_element(); }
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-form-reset-control // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-form-reset-control
virtual void reset_algorithm() {}; virtual void reset_algorithm() {};