Title: [272488] trunk/Source/WebCore
Revision
272488
Author
[email protected]
Date
2021-02-08 05:31:56 -0800 (Mon, 08 Feb 2021)

Log Message

Perform layout before running Editor::findString
https://bugs.webkit.org/show_bug.cgi?id=220384

Patch by Frédéric Wang <[email protected]> on 2021-02-08
Reviewed by Ryosuke Niwa.

This ensures that the layout is up-to-date before performing any search.
Also disable any post-resolution that could cause more changes to happen.

* editing/Editor.cpp:
(WebCore::Editor::findString):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (272487 => 272488)


--- trunk/Source/WebCore/ChangeLog	2021-02-08 12:33:40 UTC (rev 272487)
+++ trunk/Source/WebCore/ChangeLog	2021-02-08 13:31:56 UTC (rev 272488)
@@ -1,3 +1,16 @@
+2021-02-08  Frédéric Wang  <[email protected]>
+
+        Perform layout before running Editor::findString
+        https://bugs.webkit.org/show_bug.cgi?id=220384
+
+        Reviewed by Ryosuke Niwa.
+
+        This ensures that the layout is up-to-date before performing any search.
+        Also disable any post-resolution that could cause more changes to happen.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::findString):
+
 2021-02-08  Antoine Quint  <[email protected]>
 
         Deprecation warnings for NSImageHintSymbolFont and NSImageHintSymbolScale

Modified: trunk/Source/WebCore/editing/Editor.cpp (272487 => 272488)


--- trunk/Source/WebCore/editing/Editor.cpp	2021-02-08 12:33:40 UTC (rev 272487)
+++ trunk/Source/WebCore/editing/Editor.cpp	2021-02-08 13:31:56 UTC (rev 272488)
@@ -103,6 +103,7 @@
 #include "SpellingCorrectionCommand.h"
 #include "StaticPasteboard.h"
 #include "StyleProperties.h"
+#include "StyleTreeResolver.h"
 #include "SystemSoundManager.h"
 #include "TelephoneNumberDetector.h"
 #include "Text.h"
@@ -3444,10 +3445,14 @@
 bool Editor::findString(const String& target, FindOptions options)
 {
     Ref<Document> protectedDocument(m_document);
+    Optional<SimpleRange> resultRange;
+    {
+        m_document.updateLayoutIgnorePendingStylesheets();
+        Style::PostResolutionCallbackDisabler disabler(m_document);
+        VisibleSelection selection = m_document.selection().selection();
+        resultRange = rangeOfString(target, selection.firstRange(), options);
+    }
 
-    VisibleSelection selection = m_document.selection().selection();
-
-    auto resultRange = rangeOfString(target, selection.firstRange(), options);
     if (!resultRange)
         return false;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to