Truly independent web browser
LibWeb: Limit keyboard-input focus indication to text controls
Andreas Klingcfd31677c11e
diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cppindex 2ee0032bbbf..586a7862556 100644--- a/Libraries/LibWeb/DOM/Element.cpp+++ b/Libraries/LibWeb/DOM/Element.cpp@@ -7210,7 +7210,9 @@ bool Element::should_indicate_focus() const// * If the element which supports keyboard input (such as an input element, or any other element that would// triggers a virtual keyboard to be shown on focus if a physical keyboard were not present), indicate focus.- if (is<HTML::FormAssociatedTextControlElement>(this) || is_editable_or_editing_host())+ if (is<HTML::HTMLTextAreaElement>(this) || is_editable_or_editing_host())+ return true;+ if (auto const* input = as_if<HTML::HTMLInputElement>(this); input && input->has_selectable_text())return true;// * If the user interacts with the page via keyboard or some other non-pointing device, indicate focus. (This meansdiff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-003.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-003.txtindex 5264ff3264a..46fc6e6b43e 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-003.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-003.txt@@ -2,17 +2,16 @@ Harness status: OKFound 12 tests-4 Pass-8 Fail+12 PassPass Focus element SPAN#el-1 via mouse should NOT match :focus-visible as it does NOT support keyboard inputPass Focus element SPAN#el-2 via mouse should NOT match :focus-visible as it does NOT support keyboard inputPass Focus element SPAN#el-3 via mouse should NOT match :focus-visible as it does NOT support keyboard inputPass Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input-Fail Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input-Fail Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input-Fail Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input-Fail Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input-Fail Focus element INPUT#el-9 via mouse should NOT match :focus-visible as it does NOT support keyboard input-Fail Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input-Fail Focus element INPUT#el-12 via mouse should NOT match :focus-visible as it does NOT support keyboard input-Fail Focus element INPUT#el-13 via mouse should NOT match :focus-visible as it does NOT support keyboard input\ No newline at end of file+Pass Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element INPUT#el-9 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element INPUT#el-12 via mouse should NOT match :focus-visible as it does NOT support keyboard input+Pass Focus element INPUT#el-13 via mouse should NOT match :focus-visible as it does NOT support keyboard input\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-004.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-004.txtindex 11d0251aa58..1773343038b 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-004.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-004.txt@@ -2,15 +2,14 @@ Harness status: OKFound 10 tests-4 Pass-6 Fail+10 PassPass Focus element SPAN#el-1 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"Pass Focus element SPAN#el-2 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"Pass Focus element SPAN#el-3 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"Pass Focus element BUTTON#el-4 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"-Fail Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"-Fail Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"-Fail Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"-Fail Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"-Fail Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"-Fail Focus element INPUT#el-11 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"\ No newline at end of file+Pass Focus element INPUT#el-5 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Pass Focus element INPUT#el-6 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Pass Focus element INPUT#el-7 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Pass Focus element INPUT#el-8 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Pass Focus element INPUT#el-10 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"+Pass Focus element INPUT#el-11 via mouse should NOT match :focus-visible as it does NOT support keyboard input - not affected by "appearance: none"\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-026.txt b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-026.txtindex c58b573ba2c..71c031641ae 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-026.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/selectors/focus-visible-026.txt@@ -2,7 +2,6 @@ Harness status: OKFound 2 tests-1 Pass-1 Fail+2 PassPass ":focus-visible" should be a valid selector-Fail :focus-visible does NOT match when a checkbox is focused via click on the associated label\ No newline at end of file+Pass :focus-visible does NOT match when a checkbox is focused via click on the associated label\ No newline at end of file