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

Unified Diff: third_party/WebKit/Source/core/loader/ImageLoader.cpp

Issue 2859093003: Change the semantics of ImageLoader::has_pending_load_event_ (Closed)
Patch Set: Rebase 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/loader/ImageLoader.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/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;
« no previous file with comments | « third_party/WebKit/Source/core/loader/ImageLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698