Correct delayed load event handling
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 May 2019 17:14:06 +0000 (17:14 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 May 2019 17:14:06 +0000 (17:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197679
<rdar://problem/50423334>

Reviewed by Alex Christensen.

We need to properly account for the fact that JavaScript might run
while performing loads.

* dom/Document.cpp:
(WebCore::Document::loadEventDelayTimerFired):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245142 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp

index 31d3917..ec68d32 100644 (file)
@@ -1,3 +1,17 @@
+2019-05-09  Brent Fulgham  <bfulgham@apple.com>
+
+        Correct delayed load event handling
+        https://bugs.webkit.org/show_bug.cgi?id=197679
+        <rdar://problem/50423334>
+
+        Reviewed by Alex Christensen.
+
+        We need to properly account for the fact that JavaScript might run
+        while performing loads.
+
+        * dom/Document.cpp:
+        (WebCore::Document::loadEventDelayTimerFired):
+
 2019-05-09  Antti Koivisto  <antti@apple.com>
 
         Elements with "display: inline-block" don't have a touch-action region
index 7b73cc5..7614bf5 100644 (file)
@@ -6300,12 +6300,10 @@ void Document::loadEventDelayTimerFired()
     // FIXME: Should this also call DocumentLoader::checkLoadComplete?
     // FIXME: Not obvious why checkCompleted needs to go first. The order these are called is
     // visible to WebKit clients, but it's more like a race than a well-defined relationship.
-    auto weakThis = makeWeakPtr(this);
+    Ref<Document> protectedThis(*this);
     checkCompleted();
-    if (weakThis) {
-        if (auto* frame = this->frame())
-            frame->loader().checkLoadComplete();
-    }
+    if (auto* frame = this->frame())
+        frame->loader().checkLoadComplete();
 }
 
 void Document::checkCompleted()