Title: [273300] trunk/Source/WebCore
Revision
273300
Author
[email protected]
Date
2021-02-23 00:20:01 -0800 (Tue, 23 Feb 2021)

Log Message

Handle Page::didFinishLoadingImageForElement asynchronously
https://bugs.webkit.org/show_bug.cgi?id=221390

Reviewed by Antti Koivisto.

Use EventLoop instead of RunLoop::main() to be thread safe in iOS WebKit1.

* page/Page.cpp:
(WebCore::Page::didFinishLoadingImageForElement):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273299 => 273300)


--- trunk/Source/WebCore/ChangeLog	2021-02-23 07:43:16 UTC (rev 273299)
+++ trunk/Source/WebCore/ChangeLog	2021-02-23 08:20:01 UTC (rev 273300)
@@ -1,3 +1,15 @@
+2021-02-23  Ryosuke Niwa  <[email protected]>
+
+        Handle Page::didFinishLoadingImageForElement asynchronously
+        https://bugs.webkit.org/show_bug.cgi?id=221390
+
+        Reviewed by Antti Koivisto.
+
+        Use EventLoop instead of RunLoop::main() to be thread safe in iOS WebKit1.
+
+        * page/Page.cpp:
+        (WebCore::Page::didFinishLoadingImageForElement):
+
 2021-02-22  Don Olmstead  <[email protected]>
 
         Non-unified build fixes late February 2021 edition

Modified: trunk/Source/WebCore/page/Page.cpp (273299 => 273300)


--- trunk/Source/WebCore/page/Page.cpp	2021-02-23 07:43:16 UTC (rev 273299)
+++ trunk/Source/WebCore/page/Page.cpp	2021-02-23 08:20:01 UTC (rev 273300)
@@ -54,6 +54,7 @@
 #include "EmptyClients.h"
 #include "Event.h"
 #include "EventHandler.h"
+#include "EventLoop.h"
 #include "EventNames.h"
 #include "ExtensionStyleSheets.h"
 #include "FocusController.h"
@@ -3336,13 +3337,14 @@
 
 void Page::didFinishLoadingImageForElement(HTMLImageElement& element)
 {
-    RunLoop::main().dispatch([this, weakThis = makeWeakPtr(*this), element = makeRef(element)]() {
-        if (!weakThis)
+    element.document().eventLoop().queueTask(TaskSource::Networking, [element = makeRef(element)]() {
+        auto frame = makeRefPtr(element->document().frame());
+        if (!frame)
             return;
 
-        if (auto frame = makeRefPtr(element->document().frame()))
-            frame->editor().revealSelectionIfNeededAfterLoadingImageForElement(element);
-        chrome().client().didFinishLoadingImageForElement(element);
+        frame->editor().revealSelectionIfNeededAfterLoadingImageForElement(element);
+        if (auto* page = frame->page(); element->document().frame() == frame)
+            page->chrome().client().didFinishLoadingImageForElement(element);
     });
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to