Chromium Code Reviews| Index: third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| diff --git a/third_party/WebKit/Source/core/loader/ImageLoader.cpp b/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| index 537c9594f25b59ef42096cf9a7c798687ed1b169..a1e7ee66bca064c72629f0fecd3752caf945b2ff 100644 |
| --- a/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| +++ b/third_party/WebKit/Source/core/loader/ImageLoader.cpp |
| @@ -39,6 +39,7 @@ |
| #include "core/frame/UseCounter.h" |
| #include "core/html/CrossOriginAttribute.h" |
| #include "core/html/HTMLImageElement.h" |
| +#include "core/html/ImageDocument.h" |
|
yhirano
2016/04/22 04:12:13
Do we need to include this header?
Nate Chapin
2016/04/25 22:13:03
No, removed.
|
| #include "core/html/parser/HTMLParserIdioms.h" |
| #include "core/inspector/InspectorInstrumentation.h" |
| #include "core/layout/LayoutImage.h" |
| @@ -282,9 +283,6 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up |
| if (updateBehavior == UpdateForcedReload) { |
| resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); |
| resourceRequest.setLoFiState(WebURLRequest::LoFiOff); |
| - // ImageLoader defers the load of images when in an ImageDocument. |
| - // Don't defer this load on a forced reload. |
| - m_loadingImageDocument = false; |
| } |
| if (referrerPolicy != ReferrerPolicyDefault) |
| @@ -295,18 +293,7 @@ void ImageLoader::doUpdateFromElement(BypassMainWorldBehavior bypassBehavior, Up |
| FetchRequest request(resourceRequest, element()->localName(), resourceLoaderOptions); |
| configureRequest(request, bypassBehavior, *m_element, document.clientHintsPreferences()); |
| - // Prevent the immediate creation of a ResourceLoader (and therefore a network |
| - // request) for ImageDocument loads. In this case, the image contents have already |
| - // been requested as a main resource and ImageDocumentParser will take care of |
| - // funneling the main resource bytes into the ImageResource. |
| - if (m_loadingImageDocument) { |
| - request.setDefer(FetchRequest::DeferredByClient); |
| - request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); |
| - } |
| - |
| newImage = ImageResource::fetch(request, document.fetcher()); |
| - if (m_loadingImageDocument && newImage) |
| - newImage->setStatus(Resource::Pending); |
| if (!newImage && !pageIsBeingDismissed(&document)) { |
| crossSiteOrCSPViolationOccurred(imageSourceURL); |
| @@ -374,6 +361,16 @@ void ImageLoader::updateFromElement(UpdateFromElementBehavior updateBehavior, Re |
| if (!m_failedLoadURL.isEmpty() && imageSourceURL == m_failedLoadURL) |
| return; |
| + // Prevent the creation of a ResourceLoader (and therefore a network |
| + // request) for ImageDocument loads. In this case, the image contents have already |
| + // been requested as a main resource and ImageDocumentParser will take care of |
| + // funneling the main resource bytes into m_image, so just create an ImageResource |
| + // to be populated later. |
| + if (m_loadingImageDocument) { |
| + setImage(ImageResource::create(imageSourceToKURL(m_element->imageSourceURL()))); |
|
yhirano
2016/04/22 04:12:13
imageResource->setStatus(Pending) needed?
Nate Chapin
2016/04/25 22:13:03
"Need", not as the code currently works. But it's
|
| + return; |
| + } |
| + |
| // If we have a pending task, we have to clear it -- either we're |
| // now loading immediately, or we need to reset the task's state. |
| if (m_pendingTask) { |
| @@ -432,7 +429,7 @@ bool ImageLoader::shouldLoadImmediately(const KURL& url) const |
| if (resource && !resource->errorOccurred()) |
| return true; |
| } |
| - return (m_loadingImageDocument || isHTMLObjectElement(m_element) || isHTMLEmbedElement(m_element) || url.protocolIsData()); |
| + return (isHTMLObjectElement(m_element) || isHTMLEmbedElement(m_element) || url.protocolIsData()); |
| } |
| void ImageLoader::imageNotifyFinished(ImageResource* resource) |