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

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

Issue 2613853002: Phase III Step 2: Call imageNotifyFinished() and image load event after SVG loading completes (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
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..a120b1da4e2191af9d716c213075878ab122b7f3 100644
--- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp
@@ -177,6 +177,7 @@ void ImageLoader::Dispose() {
if (image_) {
image_->RemoveObserver(this);
image_ = nullptr;
+ delay_until_image_notify_finished_ = nullptr;
}
}
@@ -293,7 +294,7 @@ inline void ImageLoader::EnqueueImageLoadingMicroTask(
pending_task_ = task->CreateWeakPtr();
Microtask::EnqueueMicrotask(
WTF::Bind(&Task::Run, WTF::Passed(std::move(task))));
- load_delay_counter_ =
+ delay_until_do_update_from_element_ =
IncrementLoadEventDelayCount::Create(element_->GetDocument());
}
@@ -301,6 +302,7 @@ 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;
}
void ImageLoader::DoUpdateFromElement(BypassMainWorldBehavior bypass_behavior,
@@ -318,7 +320,7 @@ void ImageLoader::DoUpdateFromElement(BypassMainWorldBehavior bypass_behavior,
pending_task_.reset();
// Make sure to only decrement the count when we exit this function
std::unique_ptr<IncrementLoadEventDelayCount> load_delay_counter;
- load_delay_counter.swap(load_delay_counter_);
+ load_delay_counter.swap(delay_until_do_update_from_element_);
Document& document = element_->GetDocument();
if (!document.IsActive())
@@ -469,6 +471,7 @@ void ImageLoader::UpdateFromElement(UpdateFromElementBehavior update_behavior,
image->RemoveObserver(this);
}
image_ = nullptr;
+ delay_until_image_notify_finished_ = nullptr;
}
// Don't load images for inactive documents. We don't want to slow down the
@@ -511,6 +514,20 @@ bool ImageLoader::ShouldLoadImmediately(const KURL& url) const {
return (isHTMLObjectElement(element_) || isHTMLEmbedElement(element_));
}
+void ImageLoader::ImageChanged(ImageResourceContent* content, const IntRect*) {
+ DCHECK_EQ(content, image_.Get());
+ if (image_complete_ || !content->IsLoading() ||
+ delay_until_image_notify_finished_)
+ return;
+
+ Document& document = element_->GetDocument();
+ if (!document.IsActive())
+ return;
+
+ delay_until_image_notify_finished_ =
+ IncrementLoadEventDelayCount::Create(document);
+}
+
void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) {
RESOURCE_LOADING_DVLOG(1)
<< "ImageLoader::imageNotifyFinished " << this
@@ -520,6 +537,7 @@ void ImageLoader::ImageNotifyFinished(ImageResourceContent* resource) {
DCHECK_EQ(resource, image_.Get());
image_complete_ = true;
+ delay_until_image_notify_finished_ = nullptr;
// Update ImageAnimationPolicy for image_.
if (image_)
@@ -677,8 +695,14 @@ void ImageLoader::DispatchPendingErrorEvents() {
}
void ImageLoader::ElementDidMoveToNewDocument() {
- if (load_delay_counter_)
- load_delay_counter_->DocumentChanged(element_->GetDocument());
+ if (delay_until_do_update_from_element_) {
+ delay_until_do_update_from_element_->DocumentChanged(
+ element_->GetDocument());
+ }
+ if (delay_until_image_notify_finished_) {
+ delay_until_image_notify_finished_->DocumentChanged(
+ element_->GetDocument());
+ }
ClearFailedLoadURL();
ClearImage();
}
« no previous file with comments | « third_party/WebKit/Source/core/loader/ImageLoader.h ('k') | third_party/WebKit/Source/core/loader/resource/ImageResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698