Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1448)

Unified Diff: Source/core/loader/ImageLoader.cpp

Issue 696123002: Revert of Use Shadow DOM to display fallback content for images (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/loader/ImageLoader.h ('k') | Source/core/paint/ImagePainter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/core/loader/ImageLoader.h ('k') | Source/core/paint/ImagePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698