Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Unified Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp

Issue 2897533002: Make ImageObserver::AsyncLoadCompleted() called asynchronously (Closed)
Patch Set: Reflect kinuko's comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/svg/graphics/SVGImage.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
diff --git a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
index 8c34ea90b7adca781799ab40528b5f1a96055a91..226e10b05a91d3102d8723bdfcad8c092c4bf825 100644
--- a/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
+++ b/third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp
@@ -30,6 +30,7 @@
#include "core/animation/DocumentAnimations.h"
#include "core/animation/DocumentTimeline.h"
#include "core/dom/NodeTraversal.h"
+#include "core/dom/TaskRunnerHelper.h"
#include "core/dom/shadow/FlatTreeTraversal.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
@@ -640,8 +641,16 @@ void SVGImage::LoadCompleted() {
case kWaitingForAsyncLoadCompletion:
load_state_ = kLoadCompleted;
- if (GetImageObserver())
- GetImageObserver()->AsyncLoadCompleted(this);
+
+ // Because LoadCompleted() is called synchronously from
+ // Document::ImplicitClose(), we defer AsyncLoadCompleted() to avoid
+ // potential bugs and timing dependencies around ImplicitClose() and
+ // to make LoadEventFinished() true when AsyncLoadCompleted() is called.
+ TaskRunnerHelper::Get(TaskType::kUnspecedLoading,
+ ToLocalFrame(page_->MainFrame()))
+ ->PostTask(BLINK_FROM_HERE,
+ WTF::Bind(&SVGImage::NotifyAsyncLoadCompleted,
+ RefPtr<SVGImage>(this)));
break;
case kDataChangedNotStarted:
@@ -651,6 +660,11 @@ void SVGImage::LoadCompleted() {
}
}
+void SVGImage::NotifyAsyncLoadCompleted() {
+ if (GetImageObserver())
+ GetImageObserver()->AsyncLoadCompleted(this);
+}
+
Image::SizeAvailability SVGImage::DataChanged(bool all_data_received) {
TRACE_EVENT0("blink", "SVGImage::dataChanged");
« no previous file with comments | « third_party/WebKit/Source/core/svg/graphics/SVGImage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698