Sfoglia il codice sorgente

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.
Tim Ledbetter 1 anno fa
parent
commit
0b33331f36
1 ha cambiato i file con 4 aggiunte e 3 eliminazioni
  1. 4 3
      Userland/Libraries/LibWeb/DOM/Range.cpp

+ 4 - 3
Userland/Libraries/LibWeb/DOM/Range.cpp

@@ -97,13 +97,14 @@ void Range::set_associated_selection(Badge<Selection::Selection>, JS::GCPtr<Sele
 
 void Range::update_associated_selection()
 {
-    if (!m_associated_selection)
-        return;
-    if (auto* viewport = m_associated_selection->document()->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