Index: Source/core/loader/ImageLoader.cpp |
diff --git a/Source/core/loader/ImageLoader.cpp b/Source/core/loader/ImageLoader.cpp |
index d85d6e6b20863ff97ecfc6acd48cc815fb8de775..1f3f7320a84b88d8d7039f8d583ab17c85f3d622 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; |
} |
@@ -269,13 +270,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(); |
@@ -320,7 +318,7 @@ |
updatedHasPendingEvent(); |
} |
-void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior) |
+void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, LoadType loadType) |
{ |
AtomicString imageSourceURL = m_element->imageSourceURL(); |
m_suppressErrorEvents = (updateBehavior == UpdateSizeChanged); |
@@ -339,7 +337,7 @@ |
} |
KURL url = imageSourceToKURL(imageSourceURL); |
- if (shouldLoadImmediately(url)) { |
+ if (imageSourceURL.isNull() || url.isNull() || shouldLoadImmediately(url, loadType)) { |
doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior); |
return; |
} |
@@ -363,16 +361,14 @@ |
return url; |
} |
-bool ImageLoader::shouldLoadImmediately(const KURL& url) const |
-{ |
- // We force any image loads which might require alt content 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; |
- } |
- return (m_loadingImageDocument || isHTMLObjectElement(m_element) || isHTMLEmbedElement(m_element) || url.protocolIsData()); |
+bool ImageLoader::shouldLoadImmediately(const KURL& url, LoadType loadType) const |
+{ |
+ return (m_loadingImageDocument |
+ || isHTMLObjectElement(m_element) |
+ || isHTMLEmbedElement(m_element) |
+ || url.protocolIsData() |
+ || memoryCache()->resourceForURL(url, m_element->document().fetcher()->getCacheIdentifier()) |
+ || loadType == ForceLoadImmediately); |
} |
void ImageLoader::notifyFinished(Resource* resource) |
@@ -587,4 +583,5 @@ |
m_loader.willRemoveClient(m_client); |
} |
#endif |
-} |
+ |
+} |