LibWeb: Don't select text when multi-clicking user-select:none node

This commit is contained in:
Psychpsyo 2026-02-16 15:15:49 +01:00 committed by Jelle Raaijmakers
parent 0e958ca8d5
commit 68f27e9bbc
3 changed files with 20 additions and 0 deletions

View file

@ -1200,6 +1200,8 @@ EventResult EventHandler::handle_doubleclick(CSSPixelPoint visual_viewport_posit
return EventResult::Accepted;
if (!is<Painting::TextPaintable>(*result->paintable))
return EventResult::Accepted;
if (result->paintable->layout_node().user_select_used_value() == CSS::UserSelect::None)
return EventResult::Accepted;
auto& hit_paintable = static_cast<Painting::TextPaintable const&>(*result->paintable);
auto& hit_dom_node = const_cast<DOM::Text&>(as<DOM::Text>(*hit_paintable.dom_node()));
@ -1281,6 +1283,8 @@ EventResult EventHandler::handle_tripleclick(CSSPixelPoint visual_viewport_posit
return EventResult::Accepted;
if (!is<DOM::Text>(*hit->paintable->dom_node()))
return EventResult::Accepted;
if (hit->paintable->layout_node().user_select_used_value() == CSS::UserSelect::None)
return EventResult::Accepted;
auto& hit_dom_node = const_cast<DOM::Text&>(as<DOM::Text>(*hit->paintable->dom_node()));
size_t hit_index = hit->index_in_node;

View file

@ -0,0 +1,2 @@
double-click selected: ""
triple-click selected: ""

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<script src="include.js"></script>
<div style="font-size:20px">
super<span style="user-select:none">califragilistic</span>expialidocious
</div>
<script>
test(() => {
internals.click(80, 20, 2);
println(`double-click selected: "${window.getSelection()}"`);
internals.click(80, 20, 3);
println(`triple-click selected: "${window.getSelection()}"`);
});
</script>