Index: Source/core/loader/ImageLoader.cpp |
diff --git a/Source/core/loader/ImageLoader.cpp b/Source/core/loader/ImageLoader.cpp |
index 6d49d03ca6744c9aff712155346d8691ffdbaed4..7d4b10d2d172ea89a7f60307748411d33eb10ddb 100644 |
--- a/Source/core/loader/ImageLoader.cpp |
+++ b/Source/core/loader/ImageLoader.cpp |
@@ -66,7 +66,8 @@ |
{ |
ASSERT(loader); |
ASSERT(loader->element()); |
- if (loader->element()->document().frame() && loader->element()->document().frame()->script().shouldBypassMainWorldCSP()) |
+ ASSERT(loader->element()->document().frame()); |
+ if (loader->element()->document().frame()->script().shouldBypassMainWorldCSP()) |
return ImageLoader::BypassMainWorldCSP; |
return ImageLoader::DoNotBypassMainWorldCSP; |
} |
@@ -268,13 +269,10 @@ |
crossSiteOrCSPViolationOccured(imageSourceURL); |
else |
clearFailedLoadURL(); |
- } else { |
- if (!imageSourceURL.isNull()) { |
- // Fire an error event if the url string is not empty, but the KURL is. |
- m_hasPendingErrorEvent = true; |
- errorEventSender().dispatchEventSoon(this); |
- } |
- noImageResourceToLoad(); |
+ } else if (!imageSourceURL.isNull()) { |
+ // Fire an error event if the url string is not empty, but the KURL is. |
+ m_hasPendingErrorEvent = true; |
+ errorEventSender().dispatchEventSoon(this); |
} |
ImageResource* oldImage = m_image.get(); |
@@ -319,7 +317,7 @@ |
updatedHasPendingEvent(); |
} |
-void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior) |
+void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, LoadType loadType) |
{ |
AtomicString imageSourceURL = m_element->imageSourceURL(); |
@@ -337,7 +335,7 @@ |
} |
KURL url = imageSourceToKURL(imageSourceURL); |
- if (shouldLoadImmediately(url)) { |
+ if (imageSourceURL.isNull() || url.isNull() || shouldLoadImmediately(url, loadType)) { |
doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior); |
return; |
} |
@@ -361,19 +359,14 @@ |
return url; |
} |
-bool ImageLoader::shouldLoadImmediately(const KURL& url) const |
-{ |
- // We force failed image loads through the asynchronous path so that we can add the shadow DOM |
- // for the alt-text content when style recalc is over and DOM mutation is allowed again. |
- if (!url.isNull()) { |
- Resource* resource = memoryCache()->resourceForURL(url, m_element->document().fetcher()->getCacheIdentifier()); |
- if (resource && !resource->errorOccurred()) |
- return true; |
- } |
+bool ImageLoader::shouldLoadImmediately(const KURL& url, LoadType loadType) const |
+{ |
return (m_loadingImageDocument |
|| isHTMLObjectElement(m_element) |
|| isHTMLEmbedElement(m_element) |
- || url.protocolIsData()); |
+ || url.protocolIsData() |
+ || memoryCache()->resourceForURL(url, m_element->document().fetcher()->getCacheIdentifier()) |
+ || loadType == ForceLoadImmediately); |
} |
void ImageLoader::notifyFinished(Resource* resource) |