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

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, 9 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 e618c96e42f89bfb969d01e2ac426d2e613210fb..4d2c38b1d8d2a9aa776a5c1cb4280e41dbf3df68 100644
--- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp
@@ -176,6 +176,7 @@ void ImageLoader::dispose() {
if (m_image) {
m_image->removeObserver(this);
m_image = nullptr;
+ m_loadDelayCounter2 = nullptr;
}
}
@@ -200,6 +201,7 @@ void ImageLoader::setImageWithoutConsideringPendingLoadEvent(
ImageResourceContent* oldImage = m_image.get();
if (newImage != oldImage) {
m_image = newImage;
+ m_loadDelayCounter2 = nullptr;
if (m_hasPendingLoadEvent) {
loadEventSender().cancelEvent(this);
m_hasPendingLoadEvent = false;
@@ -359,17 +361,18 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior,
m_image = newImage;
m_hasPendingLoadEvent = newImage;
m_imageComplete = !newImage;
+ m_loadDelayCounter2 = nullptr;
updateLayoutObject();
// If newImage exists and is cached, addObserver() will result in the load
// event being queued to fire. Ensure this happens after beforeload is
// dispatched.
- if (newImage) {
- newImage->addObserver(this);
- }
if (oldImage) {
oldImage->removeObserver(this);
}
+ if (newImage) {
fs 2017/03/15 14:22:17 This shuffle is non-obvious, what are the side-eff
hiroshige 2017/05/04 22:50:50 Oh, this was my mistake (unintentionally changed t
+ newImage->addObserver(this);
+ }
}
if (LayoutImageResource* imageResource = layoutImageResource())
@@ -423,10 +426,10 @@ void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior,
// asynchronous load completes.
if (imageSourceURL.isEmpty()) {
ImageResourceContent* image = m_image.get();
- if (image) {
+ if (image)
image->removeObserver(this);
- }
m_image = nullptr;
+ m_loadDelayCounter2 = nullptr;
}
// Don't load images for inactive documents. We don't want to slow down the
@@ -469,6 +472,18 @@ bool ImageLoader::shouldLoadImmediately(const KURL& url) const {
return (isHTMLObjectElement(m_element) || isHTMLEmbedElement(m_element));
}
+void ImageLoader::imageChanged(ImageResourceContent* content, const IntRect*) {
+ DCHECK_EQ(content, m_image.get());
+ if (m_imageComplete || !content->isLoading() || m_loadDelayCounter2)
+ return;
+
+ Document& document = m_element->document();
+ if (!document.isActive())
+ return;
+
+ m_loadDelayCounter2 = IncrementLoadEventDelayCount::create(document);
+}
+
void ImageLoader::imageNotifyFinished(ImageResourceContent* resource) {
RESOURCE_LOADING_DVLOG(1)
<< "ImageLoader::imageNotifyFinished " << this
@@ -478,6 +493,7 @@ void ImageLoader::imageNotifyFinished(ImageResourceContent* resource) {
DCHECK_EQ(resource, m_image.get());
m_imageComplete = true;
+ m_loadDelayCounter2 = nullptr;
// Update ImageAnimationPolicy for m_image.
if (m_image)
@@ -636,6 +652,8 @@ void ImageLoader::dispatchPendingErrorEvents() {
void ImageLoader::elementDidMoveToNewDocument() {
if (m_loadDelayCounter)
m_loadDelayCounter->documentChanged(m_element->document());
+ if (m_loadDelayCounter2)
+ m_loadDelayCounter2->documentChanged(m_element->document());
clearFailedLoadURL();
setImage(0);
}

Powered by Google App Engine
This is Rietveld 408576698