From 6bd6ab67dc1fdf3cc012296885933df5e206473d Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sun, 23 Jun 2024 20:23:59 +0100 Subject: [PATCH] LibWeb: Ensure a repaint occurs when the current selection is cleared This fixes an issue where clearing the find in page query would not always visually clear the selection. (cherry picked from commit 0b33331f3678eb69bc3448949dfc2c1e1e7671e6) --- Userland/Libraries/LibWeb/DOM/Range.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index 3c14eddf7ae788..0a4ab926f1d4f8 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -96,13 +96,14 @@ void Range::set_associated_selection(Badge, JS::GCPtrdocument()->paintable()) { + if (auto* viewport = m_start_container->document().paintable()) { viewport->recompute_selection_states(); viewport->set_needs_display(); } + if (!m_associated_selection) + return; + // https://w3c.github.io/selection-api/#selectionchange-event // When the selection is dissociated with its range, associated with a new range or the associated range's boundary // point is mutated either by the user or the content script, the user agent must queue a task on the user interaction