From 7a6813cdead6f98fc792be7feb21790b0f109a65 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Wed, 20 Nov 2024 05:25:26 +0900 Subject: [PATCH] LibWeb: Fix input@type=button|submit|reset accessible-name computation This change makes Ladybird conform to the requirements in the HTML-AAM spec at https://w3c.github.io/html-aam/#accname-computation for the cases of HTML input@type=button, input@type=submit, and input@type=reset elements. Otherwise, without this change, Ladybird fails to expose the expected accessible names for those cases. --- Libraries/LibWeb/DOM/Node.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index ef1cf3eb5e8..8f0e5330901 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -2403,6 +2403,13 @@ ErrorOr Node::name_or_description(NameOrDescription target, Document con } if (is(*element)) { auto& input = (const_cast(static_cast(*element))); + // https://w3c.github.io/html-aam/#input-type-button-input-type-submit-and-input-type-reset-accessible-name-computation + // Otherwise use the value attribute. + if (input.type_state() == HTML::HTMLInputElement::TypeAttributeState::Button + || input.type_state() == HTML::HTMLInputElement::TypeAttributeState::SubmitButton + || input.type_state() == HTML::HTMLInputElement::TypeAttributeState::ResetButton) + if (auto value = input.get_attribute(HTML::AttributeNames::value); value.has_value()) + return value.release_value(); // https://w3c.github.io/html-aam/#input-type-image-accessible-name-computation // Otherwise use alt attribute if present and its value is not the empty string. if (input.type_state() == HTML::HTMLInputElement::TypeAttributeState::ImageButton)