mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibWeb: Ensure empty contenteditable boxes contain the hit test position
There are actually a couple of bugs here: 1. As of commitebda8fcf11, editing hosts are now excluded from Node::is_editable. Since this special hit test handling is specifically for contenteditable nodes, we would not enter this branch for these nodes. 2. We were not checking if the contenteditable node actually contained the hit testing position. So if a page had multiple empty editable nodes, we would just return whichever was hit test first. These bugs were exposed by7c9b3c08fa. This commit resulted in the text cursor hit test node being set as the document focus node. If we returned the wrong result, we would not set the correct node. This was seen on discord, where clicking the message box would result in the search box being focused.
This commit is contained in:
committed by
Tim Ledbetter
parent
f0ecadfae1
commit
a112eb4881
Notes:
github-actions[bot]
2026-02-21 01:03:17 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/a112eb48817 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8049 Reviewed-by: https://github.com/tcl3 ✅
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<style>
|
||||
div {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
<script src="../include.js"></script>
|
||||
<div id="div1" contenteditable></div>
|
||||
<div id="div2" contenteditable></div>
|
||||
<script>
|
||||
function clickElement(element) {
|
||||
let { x, y, width, height } = element.getBoundingClientRect();
|
||||
x += width / 2;
|
||||
y += height / 2;
|
||||
|
||||
internals.click(x, y);
|
||||
}
|
||||
|
||||
test(() => {
|
||||
clickElement(div1);
|
||||
printElement(document.getSelection().focusNode);
|
||||
|
||||
clickElement(div2);
|
||||
printElement(document.getSelection().focusNode);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user