| 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 | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights |
| 5 * reserved. | 5 * reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 static void configureRequest( | 224 static void configureRequest( |
| 225 FetchRequest& request, | 225 FetchRequest& request, |
| 226 ImageLoader::BypassMainWorldBehavior bypassBehavior, | 226 ImageLoader::BypassMainWorldBehavior bypassBehavior, |
| 227 Element& element, | 227 Element& element, |
| 228 const ClientHintsPreferences& clientHintsPreferences) { | 228 const ClientHintsPreferences& clientHintsPreferences) { |
| 229 if (bypassBehavior == ImageLoader::BypassMainWorldCSP) | 229 if (bypassBehavior == ImageLoader::BypassMainWorldCSP) |
| 230 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); | 230 request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy); |
| 231 | 231 |
| 232 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue( | 232 CrossOriginAttributeValue crossOrigin = crossOriginAttributeValue( |
| 233 element.fastGetAttribute(HTMLNames::crossoriginAttr)); | 233 element.fastGetAttribute(HTMLNames::crossoriginAttr)); |
| 234 if (crossOrigin != CrossOriginAttributeNotSet) | 234 if (crossOrigin != CrossOriginAttributeNotSet) { |
| 235 request.setCrossOriginAccessControl(element.document().getSecurityOrigin(), | 235 request.setCrossOriginAccessControl(element.document().getSecurityOrigin(), |
| 236 crossOrigin); | 236 crossOrigin); |
| 237 } |
| 237 | 238 |
| 238 if (clientHintsPreferences.shouldSendResourceWidth() && | 239 if (clientHintsPreferences.shouldSendResourceWidth() && |
| 239 isHTMLImageElement(element)) | 240 isHTMLImageElement(element)) |
| 240 request.setResourceWidth(toHTMLImageElement(element).getResourceWidth()); | 241 request.setResourceWidth(toHTMLImageElement(element).getResourceWidth()); |
| 241 } | 242 } |
| 242 | 243 |
| 243 inline void ImageLoader::dispatchErrorEvent() { | 244 inline void ImageLoader::dispatchErrorEvent() { |
| 244 m_hasPendingErrorEvent = true; | 245 m_hasPendingErrorEvent = true; |
| 245 errorEventSender().dispatchEventSoon(this); | 246 errorEventSender().dispatchEventSoon(this); |
| 246 } | 247 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 // Unlike raw <img>, we block mixed content inside of <picture> or | 293 // Unlike raw <img>, we block mixed content inside of <picture> or |
| 293 // <img srcset>. | 294 // <img srcset>. |
| 294 ResourceLoaderOptions resourceLoaderOptions = | 295 ResourceLoaderOptions resourceLoaderOptions = |
| 295 ResourceFetcher::defaultResourceOptions(); | 296 ResourceFetcher::defaultResourceOptions(); |
| 296 ResourceRequest resourceRequest(url); | 297 ResourceRequest resourceRequest(url); |
| 297 if (updateBehavior == UpdateForcedReload) { | 298 if (updateBehavior == UpdateForcedReload) { |
| 298 resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); | 299 resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); |
| 299 resourceRequest.setLoFiState(WebURLRequest::LoFiOff); | 300 resourceRequest.setLoFiState(WebURLRequest::LoFiOff); |
| 300 } | 301 } |
| 301 | 302 |
| 302 if (referrerPolicy != ReferrerPolicyDefault) | 303 if (referrerPolicy != ReferrerPolicyDefault) { |
| 303 resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer( | 304 resourceRequest.setHTTPReferrer(SecurityPolicy::generateReferrer( |
| 304 referrerPolicy, url, document.outgoingReferrer())); | 305 referrerPolicy, url, document.outgoingReferrer())); |
| 306 } |
| 305 | 307 |
| 306 if (isHTMLPictureElement(element()->parentNode()) || | 308 if (isHTMLPictureElement(element()->parentNode()) || |
| 307 !element()->fastGetAttribute(HTMLNames::srcsetAttr).isNull()) | 309 !element()->fastGetAttribute(HTMLNames::srcsetAttr).isNull()) |
| 308 resourceRequest.setRequestContext(WebURLRequest::RequestContextImageSet); | 310 resourceRequest.setRequestContext(WebURLRequest::RequestContextImageSet); |
| 309 FetchRequest request(resourceRequest, element()->localName(), | 311 FetchRequest request(resourceRequest, element()->localName(), |
| 310 resourceLoaderOptions); | 312 resourceLoaderOptions); |
| 311 configureRequest(request, bypassBehavior, *m_element, | 313 configureRequest(request, bypassBehavior, *m_element, |
| 312 document.clientHintsPreferences()); | 314 document.clientHintsPreferences()); |
| 313 | 315 |
| 314 newImage = ImageResource::fetch(request, document.fetcher()); | 316 newImage = ImageResource::fetch(request, document.fetcher()); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 if (m_image && m_image->getImage() && m_image->getImage()->isSVGImage()) | 481 if (m_image && m_image->getImage() && m_image->getImage()->isSVGImage()) |
| 480 toSVGImage(m_image->getImage())->updateUseCounters(element()->document()); | 482 toSVGImage(m_image->getImage())->updateUseCounters(element()->document()); |
| 481 | 483 |
| 482 if (!m_hasPendingLoadEvent) | 484 if (!m_hasPendingLoadEvent) |
| 483 return; | 485 return; |
| 484 | 486 |
| 485 if (resource->errorOccurred()) { | 487 if (resource->errorOccurred()) { |
| 486 loadEventSender().cancelEvent(this); | 488 loadEventSender().cancelEvent(this); |
| 487 m_hasPendingLoadEvent = false; | 489 m_hasPendingLoadEvent = false; |
| 488 | 490 |
| 489 if (resource->resourceError().isAccessCheck()) | 491 if (resource->resourceError().isAccessCheck()) { |
| 490 crossSiteOrCSPViolationOccurred( | 492 crossSiteOrCSPViolationOccurred( |
| 491 AtomicString(resource->resourceError().failingURL())); | 493 AtomicString(resource->resourceError().failingURL())); |
| 494 } |
| 492 | 495 |
| 493 // The error event should not fire if the image data update is a result of | 496 // The error event should not fire if the image data update is a result of |
| 494 // environment change. | 497 // environment change. |
| 495 // https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-elem
ent:the-img-element-55 | 498 // https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-elem
ent:the-img-element-55 |
| 496 if (!m_suppressErrorEvents) | 499 if (!m_suppressErrorEvents) |
| 497 dispatchErrorEvent(); | 500 dispatchErrorEvent(); |
| 498 | 501 |
| 499 // Only consider updating the protection ref-count of the Element | 502 // Only consider updating the protection ref-count of the Element |
| 500 // immediately before returning from this function as doing so might result | 503 // immediately before returning from this function as doing so might result |
| 501 // in the destruction of this ImageLoader. | 504 // in the destruction of this ImageLoader. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 } | 635 } |
| 633 | 636 |
| 634 void ImageLoader::elementDidMoveToNewDocument() { | 637 void ImageLoader::elementDidMoveToNewDocument() { |
| 635 if (m_loadDelayCounter) | 638 if (m_loadDelayCounter) |
| 636 m_loadDelayCounter->documentChanged(m_element->document()); | 639 m_loadDelayCounter->documentChanged(m_element->document()); |
| 637 clearFailedLoadURL(); | 640 clearFailedLoadURL(); |
| 638 setImage(0); | 641 setImage(0); |
| 639 } | 642 } |
| 640 | 643 |
| 641 } // namespace blink | 644 } // namespace blink |
| OLD | NEW |