Procházet zdrojové kódy

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.
Shannon Booth před 1 rokem
rodič
revize
28ed8e5d0f

+ 1 - 1
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<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:
     // 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 - 0
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<FormAssociatedElement&>(*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() {};