| Index: Source/core/loader/ImageLoader.cpp
|
| diff --git a/Source/core/loader/ImageLoader.cpp b/Source/core/loader/ImageLoader.cpp
|
| index 47a80b07d4e5eecccdf6f8616e676daee923dc85..3235914c8d6261747bab4a51791827a269282444 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;
|
| }
|
| @@ -276,9 +275,12 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up
|
| } else {
|
| clearFailedLoadURL();
|
| }
|
| - } else if (!imageSourceURL.isNull()) {
|
| - // Fire an error event if the url string is not empty, but the KURL is.
|
| - dispatchErrorEvent();
|
| + } else {
|
| + if (!imageSourceURL.isNull()) {
|
| + // Fire an error event if the url string is not empty, but the KURL is.
|
| + dispatchErrorEvent();
|
| + }
|
| + noImageResourceToLoad();
|
| }
|
|
|
| ImageResource* oldImage = m_image.get();
|
| @@ -323,7 +325,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();
|
| m_suppressErrorEvents = (updateBehavior == UpdateSizeChanged);
|
| @@ -342,7 +344,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;
|
| }
|
| @@ -366,14 +368,16 @@ KURL ImageLoader::imageSourceToKURL(AtomicString imageSourceURL) const
|
| return url;
|
| }
|
|
|
| -bool ImageLoader::shouldLoadImmediately(const KURL& url, LoadType loadType) const
|
| +bool ImageLoader::shouldLoadImmediately(const KURL& url) const
|
| {
|
| - return (m_loadingImageDocument
|
| - || isHTMLObjectElement(m_element)
|
| - || isHTMLEmbedElement(m_element)
|
| - || url.protocolIsData()
|
| - || memoryCache()->resourceForURL(url, m_element->document().fetcher()->getCacheIdentifier())
|
| - || loadType == ForceLoadImmediately);
|
| + // 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());
|
| }
|
|
|
| void ImageLoader::notifyFinished(Resource* resource)
|
| @@ -589,5 +593,4 @@ ImageLoader::ImageLoaderClientRemover::~ImageLoaderClientRemover()
|
| m_loader.willRemoveClient(m_client);
|
| }
|
| #endif
|
| -
|
| }
|
|
|