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

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

Issue 1879793003: Remove DeferredByClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Resource_load
Patch Set: Created 4 years, 8 months 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 | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f7b3c340d4f56daea2d5f7835e0b4ab7a2e49b39 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"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/layout/LayoutImage.h"
@@ -151,7 +152,6 @@ ImageLoader::ImageLoader(Element* element)
, m_hasPendingLoadEvent(false)
, m_hasPendingErrorEvent(false)
, m_imageComplete(true)
- , m_loadingImageDocument(false)
yhirano 2016/04/20 08:42:41 Can you tell me why you deleted this statement?
Nate Chapin 2016/04/21 18:52:46 It's a mistake. My first pass deleted this variabl
, m_elementIsProtected(false)
, m_suppressErrorEvents(false)
{
@@ -282,9 +282,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 +292,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 +360,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/20 08:42:41 ImageResource::create(const ResourceRequest&) is e
Nate Chapin 2016/04/21 18:52:46 It's safe to use, it's mostly a question of whethe
+ 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 +428,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)
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698