Преглед изворни кода

LibWeb: Move update_layout() to happen earlier in find_matching_text()

update_layout() need to be invoked before checking if layout node is
present, because layout not being updated might be the reason why layout
node doesn't exist yet.
Aliaksandr Kalenik пре 9 месеци
родитељ
комит
9754b480fa
1 измењених фајлова са 3 додато и 3 уклоњено
  1. 3 3
      Userland/Libraries/LibWeb/DOM/Document.cpp

+ 3 - 3
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -5337,12 +5337,12 @@ void Document::set_needs_to_refresh_scroll_state(bool b)
 
 
 Vector<JS::Handle<DOM::Range>> Document::find_matching_text(String const& query, CaseSensitivity case_sensitivity)
 Vector<JS::Handle<DOM::Range>> Document::find_matching_text(String const& query, CaseSensitivity case_sensitivity)
 {
 {
-    if (!layout_node())
-        return {};
-
     // Ensure the layout tree exists before searching for text matches.
     // Ensure the layout tree exists before searching for text matches.
     update_layout();
     update_layout();
 
 
+    if (!layout_node())
+        return {};
+
     auto const& text_blocks = layout_node()->text_blocks();
     auto const& text_blocks = layout_node()->text_blocks();
     if (text_blocks.is_empty())
     if (text_blocks.is_empty())
         return {};
         return {};