From 28ed8e5d0f79fc9d961f746367127e137faaf46b Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 28 Jul 2024 15:52:59 +1200 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/HTML/FormAssociatedElement.cpp | 2 +- Userland/Libraries/LibWeb/HTML/FormAssociatedElement.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/FormAssociatedElement.cpp b/Userland/Libraries/LibWeb/HTML/FormAssociatedElement.cpp index d13df20e6d4..51439c210ed 100644 --- a/Userland/Libraries/LibWeb/HTML/FormAssociatedElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/FormAssociatedElement.cpp @@ -29,7 +29,7 @@ void FormAssociatedElement::set_form(HTMLFormElement* form) bool FormAssociatedElement::enabled() const { // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-disabled - auto const& html_element = const_cast(*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: // 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). diff --git a/Userland/Libraries/LibWeb/HTML/FormAssociatedElement.h b/Userland/Libraries/LibWeb/HTML/FormAssociatedElement.h index 61dbb83cb61..2950432e162 100644 --- a/Userland/Libraries/LibWeb/HTML/FormAssociatedElement.h +++ b/Userland/Libraries/LibWeb/HTML/FormAssociatedElement.h @@ -83,6 +83,7 @@ public: virtual String value() const { return String {}; } virtual HTMLElement& form_associated_element_to_html_element() = 0; + HTMLElement const& form_associated_element_to_html_element() const { return const_cast(*this).form_associated_element_to_html_element(); } // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-form-reset-control virtual void reset_algorithm() {};