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 5fb6922ebbc64e403f08cf5bae311310aaca2931..8555a20a3517c4aa920f838988c250be9589bd56 100644 |
--- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
+++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
@@ -217,7 +217,6 @@ void ImageLoader::SetImageForImageDocument(ImageResource* new_image_resource) { |
// |has_pending_load_event_| is always false and |image_complete_| is |
yhirano
2017/05/12 10:49:50
Is this comment stale?
hiroshige
2017/05/19 20:56:34
Done.
|
// always true for ImageDocument loading, while the loading is just started. |
// TODO(hiroshige): clean up the behavior of flags. https://crbug.com/719759 |
- has_pending_load_event_ = false; |
image_complete_ = true; |
// Only consider updating the protection ref-count of the Element immediately |
@@ -300,7 +299,6 @@ inline void ImageLoader::EnqueueImageLoadingMicroTask( |
void ImageLoader::UpdateImageState(ImageResourceContent* new_image) { |
image_ = new_image; |
- has_pending_load_event_ = new_image; |
image_complete_ = !new_image; |
delay_until_image_notify_finished_ = nullptr; |
} |
@@ -559,12 +557,8 @@ void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { |
ToSVGImage(image_->GetImage()) |
->UpdateUseCounters(GetElement()->GetDocument()); |
- if (loading_image_document_) { |
- CHECK(!has_pending_load_event_); |
+ if (loading_image_document_) |
return; |
- } |
- |
- CHECK(has_pending_load_event_); |
if (resource->ErrorOccurred()) { |
LoadEventSender().CancelEvent(this); |
@@ -587,6 +581,7 @@ void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) { |
UpdatedHasPendingEvent(); |
return; |
} |
+ has_pending_load_event_ = true; |
LoadEventSender().DispatchEventSoon(this); |
} |
@@ -625,6 +620,11 @@ void ImageLoader::UpdateLayoutObject() { |
image_resource->SetImageResource(image_.Get()); |
} |
+bool ImageLoader::HasPendingEvent() const { |
+ return (image_ && !image_complete_ && !loading_image_document_) || |
+ has_pending_load_event_ || has_pending_error_event_; |
kinuko
2017/05/12 08:28:24
This condition is getting slightly complex, maybe
hiroshige
2017/05/19 20:56:35
Done.
|
+} |
+ |
void ImageLoader::UpdatedHasPendingEvent() { |
// If an Element that does image loading is removed from the DOM the |
// load/error event for the image is still observable. As long as the |
@@ -633,7 +633,7 @@ void ImageLoader::UpdatedHasPendingEvent() { |
// such an Element wishes for the load to stop when removed from the DOM it |
// needs to stop the ImageLoader explicitly. |
bool was_protected = element_is_protected_; |
- element_is_protected_ = has_pending_load_event_ || has_pending_error_event_; |
+ element_is_protected_ = HasPendingEvent(); |
if (was_protected == element_is_protected_) |
return; |