LibWeb: Indicate focus on contenteditable elements

This mirrors what Chrome and Firefox do.
This commit is contained in:
Jelle Raaijmakers 2025-08-20 10:20:07 +02:00 committed by Jelle Raaijmakers
commit 3a741b0ce6
Notes: github-actions[bot] 2025-08-20 09:37:31 +00:00
3 changed files with 4 additions and 1 deletions

View file

@ -4078,7 +4078,7 @@ bool Element::should_indicate_focus() const
// * If the element which supports keyboard input (such as an input element, or any other element that would // * 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. // triggers a virtual keyboard to be shown on focus if a physical keyboard were not present), indicate focus.
if (is<HTML::FormAssociatedTextControlElement>(this)) if (is<HTML::FormAssociatedTextControlElement>(this) || is_editable_or_editing_host())
return true; return true;
// * If the user interacts with the page via keyboard or some other non-pointing device, indicate focus. (This means // * If the user interacts with the page via keyboard or some other non-pointing device, indicate focus. (This means

View file

@ -1,2 +1,3 @@
INPUT: rgb(0, 0, 0) auto 3px INPUT: rgb(0, 0, 0) auto 3px
BUTTON: rgb(0, 0, 0) 0px BUTTON: rgb(0, 0, 0) 0px
DIV: rgb(0, 0, 0) auto 3px

View file

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<input value="foo"><br> <input value="foo"><br>
<button>bar</button> <button>bar</button>
<div contenteditable>baz</div>
<script src="include.js"></script> <script src="include.js"></script>
<script> <script>
test(() => { test(() => {
@ -13,5 +14,6 @@ test(() => {
runOutlineTest('input'); runOutlineTest('input');
runOutlineTest('button'); runOutlineTest('button');
runOutlineTest('div[contenteditable]');
}); });
</script> </script>