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

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

Issue 2247073006: Add loadend event when finishing loading image Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix issue of layoutTest Created 4 years, 4 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 86f65618292a28c53500d98bb06686c25897ba40..994069b1c57c042f1571d49393bad2062263d0b1 100644
--- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp
@@ -297,6 +297,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up
if (!newImage && !pageIsBeingDismissed(&document)) {
crossSiteOrCSPViolationOccurred(imageSourceURL);
dispatchErrorEvent();
+ dispatchLoadendEventSoon();
} else {
clearFailedLoadURL();
}
@@ -304,6 +305,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up
if (!imageSourceURL.isNull()) {
// Fire an error event if the url string is not empty, but the KURL is.
dispatchErrorEvent();
+ dispatchLoadendEventSoon();
}
noImageResourceToLoad();
}
@@ -547,12 +549,13 @@ void ImageLoader::timerFired(TimerBase*)
void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender)
{
RESOURCE_LOADING_DVLOG(1) << "ImageLoader::dispatchPendingEvent " << this;
- ASSERT(eventSender == &loadEventSender() || eventSender == &errorEventSender());
const AtomicString& eventType = eventSender->eventType();
if (eventType == EventTypeNames::load)
dispatchPendingLoadEvent();
if (eventType == EventTypeNames::error)
dispatchPendingErrorEvent();
+ if (eventType == EventTypeNames::loadend)
+ dispatchPendingLoadendEvent();
}
void ImageLoader::dispatchPendingLoadEvent()
@@ -584,6 +587,15 @@ void ImageLoader::dispatchPendingErrorEvent()
updatedHasPendingEvent();
}
+void ImageLoader::dispatchPendingLoadendEvent()
+{
+ if (element()->document().frame()) {
+ dispatchLoadendEvent();
+ }
+
+ updatedHasPendingEvent();
+}
+
bool ImageLoader::getImageAnimationPolicy(ImageAnimationPolicy& policy)
{
if (!element()->document().settings())
« 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