OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv
ed. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 AtomicString imageSourceURL = m_element->imageSourceURL(); | 275 AtomicString imageSourceURL = m_element->imageSourceURL(); |
276 KURL url = imageSourceToKURL(imageSourceURL); | 276 KURL url = imageSourceToKURL(imageSourceURL); |
277 ImageResource* newImage = nullptr; | 277 ImageResource* newImage = nullptr; |
278 if (!url.isNull()) { | 278 if (!url.isNull()) { |
279 // Unlike raw <img>, we block mixed content inside of <picture> or <img
srcset>. | 279 // Unlike raw <img>, we block mixed content inside of <picture> or <img
srcset>. |
280 ResourceLoaderOptions resourceLoaderOptions = ResourceFetcher::defaultRe
sourceOptions(); | 280 ResourceLoaderOptions resourceLoaderOptions = ResourceFetcher::defaultRe
sourceOptions(); |
281 ResourceRequest resourceRequest(url); | 281 ResourceRequest resourceRequest(url); |
282 if (updateBehavior == UpdateForcedReload) { | 282 if (updateBehavior == UpdateForcedReload) { |
283 resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); | 283 resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); |
284 resourceRequest.setLoFiState(WebURLRequest::LoFiOff); | 284 resourceRequest.setLoFiState(WebURLRequest::LoFiOff); |
285 // ImageLoader defers the load of images when in an ImageDocument. | |
286 // Don't defer this load on a forced reload. | |
287 m_loadingImageDocument = false; | |
288 } | 285 } |
289 | 286 |
290 if (referrerPolicy != ReferrerPolicyDefault) | 287 if (referrerPolicy != ReferrerPolicyDefault) |
291 resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer(ref
errerPolicy, url, document.outgoingReferrer())); | 288 resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer(ref
errerPolicy, url, document.outgoingReferrer())); |
292 | 289 |
293 if (isHTMLPictureElement(element()->parentNode()) || !element()->fastGet
Attribute(HTMLNames::srcsetAttr).isNull()) | 290 if (isHTMLPictureElement(element()->parentNode()) || !element()->fastGet
Attribute(HTMLNames::srcsetAttr).isNull()) |
294 resourceRequest.setRequestContext(WebURLRequest::RequestContextImage
Set); | 291 resourceRequest.setRequestContext(WebURLRequest::RequestContextImage
Set); |
295 FetchRequest request(resourceRequest, element()->localName(), resourceLo
aderOptions); | 292 FetchRequest request(resourceRequest, element()->localName(), resourceLo
aderOptions); |
296 configureRequest(request, bypassBehavior, *m_element, document.clientHin
tsPreferences()); | 293 configureRequest(request, bypassBehavior, *m_element, document.clientHin
tsPreferences()); |
297 | 294 |
298 // Prevent the immediate creation of a ResourceLoader (and therefore a n
etwork | |
299 // request) for ImageDocument loads. In this case, the image contents ha
ve already | |
300 // been requested as a main resource and ImageDocumentParser will take c
are of | |
301 // funneling the main resource bytes into the ImageResource. | |
302 if (m_loadingImageDocument) { | |
303 request.setDefer(FetchRequest::DeferredByClient); | |
304 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); | |
305 } | |
306 | |
307 newImage = ImageResource::fetch(request, document.fetcher()); | 295 newImage = ImageResource::fetch(request, document.fetcher()); |
308 if (m_loadingImageDocument && newImage) | |
309 newImage->setStatus(Resource::Pending); | |
310 | 296 |
311 if (!newImage && !pageIsBeingDismissed(&document)) { | 297 if (!newImage && !pageIsBeingDismissed(&document)) { |
312 crossSiteOrCSPViolationOccurred(imageSourceURL); | 298 crossSiteOrCSPViolationOccurred(imageSourceURL); |
313 dispatchErrorEvent(); | 299 dispatchErrorEvent(); |
314 } else { | 300 } else { |
315 clearFailedLoadURL(); | 301 clearFailedLoadURL(); |
316 } | 302 } |
317 } else { | 303 } else { |
318 if (!imageSourceURL.isNull()) { | 304 if (!imageSourceURL.isNull()) { |
319 // Fire an error event if the url string is not empty, but the KURL
is. | 305 // Fire an error event if the url string is not empty, but the KURL
is. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 { | 353 { |
368 AtomicString imageSourceURL = m_element->imageSourceURL(); | 354 AtomicString imageSourceURL = m_element->imageSourceURL(); |
369 m_suppressErrorEvents = (updateBehavior == UpdateSizeChanged); | 355 m_suppressErrorEvents = (updateBehavior == UpdateSizeChanged); |
370 | 356 |
371 if (updateBehavior == UpdateIgnorePreviousError) | 357 if (updateBehavior == UpdateIgnorePreviousError) |
372 clearFailedLoadURL(); | 358 clearFailedLoadURL(); |
373 | 359 |
374 if (!m_failedLoadURL.isEmpty() && imageSourceURL == m_failedLoadURL) | 360 if (!m_failedLoadURL.isEmpty() && imageSourceURL == m_failedLoadURL) |
375 return; | 361 return; |
376 | 362 |
| 363 // Prevent the creation of a ResourceLoader (and therefore a network |
| 364 // request) for ImageDocument loads. In this case, the image contents have a
lready |
| 365 // been requested as a main resource and ImageDocumentParser will take care
of |
| 366 // funneling the main resource bytes into m_image, so just create an ImageRe
source |
| 367 // to be populated later. |
| 368 if (m_loadingImageDocument && updateBehavior != UpdateForcedReload) { |
| 369 setImage(ImageResource::create(imageSourceToKURL(m_element->imageSourceU
RL()))); |
| 370 m_image->setStatus(Resource::Pending); |
| 371 return; |
| 372 } |
| 373 |
377 // If we have a pending task, we have to clear it -- either we're | 374 // If we have a pending task, we have to clear it -- either we're |
378 // now loading immediately, or we need to reset the task's state. | 375 // now loading immediately, or we need to reset the task's state. |
379 if (m_pendingTask) { | 376 if (m_pendingTask) { |
380 m_pendingTask->clearLoader(); | 377 m_pendingTask->clearLoader(); |
381 m_pendingTask.clear(); | 378 m_pendingTask.clear(); |
382 } | 379 } |
383 | 380 |
384 KURL url = imageSourceToKURL(imageSourceURL); | 381 KURL url = imageSourceToKURL(imageSourceURL); |
385 if (shouldLoadImmediately(url)) { | 382 if (shouldLoadImmediately(url)) { |
386 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior, referrerPol
icy); | 383 doUpdateFromElement(DoNotBypassMainWorldCSP, updateBehavior, referrerPol
icy); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 422 |
426 bool ImageLoader::shouldLoadImmediately(const KURL& url) const | 423 bool ImageLoader::shouldLoadImmediately(const KURL& url) const |
427 { | 424 { |
428 // We force any image loads which might require alt content through the asyn
chronous path so that we can add the shadow DOM | 425 // We force any image loads which might require alt content through the asyn
chronous path so that we can add the shadow DOM |
429 // for the alt-text content when style recalc is over and DOM mutation is al
lowed again. | 426 // for the alt-text content when style recalc is over and DOM mutation is al
lowed again. |
430 if (!url.isNull()) { | 427 if (!url.isNull()) { |
431 Resource* resource = memoryCache()->resourceForURL(url, m_element->docum
ent().fetcher()->getCacheIdentifier()); | 428 Resource* resource = memoryCache()->resourceForURL(url, m_element->docum
ent().fetcher()->getCacheIdentifier()); |
432 if (resource && !resource->errorOccurred()) | 429 if (resource && !resource->errorOccurred()) |
433 return true; | 430 return true; |
434 } | 431 } |
435 return (m_loadingImageDocument || isHTMLObjectElement(m_element) || isHTMLEm
bedElement(m_element) || url.protocolIsData()); | 432 return (isHTMLObjectElement(m_element) || isHTMLEmbedElement(m_element) || u
rl.protocolIsData()); |
436 } | 433 } |
437 | 434 |
438 void ImageLoader::imageNotifyFinished(ImageResource* resource) | 435 void ImageLoader::imageNotifyFinished(ImageResource* resource) |
439 { | 436 { |
440 WTF_LOG(Timers, "ImageLoader::imageNotifyFinished %p; m_hasPendingLoadEvent=
%d", | 437 WTF_LOG(Timers, "ImageLoader::imageNotifyFinished %p; m_hasPendingLoadEvent=
%d", |
441 this, m_hasPendingLoadEvent); | 438 this, m_hasPendingLoadEvent); |
442 | 439 |
443 ASSERT(m_failedLoadURL.isEmpty()); | 440 ASSERT(m_failedLoadURL.isEmpty()); |
444 ASSERT(resource == m_image.get()); | 441 ASSERT(resource == m_image.get()); |
445 | 442 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 | 605 |
609 void ImageLoader::elementDidMoveToNewDocument() | 606 void ImageLoader::elementDidMoveToNewDocument() |
610 { | 607 { |
611 if (m_loadDelayCounter) | 608 if (m_loadDelayCounter) |
612 m_loadDelayCounter->documentChanged(m_element->document()); | 609 m_loadDelayCounter->documentChanged(m_element->document()); |
613 clearFailedLoadURL(); | 610 clearFailedLoadURL(); |
614 setImage(0); | 611 setImage(0); |
615 } | 612 } |
616 | 613 |
617 } // namespace blink | 614 } // namespace blink |
OLD | NEW |