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

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

Issue 654253003: Error event shouldn't fire when image is updated on environment changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: style Created 6 years, 2 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 | « 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: Source/core/loader/ImageLoader.cpp
diff --git a/Source/core/loader/ImageLoader.cpp b/Source/core/loader/ImageLoader.cpp
index c89b49fc21096ea00e9107972d5d4a97d6f7eba7..825907d527ce46dd872181f1fbc1262693728a45 100644
--- a/Source/core/loader/ImageLoader.cpp
+++ b/Source/core/loader/ImageLoader.cpp
@@ -120,6 +120,7 @@ ImageLoader::ImageLoader(Element* element)
, m_imageComplete(true)
, m_loadingImageDocument(false)
, m_elementIsProtected(false)
+ , m_suppressErrorEvents(false)
, m_highPriorityClientCount(0)
{
WTF_LOG(Timers, "new ImageLoader %p", this);
@@ -319,6 +320,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up
void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, LoadType loadType)
{
AtomicString imageSourceURL = m_element->imageSourceURL();
+ m_suppressErrorEvents = (updateBehavior == UpdateSizeChanged);
if (updateBehavior == UpdateIgnorePreviousError)
clearFailedLoadURL();
@@ -386,8 +388,12 @@ void ImageLoader::notifyFinished(Resource* resource)
loadEventSender().cancelEvent(this);
m_hasPendingLoadEvent = false;
- m_hasPendingErrorEvent = true;
- errorEventSender().dispatchEventSoon(this);
+ // The error event should not fire if the image data update is a result of environment change.
+ // https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element:the-img-element-55
+ if (!m_suppressErrorEvents) {
+ m_hasPendingErrorEvent = true;
+ errorEventSender().dispatchEventSoon(this);
+ }
// Only consider updating the protection ref-count of the Element immediately before returning
// from this function as doing so might result in the destruction of this ImageLoader.
« no previous file with comments | « Source/core/loader/ImageLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698