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..2f74bcb9eaed7bc2eedd0e6346d5ed8a75a965d8 100644 |
--- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
+++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
@@ -154,6 +154,7 @@ ImageLoader::ImageLoader(Element* element) |
, m_loadingImageDocument(false) |
, m_elementIsProtected(false) |
, m_suppressErrorEvents(false) |
+ , m_suppressEvents(false) |
{ |
RESOURCE_LOADING_DVLOG(1) << "new ImageLoader " << this; |
ThreadState::current()->registerPreFinalizer(this); |
@@ -232,6 +233,9 @@ static void configureRequest(FetchRequest& request, ImageLoader::BypassMainWorld |
inline void ImageLoader::dispatchErrorEvent() |
{ |
+ if (m_suppressEvents) { |
+ return; |
+ } |
m_hasPendingErrorEvent = true; |
errorEventSender().dispatchEventSoon(this); |
} |
@@ -279,9 +283,17 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up |
// Unlike raw <img>, we block mixed content inside of <picture> or <img srcset>. |
ResourceLoaderOptions resourceLoaderOptions = ResourceFetcher::defaultResourceOptions(); |
ResourceRequest resourceRequest(url); |
- if (updateBehavior == UpdateForcedReload) { |
+ switch (updateBehavior) { |
+ case UpdateForcedReload: |
resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); |
resourceRequest.setLoFiState(WebURLRequest::LoFiOff); |
+ break; |
+ case UpdateMyReload: |
+ resourceRequest.setCachePolicy(WebCachePolicy::ReturnCacheDataElseLoad); |
+ resourceRequest.setLoFiState(WebURLRequest::LoFiOff); |
+ break; |
+ default: |
+ break; |
} |
if (referrerPolicy != ReferrerPolicyDefault) |
@@ -327,7 +339,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up |
} |
m_image = newImage; |
- m_hasPendingLoadEvent = newImage; |
+ m_hasPendingLoadEvent = newImage && !m_suppressEvents; |
m_imageComplete = !newImage; |
updateLayoutObject(); |
@@ -353,6 +365,7 @@ void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, Re |
{ |
AtomicString imageSourceURL = m_element->imageSourceURL(); |
m_suppressErrorEvents = (updateBehavior == UpdateSizeChanged); |
+ m_suppressEvents = (updateBehavior == UpdateMyReload); |
if (updateBehavior == UpdateIgnorePreviousError) |
clearFailedLoadURL(); |
@@ -365,7 +378,7 @@ void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, Re |
// been requested as a main resource and ImageDocumentParser will take care of |
// funneling the main resource bytes into m_image, so just create an ImageResource |
// to be populated later. |
- if (m_loadingImageDocument && updateBehavior != UpdateForcedReload) { |
+ if (m_loadingImageDocument && updateBehavior != UpdateForcedReload && updateBehavior != UpdateMyReload) { |
setImage(ImageResource::create(imageSourceToKURL(m_element->imageSourceURL()))); |
m_image->setStatus(Resource::Pending); |
return; |
@@ -593,6 +606,11 @@ bool ImageLoader::getImageAnimationPolicy(ImageAnimationPolicy& policy) |
return true; |
} |
+void ImageLoader::requireReloading() |
+{ |
+ updateFromElement(UpdateMyReload); |
+} |
+ |
void ImageLoader::dispatchPendingLoadEvents() |
{ |
loadEventSender().dispatchPendingEvents(); |