ladybird/Tests/LibWeb/Text/input/selection-on-rendered-text.html
Timothy Flynn 76bab90812 LibWeb: Use rendered text to find word boundaries when double-clicking
This effectively reverts da26941b50.

When the user double-clicks a word on screen, they are interacting with
the rendered text, which has e.g. whitespace collapsing applied. If we
acquire word boundaries from the raw text, the resulting selection is
not right.

We still have issues with acquiring the right selection via APIs such as
`document.getSelection`. The offsets computed here are effectively then
applied to the raw text. But this issue is present all over EventHandler
and this patch at least makes the selection visually accurate.
2025-08-14 19:36:38 +02:00

11 lines
334 B
HTML

<!DOCTYPE html>
<script src="include.js"></script>
<p id="text">Lorem ipsum dolor sit amet</p>
<script>
test(() => {
internals.doubleclick(85, 20);
const selection = document.getSelection().getRangeAt(0);
println(`Selected range: ${selection.startOffset} - ${selection.endOffset}`);
});
</script>