Chromium Code Reviews| Index: third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| diff --git a/third_party/WebKit/Source/core/loader/ImageLoader.cpp b/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| index 74f02520228e0228d8772d8930f9f31b99fff916..b54aef891768856369a84f7bc9377144588f35e4 100644 |
| --- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| +++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| @@ -519,6 +519,16 @@ void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { |
| DCHECK(failed_load_url_.IsEmpty()); |
| DCHECK_EQ(resource, image_.Get()); |
| + // |has_pending_load_event_| is always false and |image_complete_| is |
| + // always true for entire ImageDocument loading for historical reason. |
| + // DoUpdateFromElement() is not called and SetImageForImageDocument() |
| + // is called instead for ImageDocument loading. |
| + // TODO(hiroshige): Turn the CHECK()s to DCHECK()s before going to beta. |
| + if (loading_image_document_) |
| + CHECK(image_complete_); |
| + else |
| + CHECK(!image_complete_); |
| + |
| image_complete_ = true; |
| // Update ImageAnimationPolicy for image_. |
| @@ -531,8 +541,12 @@ void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { |
| ToSVGImage(image_->GetImage()) |
| ->UpdateUseCounters(GetElement()->GetDocument()); |
| - if (!has_pending_load_event_) |
| + if (loading_image_document_) { |
| + CHECK(!has_pending_load_event_); |
| return; |
| + } |
| + |
| + CHECK(has_pending_load_event_); |
| if (resource->ErrorOccurred()) { |
| LoadEventSender().CancelEvent(this); |
| @@ -632,10 +646,10 @@ void ImageLoader::DispatchPendingEvent(ImageEventSender* event_sender) { |
| } |
| void ImageLoader::DispatchPendingLoadEvent() { |
| - if (!has_pending_load_event_) |
| - return; |
| + CHECK(has_pending_load_event_); |
| if (!image_) |
| return; |
| + CHECK(image_complete_); |
| has_pending_load_event_ = false; |
| if (GetElement()->GetDocument().GetFrame()) |
| DispatchLoadEvent(); |
| @@ -647,6 +661,10 @@ void ImageLoader::DispatchPendingLoadEvent() { |
| } |
| void ImageLoader::DispatchPendingErrorEvent() { |
| + // Currently this if condition is needed because there can be multiple |
| + // in-flight error event tasks and we process only the first here. |
|
kinuko
2017/05/15 20:12:50
whoa..
|
| + // crbug.com/722500 |
| + // TODO(hiroshige): Replace this with |CHECK(has_pending_load_event_)|. |
| if (!has_pending_error_event_) |
| return; |
| has_pending_error_event_ = false; |