From 80506a161f947a37ad7dffd660c6abc468f4bf75 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 26 Mar 2022 18:02:41 +0000 Subject: [PATCH] LibWeb: Make any HTMLInputElement with type != hidden focusable From the HTML spec: Modulo platform conventions, it is suggested that the following elements should be considered as focusable areas and be sequentially focusable: ... - input elements whose type attribute are not in the Hidden state ... --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 5 ----- Userland/Libraries/LibWeb/HTML/HTMLInputElement.h | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 924640e3b7..b4c05eeef5 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -208,11 +208,6 @@ void HTMLInputElement::did_receive_focus() browsing_context->set_cursor_position(DOM::Position { *m_text_node, 0 }); } -bool HTMLInputElement::is_focusable() const -{ - return m_text_node; -} - void HTMLInputElement::parse_attribute(FlyString const& name, String const& value) { HTMLElement::parse_attribute(name, value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 3e2ed76d33..543295b653 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -78,8 +78,11 @@ public: void did_edit_text_node(Badge); - virtual bool is_focusable() const override; + // ^EventTarget + // https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-input-element + virtual bool is_focusable() const override { return m_type != TypeAttributeState::Hidden; } + // ^HTMLElement virtual void parse_attribute(FlyString const&, String const&) override; virtual void did_remove_attribute(FlyString const&) override;