| 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 2a2d79f9fc6e0a756db1f2333174bac1643da6e7..9f732b79abcdee63b9fa8071d2ca90f967e70d84 100644
|
| --- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp
|
| +++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp
|
| @@ -214,10 +214,9 @@ void ImageLoader::SetImageForImageDocument(ImageResource* new_image_resource) {
|
| image_resource_for_image_document_ = new_image_resource;
|
| SetImageWithoutConsideringPendingLoadEvent(new_image_resource->GetContent());
|
|
|
| - // |has_pending_load_event_| is always false and |image_complete_| is
|
| - // always true for ImageDocument loading, while the loading is just started.
|
| + // |image_complete_| is 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
|
| @@ -307,7 +306,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;
|
| }
|
| @@ -543,8 +541,8 @@ 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.
|
| + // |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.
|
| @@ -566,12 +564,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);
|
| @@ -594,6 +588,7 @@ void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) {
|
| UpdatedHasPendingEvent();
|
| return;
|
| }
|
| + has_pending_load_event_ = true;
|
| LoadEventSender().DispatchEventSoon(this);
|
| }
|
|
|
| @@ -632,6 +627,17 @@ void ImageLoader::UpdateLayoutObject() {
|
| image_resource->SetImageResource(image_.Get());
|
| }
|
|
|
| +bool ImageLoader::HasPendingEvent() const {
|
| + // Regular image loading is in progress.
|
| + if (image_ && !image_complete_ && !loading_image_document_)
|
| + return true;
|
| +
|
| + if (has_pending_load_event_ || has_pending_error_event_)
|
| + return true;
|
| +
|
| + return false;
|
| +}
|
| +
|
| 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
|
| @@ -640,7 +646,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;
|
|
|
|
|