Title: [273231] trunk/Source/WebCore
Revision
273231
Author
[email protected]
Date
2021-02-22 01:13:47 -0800 (Mon, 22 Feb 2021)

Log Message

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

Patch by Carlos Garcia Campos <[email protected]> on 2021-02-22
Reviewed by Alex Christensen.

When called synchronously from RenderImage::notifyFinished() it's not possible to update the layout because
scripts are not allowed at that point.

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273230 => 273231)


--- trunk/Source/WebCore/ChangeLog	2021-02-22 08:27:26 UTC (rev 273230)
+++ trunk/Source/WebCore/ChangeLog	2021-02-22 09:13:47 UTC (rev 273231)
@@ -1,3 +1,16 @@
+2021-02-22  Carlos Garcia Campos  <[email protected]>
+
+        Handle Page::didFinishLoadingImageForElement asynchronously
+        https://bugs.webkit.org/show_bug.cgi?id=221390
+
+        Reviewed by Alex Christensen.
+
+        When called synchronously from RenderImage::notifyFinished() it's not possible to update the layout because
+        scripts are not allowed at that point.
+
+        * page/Page.cpp:
+        (WebCore::Page::didFinishLoadingImageForElement):
+
 2021-02-21  Andres Gonzalez  <[email protected]>
 
         Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange.

Modified: trunk/Source/WebCore/page/Page.cpp (273230 => 273231)


--- trunk/Source/WebCore/page/Page.cpp	2021-02-22 08:27:26 UTC (rev 273230)
+++ trunk/Source/WebCore/page/Page.cpp	2021-02-22 09:13:47 UTC (rev 273231)
@@ -3336,10 +3336,14 @@
 
 void Page::didFinishLoadingImageForElement(HTMLImageElement& element)
 {
-    auto protectedElement = makeRef(element);
-    if (auto frame = makeRefPtr(element.document().frame()))
-        frame->editor().revealSelectionIfNeededAfterLoadingImageForElement(element);
-    chrome().client().didFinishLoadingImageForElement(element);
+    RunLoop::main().dispatch([this, weakThis = makeWeakPtr(*this), element = makeRef(element)]() {
+        if (!weakThis)
+            return;
+
+        if (auto frame = makeRefPtr(element->document().frame()))
+            frame->editor().revealSelectionIfNeededAfterLoadingImageForElement(element);
+        chrome().client().didFinishLoadingImageForElement(element);
+    });
 }
 
 #if ENABLE(TEXT_AUTOSIZING)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to