Files
ladybird/Tests/LibWeb/Text/input/selection-above-text-fragment.html
Jelle Raaijmakers b6deacf6b0 LibWeb: Support hit testing fully above fragments
This allows us to consider fragments for hit testing even though the
cursor moved fully above them. This will allow us to select all the
contents in a <textarea> when you drag the mouse all the way to the top,
beyond the <textarea>'s top edge.
2026-02-11 11:04:53 +01:00

33 lines
880 B
HTML

<!DOCTYPE html>
<style>
#box {
padding: 20px;
font-size: 14px;
line-height: 1.5;
}
</style>
<div id="box">Hello world</div>
<script src="include.js"></script>
<script>
test(() => {
document.body.offsetWidth; // force layout
const rect = box.getBoundingClientRect();
const textNode = box.firstChild;
// Click within the text, past "Hello ".
const startX = rect.x + 20 + 50;
const startY = rect.y + 20 + 5;
internals.mouseDown(startX, startY);
// Move into the padding area above the text fragment.
internals.mouseMove(rect.x + 5, rect.y + 2);
internals.mouseUp(rect.x + 5, rect.y + 2);
const sel = window.getSelection();
println(`focusNode: ${sel.focusNode === textNode ? "text" : sel.focusNode?.nodeName}`);
println(`focusOffset: ${sel.focusOffset}`);
println(`selected: "${sel.toString()}"`);
});
</script>