Chromium Code Reviews| 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..8c5bccf9e5255946eb213f1303eb6c051f827129 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,12 @@ void SVGImage::LoadCompleted() { |
| } |
| } |
| +void SVGImage::NotifyAsyncLoadCompleted() { |
| + if (GetImageObserver()) { |
| + GetImageObserver()->AsyncLoadCompleted(this); |
| + } |
|
kinuko
2017/05/19 22:29:58
nit: no braces for single-line body for consistenc
hiroshige
2017/05/20 01:06:26
Done.
|
| +} |
| + |
| Image::SizeAvailability SVGImage::DataChanged(bool all_data_received) { |
| TRACE_EVENT0("blink", "SVGImage::dataChanged"); |