Index: Source/core/loader/ImageLoader.cpp |
diff --git a/Source/core/loader/ImageLoader.cpp b/Source/core/loader/ImageLoader.cpp |
index 9bafe5608cee455c06f8c1567d781bac88007b89..1aeab5354d21e762bb9057d3ec93c98c6a4ae2dc 100644 |
--- a/Source/core/loader/ImageLoader.cpp |
+++ b/Source/core/loader/ImageLoader.cpp |
@@ -66,8 +66,7 @@ static ImageLoader::BypassMainWorldBehavior shouldBypassMainWorldCSP(ImageLoader |
{ |
ASSERT(loader); |
ASSERT(loader->element()); |
- ASSERT(loader->element()->document().frame()); |
- if (loader->element()->document().frame()->script().shouldBypassMainWorldCSP()) |
+ if (loader->element()->document().frame() && loader->element()->document().frame()->script().shouldBypassMainWorldCSP()) |
return ImageLoader::BypassMainWorldCSP; |
return ImageLoader::DoNotBypassMainWorldCSP; |
} |
@@ -268,10 +267,13 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up |
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); |
+ } 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(); |
} |
ImageResource* oldImage = m_image.get(); |
@@ -316,7 +318,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up |
updatedHasPendingEvent(); |
} |
-void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, LoadType loadType) |
+void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior) |
{ |
AtomicString imageSourceURL = m_element->imageSourceURL(); |
@@ -334,7 +336,7 @@ void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, Lo |
} |
KURL url = imageSourceToKURL(imageSourceURL); |
- if (imageSourceURL.isNull() || url.isNull() || shouldLoadImmediately(url, loadType)) { |
+ if (shouldLoadImmediately(url)) { |
doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior); |
return; |
} |
@@ -358,14 +360,19 @@ KURL ImageLoader::imageSourceToKURL(AtomicString imageSourceURL) const |
return url; |
} |
-bool ImageLoader::shouldLoadImmediately(const KURL& url, LoadType loadType) const |
+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); |
+ if (resource && !resource->errorOccurred()) |
+ return true; |
+ } |
return (m_loadingImageDocument |
|| isHTMLObjectElement(m_element) |
|| isHTMLEmbedElement(m_element) |
- || url.protocolIsData() |
- || memoryCache()->resourceForURL(url) |
- || loadType == ForceLoadImmediately); |
+ || url.protocolIsData()); |
} |
void ImageLoader::notifyFinished(Resource* resource) |