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

Unified Diff: third_party/WebKit/Source/core/html/HTMLImageLoader.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
Index: third_party/WebKit/Source/core/html/HTMLImageLoader.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLImageLoader.cpp b/third_party/WebKit/Source/core/html/HTMLImageLoader.cpp
index fdaa2f14c09f07a3625b72fbabb0379c84565fc1..ad61807a7ba76f79f6a9995ce113c608c1588974 100644
--- a/third_party/WebKit/Source/core/html/HTMLImageLoader.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLImageLoader.cpp
@@ -24,6 +24,7 @@
#include "core/HTMLNames.h"
#include "core/dom/Element.h"
#include "core/events/Event.h"
+#include "core/events/EventSender.h"
#include "core/fetch/ImageResource.h"
#include "core/fetch/ResourceLoadingLog.h"
#include "core/html/HTMLImageElement.h"
@@ -35,6 +36,17 @@ namespace blink {
using namespace HTMLNames;
+static ImageEventSender& loadendEventSender()
+{
+ DEFINE_STATIC_LOCAL(ImageEventSender, sender, (ImageEventSender::create(EventTypeNames::loadend)));
+ return sender;
+}
+
+void HTMLImageLoader::dispatchPendingLoadendEvents()
+{
+ loadendEventSender().dispatchPendingEvents();
+}
+
HTMLImageLoader::HTMLImageLoader(Element* element)
: ImageLoader(element)
{
@@ -58,6 +70,22 @@ void HTMLImageLoader::dispatchLoadEvent()
element()->dispatchEvent(Event::create(errorOccurred ? EventTypeNames::error : EventTypeNames::load));
}
+void HTMLImageLoader::dispatchLoadendEvent()
+{
+ RESOURCE_LOADING_DVLOG(1) << "HTMLImageLoader::dispatchLoadendEvent " << this;
+
+ if (isHTMLImageElement(*element()))
+ element()->dispatchEvent(Event::create(EventTypeNames::loadend));
+}
+
+void HTMLImageLoader::dispatchLoadendEventSoon()
+{
+ RESOURCE_LOADING_DVLOG(1) << "HTMLImageLoader::dispatchLoadendEventSoon " << this;
+
+ if (isHTMLImageElement(*element()))
+ loadendEventSender().dispatchEventSoon(this);
+}
+
static void loadFallbackContentForElement(Element* element)
{
if (isHTMLImageElement(element))
@@ -96,6 +124,7 @@ void HTMLImageLoader::imageNotifyFinished(ImageResource*)
if ((loadError || cachedImage->response().httpStatusCode() >= 400) && isHTMLObjectElement(*element))
toHTMLObjectElement(element)->renderFallbackContent();
+ dispatchLoadendEventSoon();
}
void HTMLImageLoader::ensureFallbackContent()
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLImageLoader.h ('k') | third_party/WebKit/Source/core/loader/ImageLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698